iTunes:AppleScript ->Playlist von kürzlich bewerteten Titeln erstellen
7/02/2009Die Idee (von dem hier):
Eine Playliste von Titel erstellen, die innerhalb der letzten x Tage mit y Sternchen bewertet wurden. Das Problem: iTunes speicher nicht das Datum ab, an dem die Bewertung verändert wurde, nur wann Song hinzugefügt oder zuletzt gehört wurde.Ein mögliche Lösung?
Man bewertet den Song über einen Script-Aufruf und schreibt damit das Datum in den Kommentar und über ein 2 Script wertet man dann alle bewerteten Songs, die einen entsprechenden Kommentar haben aus und kopiert diese in eine Liste.Ist nicht gerade eine super Lösung, aber mehr gibt die Aufgabenstellung auch nicht wirklich her ;-PMit diesem Skript setzt man die Bewertungen:
property stars : {1, 2, 3, 4, 5}
tell application "iTunes"
set these_ to selection of browser window 1
set new_timestamp to ((do shell script "perl -e 'print time();'"))
set rating_time to "##rating_time##" & new_timestamp & "##"
set myrating to ((choose from list stars default items {3} with prompt "Your Raiting:") as integer) * 20
repeat with this_ in these_
set rating of this_ to myrating
if comment of this_ contains "##rating_time##" then
set AppleScript's text item delimiters to "##"
set timestamp to (item -2 of (every text item of (comment of this_ as text))) as text
set AppleScript's text item delimiters to ""
if (comment of this_ as text) contains the ("##rating_time##" & timestamp & "##" as text) then
set AppleScript's text item delimiters to the ("##rating_time##" & timestamp & "##" as text)
set the item_list to every text item of (comment of this_ as text)
set AppleScript's text item delimiters to the "##rating_time##" & new_timestamp & "##" as text
set comment of this_ to the item_list as string
set AppleScript's text item delimiters to ""
end if
else
set comment of this_ to comment of this_ & rating_time
end if
end repeat
end tell
Mit diesem Skript Erstellt man anschließend die Playliste
property stars : {1, 2, 3, 4, 5}
property daysold : 3
set myrating to ((choose from list stars default items {3} with prompt "Rating for songs in Playlist?") as integer) * 20
set playlist_name to text returned of (display dialog "Playlist Name" default answer ("_Songs with a Rating of " & myrating & ",within the last " & daysold & " days")) as text
tell application "iTunes"
set these_ to every track of playlist 1 of source 1 whose rating = myrating
if these_ ≠ {} then
tell source 1
if playlist playlist_name exists then
set myplaylist to playlist playlist_name
delete every track of myplaylist
else
set myplaylist to make new playlist with properties {name:playlist_name}
end if
repeat with this_ in these_
if comment of this_ contains "##rating_time##" then
try
set mycomment to comment of this_
set AppleScript's text item delimiters to "##"
set h to (item -2 of (every text item of mycomment)) as integer
set AppleScript's text item delimiters to ""
if (((do shell script "perl -e 'print time();'") as integer) - h) / 60 / 60 / 24 < daysold then
duplicate this_ to myplaylist
end if
on error msg
display dialog msg
end try
end if
end repeat
end tell
end if
end tell