【发布时间】:2017-05-02 12:22:14
【问题描述】:
能否将此applescript 转换为使用iTunes Library framework 而不是使用标准的iTunes applescript。
我当前的脚本读取用户的 iTunes 库并创建一个由 TrackName、TrackLocation 和 PersistentId 组成的文件,它工作可靠,但当用户拥有大型 iTunes 库时可能会很慢
tell application "iTunes"
with timeout of 2400 seconds
if (count of every file track of library playlist 1) is equal to 0 then
set thePath to (POSIX file "/tmp/songkong_itunes_model.new")
set fileref to open for access (thePath) with write permission
set eof fileref to 0
close access fileref
return
end if
tell every file track of library playlist 1
script performancekludge
property tracknames : its name
property locs : its location
property persistids : its persistent ID
end script
end tell
end timeout
end tell
set thePath to (POSIX file "/tmp/songkong_itunes_model.new")
set fileref to open for access (thePath) with write permission
set eof fileref to 0
tell performancekludge
repeat with i from 1 to length of its tracknames
try
set nextline to item i of its tracknames ¬
& "::" & POSIX path of item i of its locs ¬
& "::" & item i of its persistids
write nextline & linefeed as «class utf8» to fileref
end try
end repeat
end tell
close access fileref
最大的不同是这个新框架不需要 iTunes 实际运行,我希望它应该更快。然而,稀疏的指令只讨论了 ObjectiveC 我不清楚我将如何在 applescript 中编写一个版本(甚至在 Java 中更好)
【问题讨论】:
标签: applescript itunes