2016-05-26 7 views
2

iTunesで再生している現在の曲のアルバムアートワークにデスクトップの背景を設定するアプリケーションを作成しようとしていますが、ユーザーの音楽コレクションまたはプレイリストに追加されていない限り、Apple Musicの曲のアルバムアートを読み上げません。アップルスクリプトでiTunesのApple Musicアルバムアートにアクセスする方法

現在、私はthis codeを使用してアルバムアートを抽出しています。

-- get the raw bytes of the artwork into a var 
tell application "iTunes" to tell artwork 1 of current track 
    set srcBytes to raw data 
    -- figure out the proper file extension 
    if format is «class PNG » then 
     set ext to ".png" 
    else 
     set ext to ".jpg" 
    end if 
end tell 

-- get the filename to ~/Desktop/cover.ext 
set fileName to (((path to desktop) as text) & "cover" & ext) 
-- write to file 
set outFile to open for access file fileName with write permission 
-- truncate the file 
set eof outFile to 0 
-- write the image bytes to the file 
write srcBytes to outFile 
close access outFile 

アップルの音楽から直接再生するときにこれが機能しない理由は誰にも分かりますか?
Apple Musicソングをライブラリやプレイリストに追加することができます。スクリプトはアルバムアートを読むことができます(曲をダウンロードする必要はありません)。しかし、NewまたはFor Youセクションをブラウズするだけで、私のスクリプトはそれを読まず、私のアプリケーションはクラッシュするでしょう。

このアプリケーションを使用できるようにしたいと思っている人には、どんな提案も大歓迎です。アップルの音楽をストリーミングするとき

答えて

1

申し訳ありませんが、現在のトラックURLトラックです。これはトラックから継承していますが、アートワークの要素リストはiTunesのスクリプト作成機能によって公開されていないため、カバーアートは利用できません。

tell application "iTunes" 
    tell current track 
     if exists (every artwork) then 
      tell artwork 1 
       get properties 
      end tell 
     else 
      tell me to display alert "No Cover Art found." 
     end if 
    end tell 
end tell 
+0

「存在するアートワーク」は素晴らしい作品でした。 「存在するアートワーク1」を使用すると、「現在のトラックのアートワーク1の生データを取得できません」というエラーが表示されました。 –

+0

@BenClose、うれしかった。私はあなたのフィードバックを組み込むために答えを更新しました。回答に満足している場合は、チェックマークをクリックして回答を受け入れてください。ありがとう! –

関連する問題