Applescript:通过文件系统路径在播放列表中查找曲目
无法根据文件系统路径(位置)从播放列表中选择曲目。见下文。
我在每个命令的结果之前放置了箭头。
在第一行中,我成功地从播放列表“Testing”中找到了流派“R&B”的第一首曲目。
为什么第四行不起作用?看起来我正在做与第 1 行相同的事情,仅按文件系统位置而不是按流派搜索。
还有另一种方法可以做到这一点吗?
tell application "iTunes"....
set t to first track of playlist "Testing" whose genre is "R&B"
--> file track id 18476 of user playlist id 18414 of source id 72 of application "iTunes"
set l to location of track 1 of playlist "Testing"
--> alias "Lion:Users:cworth:Desktop:a.mp3"
set f to POSIX file "/Users/cworth/Desktop/a.mp3" as alias
--> alias "Lion:Users:cworth:Desktop:a.mp3"
set tt to first track of playlist "Testing" whose location is f
--> error "iTunes got an error: A descriptor type mismatch occurred." number -10001 to item
...end tell
Can't pick a track from a playlist based on it's file system path (location). See below.
I put arrows before the result of each command.
In the first line, I successfully find the first track from the playlist "Testing" with genre "R&B".
Why doesn't the fourth line work ? It looks like I am doing the same as line 1 only searching by file-system location instead of by genre.
Is there another way to do this ?
tell application "iTunes"....
set t to first track of playlist "Testing" whose genre is "R&B"
--> file track id 18476 of user playlist id 18414 of source id 72 of application "iTunes"
set l to location of track 1 of playlist "Testing"
--> alias "Lion:Users:cworth:Desktop:a.mp3"
set f to POSIX file "/Users/cworth/Desktop/a.mp3" as alias
--> alias "Lion:Users:cworth:Desktop:a.mp3"
set tt to first track of playlist "Testing" whose location is f
--> error "iTunes got an error: A descriptor type mismatch occurred." number -10001 to item
...end tell
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
研究了 Applescript 并让它在曲目上使用显式循环:(见下文)
为什么上面的示例不起作用的一个可能的解释是“播放列表“测试”的第一首曲目的位置是...”返回对象说明符列表(例如,播放列表“测试”的第一首曲目的位置等)而不是实际位置列表 - 即缺少的是返回您在重复循环内看到的实际位置的“get”命令以下。这也许可以解释描述符类型不匹配的原因?我没有 Applescript 专业知识或动力继续前进,既然我已经让它工作了,但我很高兴它是这样!
Studied up on Applescript and got it working with an explicit loop over the tracks: (see below)
A possible explanation for why the example above doesn't work is that the 'first track of playlist "Testing" whose location is...' returns a list of object specifiers (e.g. location of first track of playlist "Testing", etc.) instead of a list of actual locations - i.e. what's missing is the "get" command that returns the actual locations that you see inside the repeat loop below. That would explain the descriptor type mismatch, maybe ? I don't have the Applescript expertise or motivation to go any further, now that I've got it working, but I'm glad that it is!
非常迟来的回复。我认为问题在于
track
类型没有location
属性,但file track
类型有。尝试搜索file track
实例列表而不是所有track
实例:Very belated reply. I believe the issue is that the
track
type does not have alocation
attribute, but the typefile track
does. Try searching the list offile track
instances rather than alltrack
instances: