class Panda: def __init__( self ): self.gui = None self.pandora = None self.playlist = [] self.curStation = "" self.curSong = None self.playing = False self.skip = False self.die = False self.settings = __settings__ self.player = None self.skinName = "Default" fmt = int(self.settings.getSetting( "format" )) fmt = ( "aacplus", "mp3", "mp3-hifi" )[fmt] try: self.pandora = Pandora() self.pandora.set_audio_format(fmt) except PandoraError, e: xbmcgui.Dialog().ok( "Pandora", "Error: %s" %e ) self.die = True return #Proxy settings if self.settings.getSetting( "proxy_enable" ) == "true": print "PANDORA: Proxy Enabled" proxy_info = { "host" : self.settings.getSetting( "proxy_server" ), "port" : self.settings.getSetting( "proxy_port" ), "user" : self.settings.getSetting( "proxy_user" ), "pass" : self.settings.getSetting( "proxy_pass" ) } self.pandora.set_proxy( "http://%(user)s:%(pass)s@%(host)s:%(port)s" % proxy_info ) while not self.auth(): resp = xbmcgui.Dialog().yesno( "Pandora", \ "Failed to authenticate listener.", \ "Check username/password and try again.", \ "Show Settings?" ) if resp: self.settings.openSettings() else: self.quit() return # Get skin from settings. # Check if a value is set in the settings. If not then use Default. if self.settings.getSetting ( "skin" ) != "": self.skinName = self.settings.getSetting( "skin" ) self.player = PandaPlayer( panda = self ) self.gui = PandaGUI( "script-pandora.xml", scriptPath, self.skinName) self.gui.setPanda( self )
class Panda: def __init__(self): self.gui = None self.pandora = None self.playlist = [] self.curStation = "" self.curSong = None self.playing = False self.skip = False self.die = False self.settings = __settings__ self.player = None self.skinName = "Default" fmt = int(self.settings.getSetting("format")) fmt = ("aacplus", "mp3", "mp3-hifi")[fmt] try: self.pandora = Pandora() self.pandora.set_audio_format(fmt) except PandoraError, e: xbmcgui.Dialog().ok("Pandora", "Error: %s" % e) self.die = True return #Proxy settings if self.settings.getSetting("proxy_enable") == "true": print "PANDORA: Proxy Enabled" proxy_info = { "host": self.settings.getSetting("proxy_server"), "port": self.settings.getSetting("proxy_port"), "user": self.settings.getSetting("proxy_user"), "pass": self.settings.getSetting("proxy_pass") } self.pandora.set_proxy( "http://%(user)s:%(pass)s@%(host)s:%(port)s" % proxy_info) while not self.auth(): resp = xbmcgui.Dialog().yesno( "Pandora", \ "Failed to authenticate listener.", \ "Check username/password and try again.", \ "Show Settings?" ) if resp: self.settings.openSettings() else: self.quit() return # Get skin from settings. # Check if a value is set in the settings. If not then use Default. if self.settings.getSetting("skin") != "": self.skinName = self.settings.getSetting("skin") self.player = PandaPlayer(panda=self) self.gui = PandaGUI("script-pandora.xml", scriptPath, self.skinName) self.gui.setPanda(self)
def main(): tmp = "/tmp/lolpiano" try: os.mkdir(tmp) except OSError as e: if e.errno == errno.EEXIST and os.path.isdir(tmp): pass else: raise e email = "" password = "" with open("login.txt", "r") as f: (email, password) = (l.rstrip() for l in f.readlines()) pandora = Pandora() client = client_keys[default_client_id] pandora.connect(client, email, password) pandora.set_audio_quality("mediumQuality") for i, station in enumerate(pandora.stations): print (i, station.name) try: station = int (input("Enter a station number ")) except ValueError: print ("invalid station number.Quitting.") sys.exit(1) station = pandora.stations[station] while True: songs = station.get_playlist() for song in songs: filename = '{0} - {1} - {2}.m4a'.format(song.artist, song.album, song.songName) filename = os.path.join('/tmp/lolpiano/', filename) url = song.audioUrl subprocess.call(['wget', url, '--output-document', filename ]) print ( 'Playing {0}'.format(song.title)) subprocess.call([MP3_PLAYER, filename ])
def __init__(self): self.gui = None self.pandora = None self.playlist = [] self.curStation = "" self.curSong = None self.playing = False self.skip = False self.die = False self.settings = __settings__ self.player = None self.skinName = "Default" fmt = int(self.settings.getSetting("format")) fmt = ("aacplus", "mp3", "mp3-hifi")[fmt] try: self.pandora = Pandora() self.pandora.set_audio_format(fmt) except PandoraError, e: xbmcgui.Dialog().ok("Pandora", "Error: %s" % e) self.die = True return
def __init__( self ): self.gui = None self.pandora = None self.playlist = [] self.curStation = "" self.curSong = None self.playing = False self.skip = False self.die = False self.settings = __settings__ self.player = None self.skinName = "Default" fmt = int(self.settings.getSetting( "format" )) fmt = ( "aacplus", "mp3", "mp3-hifi" )[fmt] try: self.pandora = Pandora() self.pandora.set_audio_format(fmt) except PandoraError, e: xbmcgui.Dialog().ok( "Pandora", "Error: %s" %e ) self.die = True return