• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Was gibt es Schöneres als den Mai draußen in der Natur mit allen Sinnen zu genießen? Lasst uns teilhaben an Euren Erlebnissen und macht mit beim Thema des Monats Da blüht uns was! ---> Klick

Script "Export Playlist as Text"

staettler

Juwel aus Kirchwerder
Registriert
04.06.12
Beiträge
6.580
Hallo,

ich habe ein Script von Doug Adams mit dem ich mir eine Playlist als Text in die Zwischenablage kopieren kann um es dann in einem Textverarbeitungsprogramm einzufügen. Das ist für DJ Sets ein große Hilfe, wenn man die Playlist herausgeben soll.

Allerdings ist mir das Script fast zu mächtig und bietet verschiedene Exportmöglichkeiten, aber nicht genau die, die ich suche. Könnte mir das jemand anpassen, bzw. neu erstellen? Das wäre sehr nett.

Ich hätte gerne folgenden Textexport in die Zwischenablage: Laufende Nummer in der Playlist Interpret - Name

Bsp: 01 Hans Maier - Liedtitel

Code:
--copyleft 2001 John Paul Davis  http://www.johnpauldavis.org
--this module was partially adapted from AppleScripts made available by Apple.
--this specific adaption is covered by the GNU LIMITED GENERAL PUBLIC LICENSE  NO WARRANTY
--Do not remove this notice

# Updated with various modern finesses by Doug Adams, december 21 2011

property summary_options : {"Artist • Album • Song • Time", "Album • Artist • Song • Time", "Song • Artist • Album • Time", "Genre • Artist • Album • Song", "Time • Song • Artist • Album", "Song • Artist", "Song"}
property summary_type : (item 1 of the summary_options)
property delimiter_character : " - "

tell application "iTunes"
    activate
    repeat
        display dialog "Export Playlist as Text" & return & return & ¬
            "This script will copy the contents of the selected playlist in iTunes to the clipboard. (You will need to manually paste the list into your software of choice.)" & ¬
            return & return & ¬
            "If no playlist is selected, please cancel select one." buttons {"Cancel", "Continue"} default button 2
       
        display dialog "Enter text to use a delimiter between the track properties:" default answer delimiter_character
        set this_text to the text returned of the result
        if this_text is not "" then
            set the delimiter_character to this_text
            exit repeat
        end if
    end repeat
   
    --check to see if iTunes has a browser window open
    if the (count of browser windows) is not greater than or equal to 1 then
        error "No browser window is open in iTunes."
    end if
   
    --the playlist currently selected is the one that will be copied
    set this_playlist to the view of browser window 1
    set this_name to (the name of this_playlist) as text
   
    -- let the user choose the order of the information
   
    display dialog "Select the order in which you would like information to be displayed" & return & return & ¬
        "Summary type: " & summary_type buttons {"Cancel", "Set Prefs", "Continue"} default button 3
    if the button returned of the result is "Set prefs" then
        set this_choice to (choose from list summary_options with prompt "Pick the format style:") as text
        if this_choice is "false" then
            -- do nothing
        else
            set the summary_type to this_choice
        end if
    end if
   
   
    if the summary_type is item 1 of the summary_options then
        --loop through each track and retrieve song title, artist, album and time information
        set the playlist_count to the count of tracks of this_playlist
        set playlist_data to {}
        tell this_playlist
            repeat with i from 1 to the count of tracks
                tell track i
                    set the end of the playlist_data to {artist, delimiter_character, album, delimiter_character, name, delimiter_character, time, return}
                end tell
            end repeat
        end tell
    else if the summary_type is item 2 of the summary_options then
        --loop through each track and retrieve song title, artist, album and time information
        set the playlist_count to the count of tracks of this_playlist
        set playlist_data to {}
        tell this_playlist
            repeat with i from 1 to the count of tracks
                tell track i
                    set the end of the playlist_data to {album, delimiter_character, artist, delimiter_character, name, delimiter_character, time, return}
                end tell
            end repeat
        end tell
    else if the summary_type is item 3 of the summary_options then
        --loop through each track and retrieve song title, artist, album and time information
        set the playlist_count to the count of tracks of this_playlist
        set playlist_data to {}
        tell this_playlist
            repeat with i from 1 to the count of tracks
                tell track i
                    set the end of the playlist_data to {name, delimiter_character, artist, delimiter_character, album, delimiter_character, time, return}
                end tell
            end repeat
        end tell
    else if the summary_type is item 4 of the summary_options then
        --loop through each track and retrieve song title, artist, album and time information
        set the playlist_count to the count of tracks of this_playlist
        set playlist_data to {}
        tell this_playlist
            repeat with i from 1 to the count of tracks
                tell track i
                    set the end of the playlist_data to {genre, delimiter_character, album, delimiter_character, artist, delimiter_character, name, return}
                end tell
            end repeat
        end tell
    else if the summary_type is item 5 of the summary_options then
        --loop through each track and retrieve song title, artist, album and time information
        set the playlist_count to the count of tracks of this_playlist
        set playlist_data to {}
        tell this_playlist
            repeat with i from 1 to the count of tracks
                tell track i
                    set the end of the playlist_data to {time, delimiter_character, name, delimiter_character, artist, delimiter_character, album, return}
                end tell
            end repeat
        end tell
    else if the summary_type is item 6 of the summary_options then
        --loop through each track and retrieve song title, artist, album and time information
        set the playlist_count to the count of tracks of this_playlist
        set playlist_data to {}
        tell this_playlist
            repeat with i from 1 to the count of tracks
                tell track i
                    set the end of the playlist_data to {name, delimiter_character, artist, return}
                end tell
            end repeat
        end tell
    else if the summary_type is item 7 of the summary_options then
        --loop through each track and retrieve song title, artist, album and time information
        set the playlist_count to the count of tracks of this_playlist
        set playlist_data to {}
        tell this_playlist
            repeat with i from 1 to the count of tracks
                tell track i
                    set the end of the playlist_data to {name, return}
                end tell
            end repeat
        end tell
    end if
end tell

--open Finder and plop the data in playlist_data as a string into the clipboard
tell application "Finder"
    activate
    try
        display dialog "The playlist information has been copied to the clipboard" buttons {"OK"}
    end try
    set the clipboard to (playlist_data) as text
   
end tell
 

Guy.brush

Weißer Winterkalvill
Registriert
15.12.08
Beiträge
3.545
Versuchs mal so:

Code:
tell application "iTunes"
    activate
  
    --check to see if iTunes has a browser window open
    if the (count of browser windows) is not greater than or equal to 1 then
        error "No browser window is open in iTunes."
    end if
  
    --the playlist currently selected is the one that will be copied
    set this_playlist to the view of browser window 1
  
    --loop through each track and retrieve song title, artist, album and time information
    set the playlist_count to the count of tracks of this_playlist
    set playlist_data to {}
    tell this_playlist
        repeat with i from 1 to the count of tracks
            tell track i
                set the end of the playlist_data to {i, " ", artist, " - ", name, return}
            end tell
        end repeat
    end tell
end tell

--open Finder and plop the data in playlist_data as a string into the clipboard
tell application "Finder"
    activate
    try
        display dialog "The playlist information has been copied to the clipboard" buttons {"OK"}
    end try
    set the clipboard to (playlist_data) as text
  
end tell

PS: Gab es nicht mal einen Editor hier mit Syntax Highlighting? das hier sieht langweilig aus..
 
  • Like
Reaktionen: staettler