iTunes: Podcast-Liste als opml exportieren

9/03/2011

Ein weiterer Beweis dafür, dass die Pflege der AppleScript-Funktionen in Apple-Anwendungen keine wirkliche Priorität genießt: Podcasts kann man zwar per Skript aktualisieren, aber deren URL auszulesen ist per Skript nicht möglich... auch ein Export über die Export-Funktion in iTunes ist per Skript ohne weiteres nicht möglich... Die denken sich wahrscheinlich, wenn's wirklich nötig ist, dann halt via GUI-Scripting. So sei es. Dieses Skript exportiert eine Liste der abonnierten Podcasts als *.opml
und wie bei allen GUI-Scripting-Geschichten, funktioniert es nur, wenn der Zugriff für Hilfsgeräte unter Systemeinstellungen/Bedienungshilfe aktiviert ist.

tell application "iTunes"

try

set myplaylist to first item of (every playlist whose special kind is Podcasts)

reveal myplaylist

my clickExportPlaylist()

delay 1

set playlistname to my SaveAsOPML()

do shell script "open -a /Applications/TextEdit.app ~/Desktop/" & playlistname

say "GUI Scripting sucks" using "Agnes"

say "It sucks but it works, Agnes" using "Alex"

say "Bla Bla, Alex" using "Agnes"

on error msg

error msg -- "There is no Podcast Playlist"

end try

end tell


on clickExportPlaylist()

activate application "iTunes"

tell application "System Events"

tell process "iTunes"

-- clicks export Playlist (iTunes 10.1.2)

click menu item 6 of menu 1 of menu item 9 of menu 1 of menu bar item 3 of menu bar 1

end tell

end tell

end clickExportPlaylist


on SaveAsOPML()

activate application "iTunes"

tell application "System Events"

tell process "iTunes"

-- clicks Playlist (iTunes 10.1.2)

click pop up button 1 of group 1 of window 1

delay 1

keystroke "O"

delay 0.25

keystroke return

delay 0.25

--switch to desktop folder

keystroke "d" using command down

--this should be a uniq name for this file

set uniqname to (do shell script "date | md5") & ".opml"

--be sure to overwrite all characters...

keystroke "a" using command down

keystroke uniqname

delay 1

-- hit save

keystroke return

-- wait until save dialog closed

repeat until name of window 1 = "iTunes"

delay 0.5

end repeat

return uniqname

end tell

end tell

end SaveAsOPML

No Comments

iTunes: Spiele ausgewählte Titel

1/03/2011
Die Skripte spielen eine Auswahl von Titel und stoppen danach die Wiedergabe... Die erste Lösung kommt ohne das Erstellen eine extra Wiedergabeliste aus, muss dafür aber für den Zeitraum der Wiedergabe laufen (deshalb am besten als Anwendung abspeichern und nicht direkt aus iTunes starten, sonst bleibt iTunes blockiert).

tell application "iTunes"

set mysongs to every track whose name contains "angel"

display dialog "now playing " & (count of mysongs) & " songs." giving up after 1

repeat with i from 1 to count of mysongs

set mysong to item i of mysongs

play mysong

##give iTunes a sec to realize current track

delay 1

repeat until mysongcurrent track

#delay otherwhise cpu load is very high!!!

delay 0.25

end repeat

stop

end repeat

end tell

2. Lösung mit Playlist:

tell application "iTunes"

set mysongs to every track whose name contains "ever"

-- display dialog "now playing " & (count of mysongs) & " songs." giving up after 1

set playlistname to "PLAY_THIS"

try

get playlist playlistname of source 1

on error

tell source 1

make new playlist with properties {name:playlistname}

end tell

end try

tell playlist playlistname of source 1

delete every track

set shuffle to false

set song repeat to off

end tell

repeat with i from 1 to count of mysongs

set mysong to item i of mysongs

set playlistsongs to {}

try

#try because of error on empty list

set playlistsongs to database ID of every track of playlist playlistname of source 1

end try

if (database ID of mysong) is not in playlistsongs then

copy mysong to playlist playlistname of source 1

end if

end repeat

tell playlist playlistname of source 1 to play

end tell

No Comments

Air-Tunes Speaker via Apple Skript switchen II

10/09/2010
Die ursprüngliche Version konnte mit iTunes 8 und 9 noch funktionieren... mit iTunes 10 hat sich das GUI wieder etwas geändert. Fall-Line hatte sich der Aktualisierung bereits angenommen, diese Version sollte aber unter jeder System-Sprache funktionieren. Zudem hat das Skript noch ein kleines Update erfahren. Man kann eine Konfiguration vorgeben oder ohne Vorgabe die aktuelle Einstellung in iTunes einfach nur switchen...
Code zum markieren einmal anklicken Code im Skript-Editor öffnen

--Airtunes-Switch-Config-Script

(**hubionmac.com 10.09.2010

for addition info: http://hubionmac.com/wordpress/?p=2303

orig. Version by http://fall-line.com/2010/09/control-airplayairtunes-feature-of-itunes-with-applescript/

if check_these und uncheck_these = {} then your

Airtunes-Config will be switched the other way around....


Makes use of GUI-Skripting, hopefully Apple will add native AppleScript-Support in iTunes for

Airtunes some day 


**)


set check_these to {} --something like {"Name of Your Air-TunesDevice"}

set uncheck_these to {} --something like {"Computer"}


my check_gui_scripting_is_active()

my check_if_iTunes_window_visible()

my press_speaker_button_and_open_all_speakers()

my check_boxes_and_close_window(check_these, uncheck_these)


on press_speaker_button_and_open_all_speakers()

tell application "iTunes"

activate

tell application "System Events"

tell application process "iTunes"

click button 8 of window "iTunes" --Press the iTunes 10 Speaker Button

key code 125 using {command down} -- this is essentiall hitting page down (command + down arrow)

delay 1

keystroke return

delay 1

end tell

end tell

end tell

end press_speaker_button_and_open_all_speakers


on check_boxes_and_close_window(check_these, uncheck_these)

--if check_these und uncheck_these = {} then your

--Airtunes-Config will be switched the other way around....

tell application "iTunes"

activate

tell application "System Events"

tell application process "iTunes"

tell window 1

tell table 1 of scroll area 1

set check_computer_allowed to false

repeat with i from (count of every row) to 1 by -1 -- Itterate through each row, looking for the criteria below

set rowcount to count of rows

set a to rowcount

if rowcount > 0 then

tell group 1 of row i

activate -- Drill into the object group of each row, so we don't have to later.

-- If "Speaker in Room A" is turned off (value of checkbox 1 = 0), turn it on. Otherwise do nothing

if check_these is {} and uncheck_these = {} then

if i > 1 and value of checkbox 1 as integer = 0 then

set check_computer_allowed to true

end if

if i > 1 then

click checkbox 1

else

if check_computer_allowed is true then

click checkbox 1

end if

end if

else

if (description of checkbox 1) is in check_these and value of checkbox 1 as integer = 0 then

click checkbox 1

end if

if (description of checkbox 1) is in uncheck_these and value of checkbox 1 as integer = 1 then

click checkbox 1

set a to (description of checkbox 1)

end if

end if

end tell

end if

end repeat

end tell

end tell

end tell

end tell

close window 1

end tell

end check_boxes_and_close_window


on check_if_iTunes_window_visible()

tell application "iTunes"

activate

tell application "System Events"

tell application process "iTunes"

--check if itunes Window is frontmost

if (count of every window) = 0 or (name of window 1 ≠ "iTunes") then

keystroke "1" using {command down, option down}

end if

end tell

end tell

end tell

end check_if_iTunes_window_visible



to check_gui_scripting_is_active()

tell application "System Events" to set isUIScriptingEnabled to UI elements enabled

if isUIScriptingEnabled = false then

tell application "System Preferences"

activate

set current pane to pane "com.apple.preference.universalaccess"

display dialog "Your system is not properly configured to run this script.

         Please select the \"Enable access for assistive devices\"

         checkbox and trigger the script again to proceed."

return

end tell

end if

end check_gui_scripting_is_active

15 Comments

Erweiterte iTunes Info (Über iTunes)

27/08/2010
Wenn man in iTunes den Menüpunkt "Über iTunes" mit gedrückt ctrl-Taste aufruft werden in dem Informationsfenster einige Infos über Treiber-Versionen und die Seriennummern und IMEI-Nummern von gekoppelten Geräten angezeigt... recht praktisch, wenn man mal schnell die Seriennummer von seinem iPod braucht =) Scrollt einem die Liste zu schnell kann man mit der alt-Taste die Laufrichtung umkehren... und mit der Leertaste ganz anhalten (merci für den Tip Tomthecat).
1 Comment

Stop iTunes after x Minutes.app

13/12/2009
itunes stop iconIch schlafe gerne mit Musik ein und dafür habe ich mir mal diese Anwendung geschrieben. Ist ein simples Skript, das wahrscheinlich auch Einzug in die iTunes-Skript-Sammlung erhalten wird. Dies aber schon vorab.
Alles was man machen muss, ist das Skript starten, angeben, wie lange die Musik noch laufen muss... Nun, es erklärt sich wirklich von alleine =)
DOWNLOAD
iTunes Auto Stop v.1.0
(420 hits)
Ach so, und Leopard-kompatibel ist es sogar auch schon ;-)
1 Comment

Hubi’s iTunes Scripts

13/12/2009
Das war eigentlich das erste Stück Software, das ich selber wirklich entwickelt habe. Ist auch heute noch ein treuer Helfer. Wenn Du also Deine iTunes Stücke sortieren möchtest, ID-Tags bereinigen oder neu organisieren möchtest. Dann können diese Scripte viel Zeit sparen =)
DOWNLOAD
Hubi's iTunes Skripts v.1.9
(3500 hits)
9 Comments

iTunes: Download Order mit iTunes abgleichen (mit playlists)

10/10/2009
Das ging eigentlich schon etwas früher mit meinen iTunes-Scripts (04-scan folder and add to iTunes Lib), hinzugekommen ist aber das Anlegen der einzelnen Playlisten.
Ist recht praktisch, um einen Überblick über alle Medien-Datein zu bekommen, die so in den Downloads dümpeln... Coole Idee von Rounak
Code zum markieren einmal anklicken Code im Skript-Editor öffnen

-- hubionmac.com 10.10.2009

-- scans download folder for folders containing media data iTunes can play

-- creates a corresponding playlist within itunes

property special_bigChars : {"Ä", "Å", "Ç", "É", "Ñ", "Ö", "Ü", "À", "Ã", "Õ", "Ÿ", "Â", "Ê", "Á", "Ë", "È", "Í", "Î", "Ï", "Ì", "Ó", "Ô", "Ò", "Ú", "Û", "Ù"}

property special_smallChars : {"ä", "å", "ç", "é", "ñ", "ö", "ü", "à", "ã", "õ", "ÿ", "â", "ê", "á", "ë", "è", "í", "î", "ï", "ì", "ó", "ô", "ò", "ú", "û", "ù"}

property action_list02 : {"01-Abcd Efg", "02-Abcd efg", "03-ABCD EFG", "04-abcd efg"}


global folder2Scan, actionid



tell application "Finder"

set actionid to (my get_selection_index(action_list02, "Format of Playlist_names (cancel for no changes)", false))

set folder2Scan to folder "Downloads" of home

set thefolders to every container of folder2Scan

set thefiles to every file of folder2Scan

--get my download folder

set thefolders_list to my makeDownloadPlaylist()

--clean the folderlist from old playlist // option dialog would be nice

my clean_iTunes_folder(thefolders_list)

-- make a folder playlist called itunes or get reference to it

tell application "iTunes"

set files_in_folder2Scan to my check_playlist(thefolders_list, "•SINGLE FILES•")

repeat with thefile in thefiles

if name of thefile does not end with ".pdf" then

add (thefile as alias) to files_in_folder2Scan

end if

end repeat

if (count of every track of files_in_folder2Scan) = 0 then

delete files_in_folder2Scan

else

--clean the playlist from duplicates

my cleanPlaylist(files_in_folder2Scan)

end if

repeat with thefolder in thefolders

set foldername to my do_string(actionid, my replace_chars((name of thefolder), "_", " "))

--now the script loops through every folder, creates a corrensponding playlist

-- if there created playlist is empty after all, it will be removed again =)

set current_playlist to my check_playlist(thefolders_list, foldername)

add (thefolder as alias) to current_playlist

if (count of every track of current_playlist) = 0 then

delete current_playlist

else

--clean the playlist from duplicates

my cleanPlaylist(current_playlist)

end if

end repeat

end tell

end tell


display dialog "done...

***commerical***

created by hubionmac.com :-P

***commerical***"



on check_playlist(folderplaylist, playlistname2check)

tell application "iTunes"

set thelists to every user playlist of source 1 whose special kind is none and smart is false

set fpl_lists to {}

repeat with i in thelists

try

if parent of i = folderplaylist then

set fpl_lists to fpl_lists & {i}

end if

end try

end repeat

repeat with i in fpl_lists

if (name of i) as text = playlistname2check then

return i

end if

end repeat

make new playlist with properties {name:playlistname2check} at folderplaylist

end tell

end check_playlist


on makeDownloadPlaylist()

tell application "iTunes"

-- set thelists to name of every user playlist of source 1 whose special kind is none and smart is false

if (count of every folder playlist) = 0 or (name of every folder playlist) does not contain "Downloads" then

tell source 1 to make new folder playlist with properties {name:"Downloads"}

set fpl to folder playlist "Downloads" of source 1

else

set fpl to folder playlist "Downloads" of source 1

end if

return fpl

end tell

end makeDownloadPlaylist


on cleanPlaylist(theplaylist)

tell application "iTunes"

set idlist to {}

repeat with i from the (count of tracks) of theplaylist to 1 by -1

set currentID to database ID of track i of theplaylist

if currentID is in the idlist then

delete track i of theplaylist

else

if ((location of track i of theplaylist) as text) starts with folder2Scan then

set idlist to idlist & {currentID}

else

delete track i of theplaylist

end if

end if

end repeat

end tell

end cleanPlaylist



on replace_chars(this_text, search_string, replacement_string)

if this_text contains the search_string then

set AppleScript's text item delimiters to the search_string

set the item_list to every text item of this_text

set AppleScript's text item delimiters to the replacement_string

set this_text to the item_list as string

set AppleScript's text item delimiters to ""

end if

return do_string(actionid, this_text)

end replace_chars




on do_string(actionid, the_string)

if actionid = {} then

return the_string

else

set actionid to actionid as integer

set finalstring to ""

if actionid = 1 then

repeat with i from 1 to count of characters of the_string

set test_char to character i of the_string

if i = 1 then

set finalstring to makebig(test_char)

else

set prev_char to character (i - 1) of the_string --last character of finalstring as text

if followed_by_bigchar(prev_char) = true then

set finalstring to finalstring & makebig(test_char)

else

set finalstring to finalstring & makesmall(test_char)

end if

end if

end repeat

else if actionid = 2 then

set firstchar to makebig(character 1 of the_string)

repeat with i from 2 to count of characters of the_string

set test_char to character i of the_string

set finalstring to finalstring & makesmall(test_char)

end repeat

set finalstring to (firstchar & finalstring) as text

else if actionid = 3 then

repeat with i from 1 to count of characters of the_string

set test_char to character i of the_string

set finalstring to finalstring & makebig(test_char)

end repeat

else if actionid = 4 then

repeat with i from 1 to count of characters of the_string

set test_char to character i of the_string

set finalstring to finalstring & makesmall(test_char)

end repeat

end if

return finalstring

end if

end do_string




on followed_by_bigchar(test_char)

if ((ASCII number of test_char) is greater than 64) and ¬

((ASCII number of test_char) is less than 91) then

return false

else if ((ASCII number of test_char) is greater than 96) and ¬

((ASCII number of test_char) is less than 123) then

return false

else if special_bigChars contains test_char then

return false

else if test_char = "'" then

return false

else

return true

end if

end followed_by_bigchar



on makesmall(test_char)

--when it's a normal character

if ((ASCII number of test_char) is greater than 64) and ¬

((ASCII number of test_char) is less than 91) then

return (ASCII character ((ASCII number of test_char) + 32))

--when it's a special character

else if test_char is in special_bigChars then

repeat with i from 1 to count of special_bigChars

if item i of special_bigChars = test_char then

return item i of special_smallChars

end if

end repeat

--when it's something else

else

return test_char

end if

end makesmall


on makebig(test_char)

--when it's a normal character

if ((ASCII number of test_char) is greater than 96) and ¬

((ASCII number of test_char) is less than 123) then

return (ASCII character ((ASCII number of test_char) - 32))

--when it's a special character

else if test_char is in special_smallChars then

repeat with i from 1 to count of special_bigChars

if item i of special_smallChars = test_char then

return item i of special_bigChars

end if

end repeat

--when it's something else

else

return test_char

end if

end makebig


on get_selection_index(action_list, theprompt, mult_selection)

set theselection to choose from list action_list multiple selections allowed mult_selection with prompt theprompt

set returnlist to {}

repeat with theselected in theselection

set i to 1

repeat with theaction in action_list

if theselected as text = theaction as text then

set returnlist to returnlist & i as list

end if

set i to i + 1

end repeat

end repeat

return returnlist

end get_selection_index


on clean_iTunes_folder(folder_playlist_2_clean)

tell application "iTunes"

set thelists to every user playlist of source 1 whose special kind is none and smart is false

repeat with i in thelists

try

if parent of i = folder_playlist_2_clean then

delete i

end if

end try

end repeat

end tell

end clean_iTunes_folder

2 Comments

Shortcuts: iTunes

9/10/2009
  • iTunes ohne Erweiterungen (abgesicherter Modus) starten: Beim Start:alt + cmditunes safe boot
  • Neue Mediathek oder andere Mediathek: Beim Start:alt andere mediathek
  • Andere Firmware auf iPod aufspielen: Beim Drücken auf Wiederherstellen:alt bzw. unter Windows alt
No Comments

Mp3s über den Kommentar schnell taggen

7/05/2009

Musik kommentieren (Chillout, party, happy, instrumental etc.) macht die Suche nach den passenden Lieder leichter. Nur das Kommentieren ist auch in iTunes nicht gerade auf die Schnelle möglich. Dafür habe ich mir dieses kleine Apple-Script-Programm geschrieben, mit dem man die Kommantare schnell und ganz ohne Maus setzen kann. Die Kommentare werden dabei Wort für Wort alphabetisch sortiert...

Hier also das Programm:

Download iTunes Comment Tagger Version 1.0a

und das X-Code Projekt:

Download iTunes Comment Tagger - XCode Version 1.0a
No Comments

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

7/02/2009

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

No Comments