Push-Nachrichten von MacTechNews.de
Würden Sie gerne aktuelle Nachrichten aus der Apple-Welt direkt über Push-Nachrichten erhalten?
Forum>Software>itunes: playlist mit kompletten Alben per Zufall, Apple-Script?

itunes: playlist mit kompletten Alben per Zufall, Apple-Script?

geroq
geroq14.03.0711:27
Hallo

ich suche ein script dass mir folgendes ermöglicht: erstellen einer Playlist mit einer Anzahl (möglichst einstellbar) Alben die per Zufall gewählt werden, aber alle vollständig in die Playlist übernommen werden.
Ich habe ein script gefunden, dass sowas für ein Album machen soll dabei aber folgende für mich als Apple-Script-Nicht-Kenner kryptische Fehlermeldung ausgibt.

Für die Wissenden hier das script ... könnte man das hinkriegen??

tell application "iTunes"

if visuals enabled is false then
set show_dialog to true
else
set show_dialog to false
end if

-- check for exisitng random album playlist and handle as required

if show_dialog then
tell application "Play Random Album"
display dialog "Preparing playlist" buttons {"KLF"} default button 1 giving up after 2
end tell
end if

my makeRandom()

set new_playlist to playlist "Random Album"

-- go to work on the library

if show_dialog then
tell application "Play Random Album"
display dialog "Picking album" buttons {"KLF"} default button 1 giving up after 2
end tell
end if

tell source "library"

tell playlist "library"

-- initialise lists

set total_album_tracks to {}

-- select a track at random and get its album

set play_album to album of some track

end tell
end tell

-- add each track to working playlist whose album matches choosen album

tell source "library"

tell playlist "library"

if show_dialog then
tell application "Play Random Album"
display dialog "Gathering tracks" buttons {"KLF"} default button 1 giving up after 2
end tell
end if

set total_album_tracks to tracks whose album is play_album

repeat with n from 1 to length of total_album_tracks

repeat with a_track in total_album_tracks
if track number of a_track is n then
duplicate a_track to new_playlist
end if
end repeat

-- start playing after addition of first song

if n = 1 then
tell application "iTunes"
delay 1
play new_playlist
end tell
end if

end repeat
end tell
end tell


-- let user know we have completed

if show_dialog then
tell application "Play Random Album"
display dialog "Finished..enjoy the tunes" buttons {"KLF"} default button 1 giving up after 2
end tell
end if

-- bring itunes to front

activate

end tell

-- subroutine to process random album playlist courtesy of dave saunders

on makeRandom()
tell application "iTunes"
set theLists to name of every playlist
if theLists contains "Random Album" then
delete every track of playlist "Random Album"
else
make new playlist with properties {name:"Random Album", shuffle:false}
end if
end tell
end makeRandom

0

Kommentare

Michael Schmidt
Michael Schmidt14.03.0712:03
Ich nutze zwar eigentlich ungern fremden Code, weil man sich irgendwie ins gemachte Nest setzt, aber naja (policeman)

tell application "iTunes"

-- iTunes Vorbereiten, Playlist "Random Album" kreieren bzw. leeren
my makeRandom()

-- Parameter setzen
set new_playlist to playlist "Random Album"
set notPlaying to true
set usedAlbums to {}

-- Abfragen, wieviele Alben gesammelt werden sollen
set albumCount to (text returned of (display dialog "Wieviele Alben sollen ausgewählt werden?" default answer "1" buttons {"Los"} giving up after 3 default button 1))

try
set albumCount to albumCount as integer
on error
set albumCount to 1
end try

repeat albumCount times
set total_album_tracks to {}
set the_Library to first library playlist of first item of (sources whose kind is library)

-- Irgendein Album holen
set play_album to album of some file track of the_Library

-- Doppelte Alben verhindern
repeat while usedAlbums contains play_album
set play_album to album of some file track of the_Library
end repeat
set end of usedAlbums to play_album

-- Alle Tracks des Albums holen
set total_album_tracks to file tracks of the_Library whose album is play_album

-- Nacheinander die Tracks (in Titelreihenfolge) zur Playlist hinzufügen
repeat with n from 1 to length of total_album_tracks
repeat with a_track in total_album_tracks
if track number of a_track is n then
duplicate a_track to new_playlist
end if
end repeat

-- Wenn die Playlist noch nicht läuft, Playlist starten
if notPlaying then
tell application "iTunes"
delay 1
play new_playlist
end tell
set notPlaying to false
end if

end repeat
end repeat
activate
end tell

on makeRandom()
tell application "iTunes"
set theLists to name of every playlist
if theLists contains "Random Album" then
delete every track of playlist "Random Album"
else
make new playlist with properties {name:"Random Album", shuffle:false}
end if
end tell
end makeRandom


CU
Schmiddl
„Trautman: "Er wird kommen und er wird mich hier rausholen." Russischer Offizier: "Was, glaubt dieser Mann, wer er ist? Gott?" Trautman: "Nein, Gott kennt Gnade!"“
0
geroq
geroq14.03.0712:12
ja wahnsinn!

klappt prima, vielen dank für die schnelle hilfe!!!
0

Kommentieren

Diese Diskussion ist bereits mehr als 3 Monate alt und kann daher nicht mehr kommentiert werden.