デスクトップの背景を iTunes で現在再生中の曲のアルバム アートワークに設定するアプリケーションを作成しようとしていますが、スクリプトが Apple Music の曲のアルバム アートを読み取ることができないという問題に遭遇しました。ユーザーの音楽コレクションまたはプレイリストに追加されました。
現在、このコードを使用してアルバム アートを抽出しています。
-- 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 から直接再生するときにこれが機能しない理由を知っている人はいますか?
したがって、Apple Music の曲をライブラリまたはプレイリストに追加でき、スクリプトはそのアルバム アートを読み取ることができます (曲をダウンロードする必要はありません)。曲を再生すると、スクリプトがそれを読み取らず、アプリケーションがクラッシュします。
このアプリケーションを使用できるようにしたい人なら誰でも大好きなので、どんな提案でも大歓迎です。