Created
December 18, 2009 08:05
-
-
Save codiez/259355 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
This script grabs the currently playing song from Itunes and generates a dict with the song details such as name, artist, album, genre etc. | |
You need the appscript library | |
''' | |
from appscript import * | |
it = app('iTunes') | |
tags = ['name', 'artist','album','genre','played_date','duration'] | |
if it.isrunning(): | |
state = it.player_state.get() | |
if state.name == 'playing': | |
song_details = [eval('it.current_track.' + tag + '.get()') for tag in tags] | |
song_details = dict(zip(tags, song_details)) | |
try: | |
z = song_details['played_date'].name | |
song_details['played_date'] = '' | |
except: | |
pass | |
print song_details | |
else: | |
print "Itunes is currently:", state.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment