iTunes > Wertungen etc. aus Sicherung wiederherstellen

L

little_pixel

Aktives Mitglied
Thread Starter
Dabei seit
06.06.2006
Beiträge
4.706
Reaktionspunkte
1.658
Hallo zusammen,

ich dachte mir, dass ich mal das heute getippselte Skript hier einstelle.
Vor ein paar Wochen hat sich ein Anwender mit der Bitte um Hilfe an mich gewandt.

Seine Mediathek war defekt und er mußte eine Neue anlegen.
Unschön war natürlich, dass alle Wertungen der Titel verloren gegangen sind.
Zum Glück hatte er noch ein altes XML der Mediathek und aus dem lässt sich das problemlos extrahieren.

Das nachfolgenden Skript funktioniert ganz einfach:

- Skript-Editor.app öffnen und hinein kopieren
- Skript starten und im kommenden Auswahldialog zum gewünschten iTunes-Mediathek-XML navigieren
- warten…

Aus dem XML wird für jeden Titel der Name, Interpret und das Album geholt.
Stimmen in iTunes alle drei Werte für einen Titel überein, dann wird die Wertung, Zähler und Anzahl Übersprungen entsprechend der Angabe aus dem XML gesetzt.

Vielleicht hilft es auch mal jemand anderen… :)

Viele Grüße

Code:
--

set filePath to (choose file) as text

if (length of filePath < 1) then
	
	return false
	
end if

--

tell application "System Events"
	
	--
	
	set propertyListFile to property list file filePath
	
	if (propertyListFile is missing value) then
		
		return false
		
	end if
	
	--
	
	set allTrackItems to every property list item of property list item "Tracks" of propertyListFile
	
	if ((count of allTrackItems) < 1) then
		
		return false
		
	end if
	
	--
	
	repeat with nTrackItem in allTrackItems
		
		--
		
		try
			
			my workWithTrackItem(nTrackItem)
			
		on error theErrorMessage number theErrorNumber
			
			-- display alert theErrorNumber message theErrorMessage as critical
			
		end try
		
		--
		
	end repeat
	
	--
	
end tell

--

return true

--

on workWithTrackItem(aTrackItem)
	
	--
	
	if (aTrackItem is missing value) then
		
		return false
		
	end if
	
	--
	
	tell application "System Events"
		
		--
		
		set theName to value of property list item "Name" of aTrackItem
		
		if (length of theName < 1) then
			
			return false
			
		end if
		
		--
		
		set theArtist to value of property list item "Artist" of aTrackItem
		
		if (length of theArtist < 1) then
			
			return false
			
		end if
		
		--
		
		set theAlbum to value of property list item "Album" of aTrackItem
		
		if (length of theAlbum < 1) then
			
			return false
			
		end if
		
		--
		
		try
			
			set theRating to value of property list item "Rating" of aTrackItem
			
		on error
			
			set theRating to 0
			
		end try
		
		--
		
		try
			
			set thePlayCount to value of property list item "Play Count" of aTrackItem
			
		on error
			
			set thePlayCount to 0
			
		end try
		
		--
		
		try
			
			set theSkipCount to value of property list item "Skip Count" of aTrackItem
			
		on error
			
			set theSkipCount to 0
			
		end try
		
		-- 
		
	end tell
	
	--
	
	tell application "iTunes"
		
		--
		
		set allTracks to every track whose name is equal to theName and artist is equal to theArtist and album is equal to theAlbum
		
		if ((count of allTracks) < 1) then
			
			return false
			
		end if
		
		--
		
		set theTrack to first item of allTracks
		
		--
		
		if (theRating > 0) then
			
			set rating of theTrack to theRating
			
		end if
		
		--
		
		if (thePlayCount > 0) then
			
			set played count of theTrack to thePlayCount
			
		end if
		
		--
		
		if (theSkipCount > 0) then
			
			set skipped count of theTrack to theSkipCount
			
		end if
		
		--
		
		(*
		log "#"
		log theName
		log theArtist
		log theTrack
		*)
		
		--
		
	end tell
	
	--
	
	return true
	
	--
	
end workWithTrackItem

--
 
  • Gefällt mir
Reaktionen: smn, Rubens, iTob und 3 andere
Sehr schön.
Ich frag mich aber, warum es eine intakte Backupversion der xml-Datei gab, aber keine der itl-Datei.
Ernstgemeinte Frage.
Oder ist das mit der "alten XML" nur mißverständlich formuliert?
 
Guten Morgen,

das kann ich leider nicht beantworten.
Er bat mich um das Ermitteln aus der XML und das fand ich ne gute Idee.

Viele Grüße
 
Zurück
Oben Unten