Applescript、iTunes 和“日期”;
我有一个苹果脚本,我调用一首歌曲来设置播放计数,另一首歌曲设置最后播放日期。这些是从 perl 脚本调用的,该脚本从 last.fm 获取数据。不幸的是,每当我调用上次播放日期脚本时,我都会收到一条错误消息 setItunesLastPlayed.scpt:执行错误:iTunes 出现错误:发生描述符类型不匹配。 (-10001)
。
我是这样称呼它的:
osascript /Users/gms8994/setItunesLastPlayed.scpt "<ARTIST>" "<TITLE>" "Wednesday, July 05, 2011 07:14:11 AM"
我确实注意到,如果我从 itunes 请求最后一次播放的值,它会返回没有零填充的日期和小时,所以我尝试删除它们,但无济于事。
这是我的脚本。
on run argv
tell application "iTunes"
set theArtist to (item 1 of argv)
set theTitle to (item 2 of argv)
set theLastPlay to (item 3 of argv)
set theLastPlay to date theLastPlay
set results to (every file track of playlist "Library" whose artist contains theArtist and name contains theTitle)
repeat with t in results
tell t
say theLastPlay
set played date of t to theLastPlay
end tell
end repeat
end tell
end run
谁能指出我的修复方法吗?
I've got an applescript that I call for a song to set the play count and another to set the last played date. These are called from a perl script fetching data from last.fm. Unfortunately, whenever I call the last played date script, I get an error message setItunesLastPlayed.scpt: execution error: iTunes got an error: A descriptor type mismatch occurred. (-10001)
.
I'm calling it like this:
osascript /Users/gms8994/setItunesLastPlayed.scpt "<ARTIST>" "<TITLE>" "Wednesday, July 05, 2011 07:14:11 AM"
I did notice that if I request the value of the last play from itunes, it comes back without zero-padding days and hours, so I tried removing those, to no avail.
Here's my script.
on run argv
tell application "iTunes"
set theArtist to (item 1 of argv)
set theTitle to (item 2 of argv)
set theLastPlay to (item 3 of argv)
set theLastPlay to date theLastPlay
set results to (every file track of playlist "Library" whose artist contains theArtist and name contains theTitle)
repeat with t in results
tell t
say theLastPlay
set played date of t to theLastPlay
end tell
end repeat
end tell
end run
Can anyone point me to the fix?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
曲目的
播放日期
属性需要一个日期
对象,而不仅仅是日期字符串。您需要将日期转换为日期对象:我认为没有办法直接从给定的字符串创建日期对象,因此您必须维护一个函数来为您执行此操作,以防万一。 fm(或他们用来存储和报告回溯日期的技术)决定更改他们的日期格式。
The
played date
property of a track requires adate
object, not just the date string. You will need to convert your date into a date object:I don't think there is a way to directly create a date object from a given string, so you'll have to maintain a function to do that for you in case last.fm (or the technology they rely to store and report back dates) decides to change their date format.