iTunes Albenlose Songs Sammeln

X

xxxxx6

Neues Mitglied
Thread Starter
Dabei seit
11.08.2014
Beiträge
7
Reaktionspunkte
0
Hallo, Ich benötige etwas Hilfe beim erstellen eines Apple iTunes Scripts. Funktion soll folgende sein: Das Script soll meine Musik durchsuchen nach allen Alben die weniger oder gleichX (z.B. 2) Songs haben. die Songs aus diesen Alben soll es dann in eine Playlist packen. Bei erneutem ausführen soll die Playlist aktualliesiert/ersetzt werden.
Sinn/Zweck: Mich nervt es wenn ich nach Alben suche immer zu sehen wie viele einzelne Songs ich dazwischen habe von denen ich garkein Album besitze. Daher möchte ich die Playlist zu einer Complilation zusammenfassen da dies als einzelnes Album angezeigt wird.
Ich danke vielmals!! Hier ist mein nicht funktionierender Versuch den ich aus vorhandenen Scripts versucht haben zu modifizieren:

tell application "iTunes"
-- The number of tracks
set songsPerAlbum to 2
if not (exists playlist "SingleSongs") then make new playlist with properties {name:"SingleSongs"}

-- Get list of albums, the fast way...
set albumsWithDups to (album of every track)
set albumsNames to my removeDuplicates(albumsWithDups)

-- Check each album
repeat with currentAlbum in albumsNames
set albumSongs to (every track of library playlist 1 whose album is currentAlbum)

-- Check track count
if (count of albumSongs) is less than songsPerAlbum then
duplicate (every track of albumSongs whose (count of albumSongs) is less than songsPerAlbum) to playlist "SingleSongs"
end if
end repeat
end tell

on removeDuplicates(lst)
-- from <a href="http://applescript.bratis-lover.net/library/list/#removeDuplicates">http://applescript.bratis-lover.net/library/list/#removeDuplicates</a>
local lst, itemRef, res, itm
try
if lst's class is not list then error "not a list." number -1704
script k
property l : lst
property res : {}
end script
repeat with itemRef in k's l
set itm to itemRef's contents
-- note: minor speed optimisation when removing duplicates
-- from ordered lists: assemble new list in reverse so
-- 'contains' operator checks most recent item first
if k's res does not contain {itm} then ¬
set k's res's beginning to itm
end repeat
return k's res's reverse
on error eMsg number eNum
error "Can't removeDuplicates: " & eMsg number eNum
end try
end removeDuplicates
 
Das ganze Gedöse mit dem removeDuplicates-Handler würde ich mir ehrlich gesagt sparen, und stattdessen ASObjC-Runner herunterladen und nutzen:

Code:
[B]property [/B][COLOR=#4F8F00][FONT=Verdana]songsPerAlbum[/FONT][/COLOR][FONT=Verdana] : 2
[/FONT][FONT=Verdana][B]property[/B] [COLOR=#4f8f00]playlistName[/COLOR] : "SingleSongs"[/FONT]
[FONT=Verdana][B]tell[/B] [COLOR=#0433ff][I]application[/I][/COLOR] "iTunes"[/FONT]
[FONT=Verdana]    [B]if[/B] [B]not[/B] ([COLOR=#0433ff][B]exists[/B][/COLOR] [COLOR=#0433ff][I]playlist [/I][/COLOR][/FONT][COLOR=#4F8F00][FONT=Verdana]playlistName[/FONT][/COLOR][FONT=Verdana]) [B]then[/B][/FONT]
[COLOR=#0433FF][FONT=Verdana][COLOR=#000000]        [B]set[/B] [/COLOR][COLOR=#4f8f00]thePlaylist[/COLOR][COLOR=#000000] [B]to[/B] [/COLOR][B]make [/B]new [I]playlist [/I]with properties[COLOR=#000000] {[/COLOR][COLOR=#812fdc]name[/COLOR][COLOR=#000000]:[/COLOR][COLOR=#4f8f00]playlistName[/COLOR][COLOR=#000000]}[/COLOR][/FONT][/COLOR]
[FONT=Verdana]    [B]else[/B][/FONT]
[COLOR=#4F8F00][FONT=Verdana][COLOR=#000000]        [B]set[/B] [/COLOR]thePlaylist[COLOR=#000000] [B]to[/B] [/COLOR][COLOR=#0433ff][I]playlist [/I][/COLOR]playlistName[/FONT][/COLOR]
[COLOR=#0433FF][FONT=Verdana]        [B]delete [/B][I]tracks[/I][COLOR=#000000] [B]of[/B] [/COLOR][COLOR=#4f8f00]thePlaylist[/COLOR][/FONT][/COLOR]
[FONT=Verdana]    [B]end[/B] [B]if[/B][/FONT]
[FONT=Verdana]    [B]set[/B] [COLOR=#4f8f00]albumNames[/COLOR] [B]to [/B][/FONT][FONT=Verdana]([/FONT][B]every [/B][COLOR=#0433FF][FONT=Verdana][I]track [/I][/FONT][/COLOR][B]whose [/B][COLOR=#812FDC][FONT=Verdana]kind [/FONT][/COLOR][B]contains[/B][FONT=Verdana] "audio")[/FONT][COLOR=#000000][FONT=Verdana]'s [/FONT][/COLOR][COLOR=#812FDC][FONT=Verdana]album[/FONT][/COLOR][FONT=Verdana]
[/FONT]
[FONT=Verdana]    [B]tell[/B] [COLOR=#0433ff][I]application[/I][/COLOR] "ASObjC Runner" [B]to[/B] [B]set[/B] [COLOR=#4f8f00]uniqueAlbumNames[/COLOR] [B]to[/B] [COLOR=#0433ff][B]rearrange list[/B][/COLOR] [COLOR=#4f8f00]albumNames[/COLOR] [B]with[/B] [COLOR=#0433ff]unique[/COLOR][/FONT]

[COLOR=#4F8F00][FONT=Verdana][COLOR=#000000]    [B]repeat[/B] [B]with[/B] [/COLOR]theAlbum[COLOR=#000000] [B]in[/B] [/COLOR]uniqueAlbumNames[/FONT][/COLOR]
[FONT=Verdana]        [B]tell[/B] ([B]every[/B] [COLOR=#0433ff][I]track[/I][/COLOR] [B]of[/B] [COLOR=#0433ff][I]library playlist[/I][/COLOR] 1 [B]whose[/B] [COLOR=#812fdc]album[/COLOR] [B]is[/B] [COLOR=#4f8f00]theAlbum[/COLOR]) [B]to[/B] [B]if[/B] ([COLOR=#0433ff][B]count[/B][/COLOR] [B]of[/B] [B]it[/B]) < [COLOR=#4f8f00]songsPerAlbum[/COLOR] [B]then[/B] [COLOR=#0433ff][B]duplicate[/B][/COLOR] [B]it[/B] [COLOR=#0433ff]to[/COLOR] [COLOR=#4f8f00]thePlaylist[/COLOR][/FONT]

[FONT=Verdana]    [B]end[/B] [B]repeat[/B][/FONT]
[B]end [/B][B]tell[/B]


Allerdings bin ich ehrlich gesagt hingegangen, und habe mir ein [complete album]-Etikett in das Kommentarfeld jedes Komplettalbums gesetzt, das es mir dann erlaubt eine Intelligente Wiedergabeliste mit entsprechendem Kriterium zu erstellen.
 
bzw. genau das Gleiche, aber noch kompakter falls Du OS X ≥ 10.9 benutzt:

Code:
[FONT=Verdana][B]property[/B] [COLOR=#4f8f00]songsPerAlbum[/COLOR] : 2[/FONT]
[FONT=Verdana][B]property[/B] [COLOR=#4f8f00]playlistName[/COLOR] : "SingleSongs"
[/FONT][B]use [/B][COLOR=#4F8F00][FONT=Verdana]iTunes[/FONT][/COLOR][FONT=Verdana] : [/FONT][COLOR=#0433FF][FONT=Verdana][I]application[/I][/FONT][/COLOR][FONT=Verdana] "iTunes"
[/FONT][FONT=Verdana][B]use[/B] [COLOR=#0433ff][I]application[/I][/COLOR] "ASObjC Runner"[/FONT][FONT=Verdana]
[/FONT]
[COLOR=#0433FF][FONT=Verdana][COLOR=#000000][B]if[/B] [B]not[/B] ([/COLOR][B]exists [/B][COLOR=#012fbe][I]playlist [/I][/COLOR][COLOR=#4f8f00]playlistName[/COLOR][COLOR=#000000]) [B]then[/B] [/COLOR][B]make [/B]new [COLOR=#012fbe][I]playlist [/I][/COLOR]with properties[COLOR=#000000] {[/COLOR][COLOR=#812fdc]name[/COLOR][COLOR=#000000]:[/COLOR][COLOR=#4f8f00]playlistName[/COLOR][COLOR=#000000]}[/COLOR][/FONT][/COLOR]
[COLOR=#4F8F00][FONT=Verdana][COLOR=#000000][B]set[/B] [/COLOR]thePlaylist[COLOR=#000000] [B]to[/B] [/COLOR][COLOR=#012fbe][I]playlist [/I][/COLOR]playlistName[/FONT][/COLOR]
[COLOR=#4F8F00][FONT=Verdana][COLOR=#0433ff][B]delete [/B][/COLOR][COLOR=#012fbe][I]tracks[/I][/COLOR][COLOR=#000000] [B]of[/B] [/COLOR]thePlaylist[/FONT][/COLOR]
[FONT=Verdana][B]using terms from[/B] [COLOR=#0433ff][I]application[/I][/COLOR] "iTunes"[/FONT]
[FONT=Verdana]    [B]repeat[/B] [B]with[/B] [COLOR=#4f8f00]theAlbum[/COLOR] [B]in[/B] ([COLOR=#012fbe][B]rearrange list[/B][/COLOR] ([B]get[/B] [COLOR=#812fdc]album[/COLOR] [B]of[/B] ([B]every[/B] [COLOR=#0433ff][I]track[/I][/COLOR] [B]of[/B] [COLOR=#4f8f00]iTunes[/COLOR]) [B]whose[/B] [COLOR=#812fdc]kind[/COLOR] [B]contains[/B] "audio") [B]with[/B] [COLOR=#012fbe]unique[/COLOR])[/FONT]
[FONT=Verdana]        [B]tell[/B] ([B]every[/B] [COLOR=#0433ff][I]track[/I][/COLOR] [B]of[/B] [COLOR=#4f8f00]iTunes's[/COLOR] [COLOR=#0433ff][I]library playlist[/I][/COLOR] 1 [B]whose[/B] [COLOR=#812fdc]album[/COLOR] [B]is[/B] [COLOR=#4f8f00]theAlbum[/COLOR]) [B]to[/B] [B]if[/B] ([COLOR=#0433ff][B]count[/B][/COLOR] [B]of[/B] [B]it[/B]) < [COLOR=#4f8f00]songsPerAlbum[/COLOR] [B]then[/B] [COLOR=#0433ff][B]duplicate[/B][/COLOR] [B]it[/B] [COLOR=#0433ff]to[/COLOR] [COLOR=#4f8f00]thePlaylist[/COLOR][/FONT]
[FONT=Verdana]    [B]end[/B] [B]repeat[/B][/FONT]
[B]end [/B][B]using terms from[/B]
;)
 
Erst mal bin ich euch sehr dankbar für die Hilfe.

Ich habe mir dieses extra Programmchen installiert und Applescript wollte direkt den Installationsort wissen.
Das Script will aber irgendwie nicht.
Ich kenne mich da sehr wenig aus weshalb ich nochmals nachfragen muss.
Habt ihr das Script in der Praxis geprüft?

http://image-upload.de/image/YiAu0d/e31c43ceb8.png
 
Zuletzt bearbeitet:
Ja. Das Skript kann bereits nicht kompiliert werden, d.h. es kommt gar nicht erst zur Ausführung. Da musst Du im Dialog, als nach dem ASObjC-Runner gefragt wurde, kein oder das falsche Programm ausgewählt haben, bzw. - am wahrscheinlichsten - Du hast den ASObjC-Runner noch gar nicht richtig installiert? Befindet sich der ASObjC-Runner in Deinem Programmeordner? Falls ja, ersetz vielleicht mal
Code:
"ASObjC Runner"
durch
Code:
"/Applications/ASObjC Runner.app"

in dem Skript und/oder versuche erstmal die erste von mir hier gepostete Version des Skripts.
 
Oh okay. Ich wollte das nicht in Programme packen damit ich das nicht im Launchpad hab.
Wusste nicht dass das so sein muss.
Danke dir, es funktioniert :)

Wäre es noch möglich das ganze automatisch als Compilation zusammen zu fügen?
Danach wars das. Ich will dich ja nicht ewig nerven. :)

Edit: Mir ist gerade bewusst geworden dass die ja dann trotzdem alle den selben Album Namen brauchen um zusammen gefügtzu werden... Wie könnte ich das denn umgehen? :(
 
Super - Du nervst überhaupt nicht. :) Das ginge natürlich per AppleScript, aber spricht etwas dagegen, alle Tracks in der Playlist auszuwählen, und dann im Informationsfenster den Haken bei "Compilation" zu setzen?

Zumindest im Spalten-Browser gibt es eine Option, die Compilations zu gruppieren. Weiß nicht, ob Dir das bereits reicht... ich persönlich bin wie gesagt sozusagen den umgekehrten Weg gegangen, indem ich mir alle Komplettalben markiert habe, so dass ich bei sichtbarem Kommentarfeld [complete album] ins Suchfeld eingeben kann, um nur meine Komplettalben zu sehen...
Oder eben eine intelligente Wiedergabeliste mit entsprechender Filterung.
 
also was ich an der ganzen Aktion nicht so recht verstehe, ist, dass Du daraus eine Compilation machen willst...
Dir ist schon klar, dass Du dafür den Album-Namen für alle diese Tracks gleich setzen musst? Ob das wirklich sinnvoll ist? :kopfkratz:
 
Habt eigentlich recht. Nützlich war diese Sortierung mit dem Script trotzdem.
Hab das höchstens 1 Song auf mindestens 3 Songs umgekehrt und hab jetzt quasi alle kompletten Alben durchgetagt mit dem "Complete Album" :)
Ich sehe gerade dass das Script auch meine Filme und Hörbücher mit einbezieht. Kann ich das irgendwie ausgrenzen?
 
Oh ja, bei whose album is theAlbum fehlt eigentlich noch (etwa) der Zusatz and kind contains "audio". Läuft dann allerdings etwas langsam. Alternativ kannst du auch eine intelligente Wiedergabeliste "dieMusik" mit bloß Deiner Musik erstellen, und dann das AppleScript für diese Playlist ausführen.
 
Aah :) Vielen Dank, dass funktioniert gut.
 
Zurück
Oben Unten