【发布时间】:2016-06-11 21:46:32
【问题描述】:
我制作了一个自动化工作流程,可以将歌曲添加到我的 iTunes 库中,并通过艺术家姓名、专辑名称和歌曲名称设置他们的信息。然而,当我导入它们时,这些轨道是无盖的,所以我一直在寻找自动添加艺术品的方法。其中一种方法是使用 iTunes“获取专辑插图”。这样做的问题是,即使它提供了,它通常也不能提供非常好的艺术品。
我决定下载我的“下载”文件夹中没有的歌曲的艺术作品。我传入脚本的input 是.jpg 文件,我想将其作为艺术品添加到歌曲中。问题是每当我运行这个脚本时,它都会说它不能将别名文件变成文件类型。错误信息如下:
无法将别名“Macintosh HD:Users:Nilay:Downloads:Avicii - True - Hey Brother.jpg”添加到类型文件中。
没有理由找不到该文件,因为我使用 Automator“过滤查找器项目”找到该文件,所以我知道它传递了正确的文件。
我试图传递文件的文本而不是实际的文件,但这仍然导致相同的消息。前几个 cmets 是我尝试解决此错误消息的几种方法,但可惜没有奏效。
我想知道是否有人知道如何解决此错误消息或以其他方式向歌曲添加自定义图稿,而无需手动转到 iTunes -> 选择歌曲 -> 获取信息 -> 图稿 -> 添加图稿。如果有人可以解释如何使用 AppleScript 或 Workflow 自动执行此操作,那也是可行的。谢谢!!!
on run {input, parameters}
--set jpegFilename to input
--set jpegFilename to "/path/to/some/artwork.jpg"
--set jpegFile to (POSIX file jpegFilename)
--set jpegFile to (jpegFilename as POSIX file)
--tell application "System Events" to set jpegFile to (input as POSIX file)
set jpegFile to input
tell application "Image Events"
set myImage to open (jpegFile as file)
-- the below line needs HFS syntax pathname, eg: MyComputer:Users:liquidx:
-- save myImage as PICT in (file ":path:to:some:temporary.pict")
save myImage as PICT in (POSIX file jpegFile)
close myImage
end tell
tell application "iTunes"
set myTrack to current track
set artworkCount to count of artwork of myTrack
-- the below line needs HFS syntax pathname, eg: MyComputer:Users:liquidx:
-- set myArt to read (file ":path:to:some:temporary.pict") from 513 as picture
set myArt to read (POSIX file jpegFile) from 513 as picture
if artworkCount > 0 then
set data of artwork (artworkCount + 1) of current track to myArt
else
set data of artwork 1 of current track to myArt
end if
end tell
tell application "Image Events"
-- delete (file ":path:to:some:temporary.pict")
delete (POSIX file jpegFile)
end tell
end run
【问题讨论】:
标签: applescript posix itunes itunesartwork