Applescript、iTunes 和“日期”;

发布于 2024-11-19 19:15:22 字数 1022 浏览 1 评论 0原文

我有一个苹果脚本,我调用一首歌曲来设置播放计数,另一首歌曲设置最后播放日期。这些是从 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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸢与 2024-11-26 19:15:22

曲目的播放日期属性需要一个日期对象,而不仅仅是日期字符串。您需要将日期转换为日期对象:

set newDate to (current date)
set month of newDate to "July"
set year of newDate to "2011"
(* You can fill in the rest *)
set played date of t to newDate

我认为没有办法直接从给定的字符串创建日期对象,因此您必须维护一个函数来为您执行此操作,以防万一。 fm(或他们用来存储和报告回溯日期的技术)决定更改他们的日期格式。

The played date property of a track requires a date object, not just the date string. You will need to convert your date into a date object:

set newDate to (current date)
set month of newDate to "July"
set year of newDate to "2011"
(* You can fill in the rest *)
set played date of t to newDate

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文