def getStationList():
    stationList = []
    telnet = mpc.telnetCmd('playlistinfo')
    stationsBlocks = telnet.split('Id')
    for station in stationsBlocks:
        stationItems = station.split('\n')
    	stationStore = dict()
    	stationStore.update({'url': ''})
    	stationStore.update({'title': ''})
    	for stationItem in stationItems:
    		if('Pos:' in stationItem):
    			pos = stationItem[5:]
    			stationStore.update({'id': int(pos)})
    		if('file:' in stationItem):
    			url = stationItem[6:]
    			stationStore.update({'url': url})
    		if('Title:' in stationItem):
    			title = stationItem[7:]
    			stationStore.update({'title': title})
    		if('Name:' in stationItem):
    			name = stationItem[6:]
    			stationStore.update({'name': name})
    	if(len(stationStore['url']) > 0):
    		stationList.append(stationStore)
    	
    result = dict()
    result.update({'stations': stationList})
    result.update({'size': len(stationList)})
    return result
Exemple #2
0
 def run(self):
     while(self.__running):
         current = mpc.sysCmd('mpc current')
         if(len(current.strip()) == 0):
             next = self.__player.next()
             if next is None:
                 self.__running = False
             else:
                 url = Player.api.get_stream_urls(next)[0]
                 mpc.telnetCmd('clear')
                 mpc.telnetCmd('add ' + str(url))
                 mpc.telnetCmd('play')    
         time.sleep(3)
Exemple #3
0
 def playSong(self, songId):
     self.stop()
     
     if(songId is None):
         Player.current = Player.playlist[0].get('id');
     else:
         Player.current = songId;
         
     url = Player.api.get_stream_url(Player.current)
     mpc.telnetCmd('clear')
     mpc.telnetCmd('add ' + str(url))
     mpc.telnetCmd('play')
     
     Player.updater = PlayerUpdate(self)
     Player.updater.setRunning(True)
     Player.updater.start()
         
     return Player.current
Exemple #4
0
 def stop(self):
     Player.updater.setRunning(False)
     mpc.telnetCmd('clear')
     mpc.telnetCmd('stop')
     mpc.telnetCmd('load ' + FALLBACK_PLAYLIST)
     return str(True);
Exemple #5
0
 def stop(self):
     Player.updater.setRunning(False)
     mpc.telnetCmd('clear')
     mpc.telnetCmd('stop')
     return str(True);
def moveStation(posFrom, posTo):
    mpc.telnetCmd('move ' + posFrom + ' ' + posTo)
    mpc.savePlaylist()
    return posTo