-
-
Save DomiR/5595755 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 python script listens for distributed notifications from iTunes of new songs playing, | |
works alot better then constantly polling. | |
''' | |
import Foundation | |
from AppKit import * | |
from PyObjCTools import AppHelper | |
class GetSongs(NSObject): | |
def getMySongs_(self, song): | |
song_details = {} | |
ui = song.userInfo() | |
song_details = dict(zip(ui.keys(), ui.values())) | |
print song_details | |
nc = Foundation.NSDistributedNotificationCenter.defaultCenter() | |
GetSongs = GetSongs.new() | |
nc.addObserver_selector_name_object_(GetSongs, 'getMySongs:', 'com.apple.iTunes.playerInfo',None) | |
NSLog("Listening for new tunes....") | |
AppHelper.runConsoleEventLoop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment