M
MrKnx
Mitglied
Thread Starter
- Dabei seit
- 30.01.2014
- Beiträge
- 44
- Reaktionspunkte
- 1
Hi Leute,
ich habe vor, einige iTunesinformationen in eine XML zu schreiben, um diese mit meinem Hausautomationserver auslesen zu können. Leider wehrt sich mein Script an dem current track und will einfach nicht durchlaufen. Kann mir vielleicht jemand weiterhelfen?
Bitte nicht schlagen, Apllescripte sind nicht mein Spezialgebiet.... :d
ich habe vor, einige iTunesinformationen in eine XML zu schreiben, um diese mit meinem Hausautomationserver auslesen zu können. Leider wehrt sich mein Script an dem current track und will einfach nicht durchlaufen. Kann mir vielleicht jemand weiterhelfen?
Bitte nicht schlagen, Apllescripte sind nicht mein Spezialgebiet.... :d
Code:
[FONT=Helvetica Neue]on [COLOR=#0433ff]run[/COLOR][/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]filepath[/COLOR] to ((([COLOR=#012fbe]path to[/COLOR] [COLOR=#5730be]desktop[/COLOR]) as [COLOR=#0433ff]Unicode text[/COLOR]) & "iTunes_Info.xml")[/FONT]
[COLOR=#4F8F00][FONT=Helvetica Neue][COLOR=#000000] set [/COLOR]xmldata[COLOR=#000000] to [/COLOR]xmlheader[COLOR=#000000]() & [/COLOR][COLOR=#812fdc]return[/COLOR][/FONT][/COLOR]
[FONT=Helvetica Neue] tell [COLOR=#0433ff]application[/COLOR] "System Events" to ([COLOR=#812fdc]name[/COLOR] of [COLOR=#0433ff]processes[/COLOR]) contains "iTunes"[/FONT]
[FONT=Helvetica Neue] if [COLOR=#812fdc]result[/COLOR] is [COLOR=#812fdc]true[/COLOR] then[/FONT]
[FONT=Helvetica Neue] tell [COLOR=#0433ff]application[/COLOR] "iTunes"[/FONT]
[FONT=Helvetica Neue] try[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]player_state[/COLOR] to (get [COLOR=#812fdc]player state[/COLOR] as [COLOR=#0433ff]string[/COLOR])[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]volume_info[/COLOR] to (get [COLOR=#812fdc]sound volume[/COLOR] as [COLOR=#0433ff]string[/COLOR])[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]airplay_state[/COLOR] to (get [COLOR=#812fdc]AirPlay enabled[/COLOR] as [COLOR=#0433ff]string[/COLOR])[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]equalizer_state[/COLOR] to (get [COLOR=#812fdc]EQ enabled[/COLOR] as [COLOR=#0433ff]string[/COLOR])[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]current_album[/COLOR] to (get [COLOR=#812fdc]album[/COLOR] of the [COLOR=#812fdc]current track[/COLOR] as [COLOR=#0433ff]string[/COLOR])[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]current_artist[/COLOR] to (get [COLOR=#812fdc]artist[/COLOR] of the [COLOR=#812fdc]current track[/COLOR] as [COLOR=#0433ff]string[/COLOR])[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]current_track[/COLOR] to (get [COLOR=#812fdc]current track[/COLOR] as [COLOR=#0433ff]string[/COLOR])[/FONT]
[FONT=Helvetica Neue] end try[/FONT]
[FONT=Helvetica Neue] end tell[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]xmldata[/COLOR] to [COLOR=#4f8f00]xmldata[/COLOR] & "<iTunes>ON</iTunes>"[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]xmldata[/COLOR] to [COLOR=#4f8f00]xmldata[/COLOR] & "<state>" & [COLOR=#4f8f00]player_state[/COLOR] & "</state>"[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]xmldata[/COLOR] to [COLOR=#4f8f00]xmldata[/COLOR] & "<volume>" & [COLOR=#4f8f00]volume_info[/COLOR] & "</volume>"[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]xmldata[/COLOR] to [COLOR=#4f8f00]xmldata[/COLOR] & "<airplay>" & [COLOR=#4f8f00]airplay_state[/COLOR] & "</airplay>"[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]xmldata[/COLOR] to [COLOR=#4f8f00]xmldata[/COLOR] & "<equalizerON>" & [COLOR=#4f8f00]equalizer_state[/COLOR] & "</equalizerON>"[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]xmldata[/COLOR] to [COLOR=#4f8f00]xmldata[/COLOR] & "<album>" & [COLOR=#4f8f00]current_album[/COLOR] & "</album>"[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]xmldata[/COLOR] to [COLOR=#4f8f00]xmldata[/COLOR] & "<artist>" & [COLOR=#4f8f00]current_artist[/COLOR] & "</artist>"[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]xmldata[/COLOR] to [COLOR=#4f8f00]xmldata[/COLOR] & "<title>" & [COLOR=#4f8f00]current_track[/COLOR] & "</track>"[/FONT]
[COLOR=#4F8F00][FONT=Helvetica Neue][COLOR=#000000] my [/COLOR]writetofile[COLOR=#000000]([/COLOR]xmldata[COLOR=#000000], [/COLOR]filepath[COLOR=#000000])[/COLOR][/FONT][/COLOR]
[FONT=Helvetica Neue] else[/FONT]
[FONT=Helvetica Neue] set [COLOR=#4f8f00]xmldata[/COLOR] to [COLOR=#4f8f00]xmldata[/COLOR] & "<iTunes>OFF</iTunes>"[/FONT]
[COLOR=#4F8F00][FONT=Helvetica Neue][COLOR=#000000] my [/COLOR]writetofile[COLOR=#000000]([/COLOR]xmldata[COLOR=#000000], [/COLOR]filepath[COLOR=#000000])[/COLOR][/FONT][/COLOR]
[FONT=Helvetica Neue] end if[/FONT]
[FONT=Helvetica Neue]end [COLOR=#0433ff]run[/COLOR][/FONT]
[FONT=Helvetica Neue]
[/FONT]
[COLOR=#4F8F00][FONT=Helvetica Neue][COLOR=#000000]on [/COLOR]xmlheader[COLOR=#000000]()[/COLOR][/FONT][/COLOR]
[FONT=Helvetica Neue] return "<?xml version=\"1.0\" encoding=\"utf-8\"?>"[/FONT]
[COLOR=#4F8F00][FONT=Helvetica Neue][COLOR=#000000]end [/COLOR]xmlheader[/FONT][/COLOR]
[FONT=Helvetica Neue]
[/FONT]
[FONT=Helvetica Neue]
[/FONT]
[COLOR=#4F8F00][FONT=Helvetica Neue][COLOR=#000000]on [/COLOR]writetofile[COLOR=#000000]([/COLOR]cont[COLOR=#000000], [/COLOR]filepath[COLOR=#000000])[/COLOR][/FONT][/COLOR]
[FONT=Helvetica Neue] try[/FONT]
[COLOR=#012FBE][FONT=Helvetica Neue][COLOR=#000000] set [/COLOR][COLOR=#4f8f00]openfile[/COLOR][COLOR=#000000] to [/COLOR]open for access[COLOR=#4f8f00]filepath[/COLOR][COLOR=#000000] with [/COLOR]write permission[/FONT][/COLOR]
[FONT=Helvetica Neue] [COLOR=#012fbe]set eof[/COLOR] of [COLOR=#4f8f00]openfile[/COLOR] [COLOR=#012fbe]to[/COLOR] 0[/FONT]
[COLOR=#012FBE][FONT=Helvetica Neue][COLOR=#000000] set [/COLOR][COLOR=#4f8f00]BOM_UTF8[/COLOR][COLOR=#000000] to (([/COLOR]ASCII character[COLOR=#000000] 239) & ([/COLOR]ASCII character[COLOR=#000000] 187) & ([/COLOR]ASCII character[COLOR=#000000] 191))[/COLOR][/FONT][/COLOR]
[COLOR=#4F8F00][FONT=Helvetica Neue][COLOR=#012fbe]write[/COLOR]BOM_UTF8[COLOR=#012fbe]to[/COLOR]openfile[/FONT][/COLOR]
[FONT=Helvetica Neue] [COLOR=#012fbe]write[/COLOR] [COLOR=#4f8f00]cont[/COLOR] [COLOR=#012fbe]to[/COLOR] [COLOR=#4f8f00]openfile[/COLOR] [COLOR=#012fbe]as[/COLOR] «[COLOR=#0433ff]class[/COLOR] utf8»[/FONT]
[COLOR=#012FBE][FONT=Helvetica Neue]close access[COLOR=#4f8f00]openfile[/COLOR][/FONT][/COLOR]
[FONT=Helvetica Neue] return [COLOR=#812fdc]true[/COLOR][/FONT]
[FONT=Helvetica Neue] on error[/FONT]
[FONT=Helvetica Neue] try[/FONT]
[COLOR=#012FBE][FONT=Helvetica Neue]close access[COLOR=#4f8f00]openfile[/COLOR][/FONT][/COLOR]
[FONT=Helvetica Neue] end try[/FONT]
[FONT=Helvetica Neue] return [COLOR=#812fdc]false[/COLOR][/FONT]
[FONT=Helvetica Neue] end try[/FONT]
[COLOR=#4F8F00][FONT=Helvetica Neue][COLOR=#000000]end [/COLOR]writetofile[/FONT][/COLOR]