Per Tastendruck Titel zu einer Playlist zufügen

fyysh

Schweizer Glockenapfel
Registriert
25.01.10
Beiträge
1.386
Aus purem Spaß hab ich das mal in Apfelskript geschrieben. So unsagbar kompliziert war's nu auch nicht. ;)

Beschreibung:
Das Skript fügt alle ausgewählten Tracks in einer Playlist hinzu, die über eine angezeigte Liste der verfügbaren Playlists ausgewählt wird. Aus der Liste heraus kann man auch eine neue Playlist erstellen.

Wenn nichts ausgewählt ist, versucht das Script den Track zu bekommen, der gerade abgespielt wird und added das zur ausgewählten Playlist hinzu und teilt das mit.

Wenn der Track schon in der Playlist ist, fügt es den Track nicht hinzu, teilt das aber auch mit.

Warnung:
Ich hab das Skript nicht sonderlich hart getestet, also keine Garantie. For me it works. ;)
Ich übernehme keinerlei Haftung, wenn was kaputt geht! :p

"Installation":
Dieses Script herunterladen, entpacken und in den Ordner ~/Library/iTunes/Scripts ablegen ("~" steht für den Home-Ordner)
Anhang anzeigen 61923

Ausführen:
So, schau
Anhang anzeigen 61924


Mit Tastenkombi ausführen:
In den Tastatureinstellungen ein Shortcut für iTunes hinzufügen und den Namen des Scripts ohne .scpt eingeben.
Anhang anzeigen 61925 => Anhang anzeigen 61926


Noch ein bisschen Senf:

Ein Skript, dass das selbe macht, wahrscheinlich sogar besser, müsste es schon irgendwo im Internet geben. Vielleicht bei Doug oder so. Ich hab das jetzt, wie anfangs gesagt, wirklich nur aus Spaß geschrieben und werde es wohl nicht pflegen. ;)


Code:
Code:
--labels
property createNewLabel : "Create new Playlist"
property chooseListPrompt : "Select a Playlist"
property newPlaylistNamePropmt : "Enter the name of the new Playlist"
property addResultMsg : "tracks were added to playlist"
property excludeResultMsg : "tracks were not added."

--lists
set userLibs to {}
set selectedTracks to {}

--others
set targetPlaylist to false
set addCount to 0
set resultMsg to ""

tell application "iTunes"
    
    --get the names of the playlists
    set userLibs to name of every user playlist whose smart is false and special kind is none
    --get selected songs
    set selectedTracks to selection
    
    --if nothing is selected, choose set the current track as selection, else exit
    if selectedTracks = {} then
        try
            set selectedTracks to {current track} --this causes an error if nothing is playing
        on error
            return -1728 --exit
        end try
    end if
    
    repeat
        --ask for the playlist to add the selection to
        set targetPlaylistName to (choose from list userLibs & createNewLabel ¬
            with prompt chooseListPrompt ¬
            default items {(item 1 of userLibs)})
        
        if targetPlaylistName = false then --if canceled exit
            return -128 --exit
        else if (targetPlaylistName as string) = (createNewLabel as string) then --if selection shall be added to new
            set targetPlaylistName to text returned of (display dialog newPlaylistNamePropmt ¬
                default answer ((current date) as string))
            exit repeat
        else if not (targetPlaylistName as string) = "" then --if chosen item is not the separator, exit
            exit repeat
        end if
    end repeat
    
    set targetPlaylistName to targetPlaylistName as string
    
    --check if the target playlist exists, else create it
    if not (exists playlist targetPlaylistName) then
        try
            make new user playlist with properties {name:targetPlaylistName}
        on error
            display dialog "Cannot create playlist " & return & targetPlaylistName & return & ¬
                "dude!" buttons {"Pity!"} ¬
                default button 1 ¬
                with icon 0
            return 1 --exit
        end try
    end if
    
    
    repeat with aTrack in selectedTracks
        --check if the song is already in the playlist, else add it
        set trackPID to persistent ID of aTrack
        if not (exists (some track of playlist targetPlaylistName whose persistent ID is trackPID)) then
            duplicate aTrack to playlist targetPlaylistName
            set addCount to addCount + 1
        end if
    end repeat
    
    
    --create result msg
    set resultMsg to (addCount & "/" & (count of selectedTracks) & return & addResultMsg & return & targetPlaylistName) as string
    
    if (count of selectedTracks) - addCount > 0 then ¬
        set resultMsg to (resultMsg & return & return & (count of selectedTracks) - addCount & " " & excludeResultMsg) as string
    
    display dialog resultMsg buttons {"Nice!"} default button 1 giving up after 20
    
end tell
 

Anhänge

  • AddToPlaylist.scpt.zip
    7,3 KB · Aufrufe: 64
  • 2209_2010-04-30_2208.png
    2209_2010-04-30_2208.png
    134 KB · Aufrufe: 99
  • 2211_2010-04-30_2210.png
    2211_2010-04-30_2210.png
    136,7 KB · Aufrufe: 101
  • 2214_2010-04-30_2214.png
    2214_2010-04-30_2214.png
    21,8 KB · Aufrufe: 127

MacAlzenau

Golden Noble
Registriert
26.12.05
Beiträge
22.478
Die Links zu den Anhängen (oben im Text) funktionieren nicht. Braucht man die, oder sind es die gleichen, die unten als Grafik stehen?