Last active
December 10, 2015 11:28
-
-
Save hiway/4427513 to your computer and use it in GitHub Desktop.
Script to print currently playing track from iTunes on MacOSX — I use this to tweet out my favorite songs. (works on Snow Leopard) Bonus script: youtube_current_song.py will give you a youtube search URL for current song - again useful when tweeting. It also prints exception to stdout, useful for debugging with automation tools like TextExpander.
This file contains hidden or 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
import appscript | |
itunes = appscript.app('itunes') | |
if itunes.isrunning(): | |
track = itunes.current_track() | |
status = "#music %s by %s" %(track.name(), track.artist()) | |
album = track.album() | |
if album: | |
status += " from %s" %(album) | |
print status |
This file contains hidden or 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
appscript==1.0.1 |
This file contains hidden or 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
import appscript | |
import urllib | |
itunes = appscript.app('itunes') | |
try: | |
if itunes.isrunning(): | |
track = itunes.current_track() | |
status = "www.youtube.com/results?" | |
query = track.name() + " " + track.artist() | |
status = status + urllib.urlencode({"search_query":query}) | |
print status, | |
except Exception, e: | |
import traceback, sys | |
traceback.print_exc(file=sys.stdout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment