iTunes:AppleScript ->Playlist von kürzlich bewerteten Titeln erstellen

Die 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 ;-P

Mit diesem Skript setzt man die Bewertungen:

Code zum markieren einmal anklicken

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

Code zum markieren einmal anklicken

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

This entry was posted in iTunes and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CAPTCHA:


+ 2 = seven

Subscribe without commenting

  • Seite übersetzen:


    Paypal for Pizza:




  • Kategorien


  • Letzte Kommentare

    • Niklas: Vielen Vielen Dank! So klappt es!
    • hubi: Servus Niklas, ich habe mir den Quellcode noch einmal angesehen und habe nun unter 10.7.3 einen Weg gefunden...
    • Niklas: Klingt super das Script. Leider bekomm ich immer folgende Fehlermeldung: error “„Mail“ hat einen Fehler...
    • Jürgen: Hallo Hubi, beim Abfragen von Kennworten gibt es noch eine böse Falle: Das Format, in dem security antwortet,...
    • hubi: Am einfachsten Du öffnest im AppleScript-Editor mal das Funktionsverzeichnis (unter Ablage) von iTunes. Ein...