In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Ricardo SIGNES) wrote:
> I can do this in AppleScript:
>
> tell application "iTunes"
> tell playlist "Library"
> get tracks whose played date is greater than date
> "January 1, 2005"
> end tell
> end tell
>
> I can't reproduce this kind of query in Mac::Glue, as far as I can tell.
> I tried using a string and a timestamp in place of the date, but to no
> avail. What should I be doing?
Not sure what you tried, but basically, you use track whose(played_date =>
g_t => $date). The question is how to construct $date. AppleScript can
afford to make more assumptions than we can, so param_type() helps us
defined types when necessary.
For dates there's two steps: get the epoch time (with timelocal here), and
then pass it to param_type to define it as typeLongDateTime.
use Mac::Glue ':all';
use Time::Local;
my $itunes = new Mac::Glue 'iTunes';
my $library = $itunes->obj(playlist => 'Local Library');
my $time = timelocal(0, 0, 0, 1, 0, 105); # jan 1 2005
my @tracks = $library->obj(track =>
whose(played_date => g_t => param_type(typeLongDateTime, $time)),
)->get;
# check our work
for (@tracks) {
print $_->prop('name')->get, ": ";
print scalar localtime $_->prop('played date')->get, "\n";
}
--
Chris Nandor [EMAIL PROTECTED] http://pudge.net/
Open Source Technology Group [EMAIL PROTECTED] http://ostg.com/