def playlist(self, name): for item in self.mpd.listplaylistinfo(name): print item info = util.get_info_labels_from_queued_item(item) title = util.format_song(info) menu = { __str__(30030): { self.key: 'queue_add', 'file': item['file'] }, __str__(30031): { self.key: 'queue_repl', 'file': item['file'] } } util.add_song(title, { self.key: 'play', 'id': 'id' }, infoLabels=info, menuItems=menu, replace=True) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_LABEL, label2Mask="%X")
def list(self): playlist = self.mpd.playlistinfo() print playlist current = util.fix_keys(self.mpd.currentsong(),['id']) for item in playlist: info = util.get_info_labels_from_queued_item(item) title = util.format_song(info) if current['id'] == item['id']: title = '* %s' % title util.add_song(title,{self.key:'play','id':item['id']},infoLabels=info,menuItems={})
def list_tracks(self,artist,album): xbmcplugin.addSortMethod( handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_TRACKNUM) for item in self.mpd.find('artist',artist,'album',album): info = util.get_info_labels_from_queued_item(item) title = '%02d %s' % (info['tracknumber'],item['title']) menu={ __str__(30030):{self.key:'queue_add','file':item['file']}, __str__(30031):{self.key:'queue_repl','file':item['file']} } util.add_song(title,{self.key:'play','id':'id'},infoLabels=info,menuItems=menu,replace=True)
def playlist(self,name): for item in self.mpd.listplaylistinfo(name): print item info = util.get_info_labels_from_queued_item(item) title = util.format_song(info) menu={ __str__(30030):{self.key:'queue_add','file':item['file']}, __str__(30031):{self.key:'queue_repl','file':item['file']} } util.add_song(title,{self.key:'play','id':'id'},infoLabels=info,menuItems=menu,replace=True) xbmcplugin.addSortMethod( handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_LABEL, label2Mask="%X")
def render(data): if data == None: raise Exception('Addon error, no data returned') listed = 0 for item in data: if item['type'] == 'play': print 'Playing MPD Stream ' + item['path'] li = xbmcgui.ListItem(path=item['path'], iconImage='DefaulAudio.png') return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li) if item['type'] == 'dummy': listed += 1 if item['type'] == 'dir': listed += 1 params = item['params'] params.update({'m': item['m']}) util.add_dir(item['title'], params, icon(item['icon']), menuItems=item['menu'], replace=True) if item['type'] == 'audio': listed += 1 params = item['params'] params.update({'m': item['m']}) util.add_song(item['title'], params, icon(item['icon']), menuItems=item['menu'], playable=str(item['play']).lower(), replace=True) if item['type'] == 'func': print 'Executing %s' % item['func'] xbmc.executebuiltin(item['func']) if item['type'] == 'sort': sort_methods(item['keys']) if item['type'] == 'notify': notify(item['title'], item['message']) if item['type'] == 'search': what = item['for'] if what == '#': kb = xbmc.Keyboard('', __str__(30071), False) kb.doModal() if kb.isConfirmed(): what = kb.getText() if not (what == '' or what == '#'): render(item['func'](what)) return if listed > 0: xbmcplugin.endOfDirectory(int(sys.argv[1]))
def list(self): playlist = self.mpd.playlistinfo() print playlist current = util.fix_keys(self.mpd.currentsong(), ['id']) for item in playlist: info = util.get_info_labels_from_queued_item(item) title = util.format_song(info) if current['id'] == item['id']: title = '* %s' % title util.add_song(title, { self.key: 'play', 'id': item['id'] }, infoLabels=info, menuItems={})
def list(self, params): uri = '' if 'path' in params.keys(): uri = params['path'] for item in self.mpd.lsinfo(uri): print item if 'directory' in item: menu = { __str__(30030): { self.key: 'queue_add', 'path': item['directory'] }, __str__(30031): { self.key: 'queue_repl', 'path': item['directory'] } } title = os.path.basename(item['directory']) util.add_dir(title, { self.key: 'list', 'path': item['directory'] }, infoLabels={}, menuItems=menu, replace=True) elif 'file' in item: menu = { __str__(30030): { self.key: 'queue_add', 'path': item['file'] }, __str__(30031): { self.key: 'queue_repl', 'path': item['file'] } } title = os.path.basename(item['file']) util.add_song(title, { self.key: 'list', 'path': item['file'] }, infoLabels={}, menuItems=menu, replace=True) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_LABEL, label2Mask="%X")
def render(data): if data == None: raise Exception('Addon error, no data returned') listed = 0 for item in data: if item['type'] == 'play': print 'Playing MPD Stream '+item['path'] li = xbmcgui.ListItem(path=item['path'],iconImage='DefaulAudio.png') return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li) if item['type'] == 'dummy': listed+=1 if item['type'] == 'dir': listed+=1 params = item['params'] params.update({'m':item['m']}) util.add_dir(item['title'],params,icon(item['icon']),menuItems=item['menu'],replace=True) if item['type'] == 'audio': listed+=1 params = item['params'] params.update({'m':item['m']}) util.add_song(item['title'],params,icon(item['icon']),menuItems=item['menu'],playable=str(item['play']).lower(),replace=True) if item['type'] == 'func': print 'Executing %s' % item['func'] xbmc.executebuiltin(item['func']) if item['type'] == 'sort': sort_methods(item['keys']) if item['type'] == 'notify': notify(item['title'],item['message']) if item['type'] == 'search': what = item['for'] if what == '#': kb = xbmc.Keyboard('',__str__(30071),False) kb.doModal() if kb.isConfirmed(): what = kb.getText() if not (what == '' or what == '#'): render(item['func'](what)) return if listed > 0: xbmcplugin.endOfDirectory(int(sys.argv[1]))
def list(self,params): uri = '' if 'path' in params.keys(): uri = params['path'] for item in self.mpd.lsinfo(uri): print item if 'directory' in item: menu={ __str__(30030):{self.key:'queue_add','path':item['directory']}, __str__(30031):{self.key:'queue_repl','path':item['directory']} } title = os.path.basename(item['directory']) util.add_dir(title,{self.key:'list','path':item['directory']},infoLabels={},menuItems=menu,replace=True) elif 'file' in item: menu={ __str__(30030):{self.key:'queue_add','path':item['file']}, __str__(30031):{self.key:'queue_repl','path':item['file']} } title = os.path.basename(item['file']) util.add_song(title,{self.key:'list','path':item['file']},infoLabels={},menuItems=menu,replace=True) xbmcplugin.addSortMethod( handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_LABEL, label2Mask="%X")
def list_tracks(self, artist, album): xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_TRACKNUM) for item in self.mpd.find('artist', artist, 'album', album): info = util.get_info_labels_from_queued_item(item) title = '%02d %s' % (info['tracknumber'], item['title']) menu = { __str__(30030): { self.key: 'queue_add', 'file': item['file'] }, __str__(30031): { self.key: 'queue_repl', 'file': item['file'] } } util.add_song(title, { self.key: 'play', 'id': 'id' }, infoLabels=info, menuItems=menu, replace=True)
def list(self): status = self.mpd.status() print status print self.mpd.currentsong() if status['state'] == 'pause' or status['state'] == 'stop': util.add_song('Play',{self.key:'play'}) else: util.add_song('Pause',{self.key:'pause'}) util.add_song('Stop',{self.key:'stop'}) util.add_song('Next',{self.key:'next'}) util.add_song('Previous',{self.key:'prev'}) if not __sett__('stream_url') == '' and status['state'] == 'play': util.add_song(__str__(30039),{self.key:'play_stream'},playable='true')
def list(self): status = self.mpd.status() print status print self.mpd.currentsong() if status['state'] == 'pause' or status['state'] == 'stop': util.add_song('Play', {self.key: 'play'}) else: util.add_song('Pause', {self.key: 'pause'}) util.add_song('Stop', {self.key: 'stop'}) util.add_song('Next', {self.key: 'next'}) util.add_song('Previous', {self.key: 'prev'}) if not __sett__('stream_url') == '' and status['state'] == 'play': util.add_song(__str__(30039), {self.key: 'play_stream'}, playable='true')