def popup_free_account(self): if qobuz.addon.getSetting('warn_free_account') != 'true': return dialog = xbmcgui.Dialog() ok = dialog.yesno(qobuz.lang(41000), qobuz.lang(41001), qobuz.lang(41002), qobuz.lang(41003)) if ok: qobuz.addon.setSetting('warn_free_account', 'false')
def __init__(self, parent = None, parameters = None, progress = None): super(Node_favorites, self).__init__(parent, parameters) self.type = NodeFlag.TYPE_NODE | NodeFlag.TYPE_FAVORITES self.set_label(qobuz.lang(30079)) #self.set_is_folder(True) #self.cache = None self.packby = ''#album' self.image = qobuz.image.access.get('playlist') #if self.packby == 'album': # self.set_content_type('albums') #else: self.name = qobuz.lang(30079) self.label = qobuz.lang(30079) self.set_content_type('songs') self.set_auto_set_cache(True)
def attach_context_menu(self,item): # import urllib color = qobuz.addon.getSetting('color_item') menuItems = [] cmd = '' ''' VIEW BIG DIR ''' path = self.make_url(Mode.VIEW_BIG_DIR) label = qobuz.lang(39002) menuItems.append((qobuz.utils.color(color,label),"XBMC.Container.Update(%s)" % (path))) if self.type & (NodeFlag.TYPE_PRODUCT | NodeFlag.TYPE_TRACK | NodeFlag.TYPE_ARTIST): ''' ALL ALBUM ''' id = self.get_artist_id() url = self.help_make_url(Mode.VIEW,NodeFlag.TYPE_ARTIST,id) cmd = "XBMC.Container.Update(%s)" % (url) menuItems.append((qobuz.utils.color(color,qobuz.lang(39001)),cmd)) ''' Similar artist ''' id = self.get_artist_id() import urllib query = urllib.quote(self.get_artist().encode('utf-8')) args = sys.argv[0] + '?mode=%i&nt=%i&nid=%s&query=%s' % (Mode.VIEW, NodeFlag.TYPE_SIMILAR_ARTIST, id,query) cmd = "XBMC.Container.Update(%s)" % (args) menuItems.append((qobuz.utils.color(color, qobuz.lang(39004)),cmd)) ''' ADD TO CURRENT PLAYLIST ''' cmd = "XBMC.Container.Update(%s)" % (self.make_url(Mode.PLAYLIST_ADD_TO_CURRENT)) menuItems.append((qobuz.utils.color(color,qobuz.lang(39005)),cmd)) #======================================================================= # ''' ADD AS NEW ''' # cmd = "XBMC.Container.Update(%s)" % (self.make_url(Mode.PLAYLIST_ADD_AS_NEW)) # menuItems.append((qobuz.utils.color(color, "(i8n) Add as new"),cmd)) #======================================================================= ''' Show playlist ''' if not (self.type & NodeFlag.TYPE_PLAYLIST): showplaylist = sys.argv[0] + "?mode=" + str(Mode.VIEW) + '&nt=' + str(NodeFlag.TYPE_USERPLAYLISTS) menuItems.append((qobuz.utils.color(color, qobuz.lang(39006)),"XBMC.Container.Update(" + showplaylist + ")")) if self.type & NodeFlag.TYPE_USERPLAYLISTS: ''' CREATE ''' url = self.make_url(Mode.PLAYLIST_CREATE) menuItems.append((qobuz.utils.color(color, qobuz.lang(39008)), "XBMC.RunPlugin("+url+")")) ''' Give a chance to our siblings to attach their items ''' self.hook_attach_context_menu(item,menuItems) ''' SCAN ''' url = self.make_url(Mode.SCAN) try: label = qobuz.utils.color(color,qobuz.lang(39003) + ": ") + self.get_label().decode('utf8','replace') except: pass menuItems.append((label,'XBMC.UpdateLibrary("music", "%s")' % (url))) ''' ERASE CACHE ''' color = qobuz.addon.getSetting('color_item_caution') erasecache = sys.argv[0] + "?mode=" + str(Mode.ERASE_CACHE) menuItems.append((qobuz.utils.color(color,qobuz.lang(31009)),"XBMC.RunPlugin(" + erasecache + ")")) ''' Add our items to the context menu ''' if len(menuItems) > 0: item.addContextMenuItems(menuItems,replaceItems=False)
def _build_down(self, xbmc_directory, lvl, flag = None): query = self.get_parameter('query').strip().lower() query.encode('utf8', 'replace') data = qobuz.api.get_similar_artists(query) warn (self, pprint.pformat(data)) if not data: return False #dom = parseString(data) class parse_simartists(): def __init__(self, data): self.dom = parseString(data) self.artists = [] def getText(self, nodelist): rc = [] for node in nodelist: if node.nodeType == node.TEXT_NODE: rc.append(node.data) return ''.join(rc) def parse(self): self._get_artists(self.dom) def _get_artists(self, dom): artists = dom.getElementsByTagName('artist') for artist in artists: self._h_artist(artist) def _h_artist_image(self, domlist, artist): for dom in domlist: size = dom.getAttribute('size') if size != 'mega': continue image = self.getText(dom.childNodes) artist['image'] = image def _h_artist(self, dom): name = self.getText(dom.getElementsByTagName('name')[0].childNodes).strip().lower() artist = { 'name': name} self._h_artist_image(dom.getElementsByTagName('image'), artist) self.artists.append(artist) return True parse = parse_simartists(data) parse.parse() if len(parse.artists) < 1: qobuz.gui.notifyH("Qobuz: No similar artist", urllib.unquote(query)) return False listid = {} max = 20 count = 0 total = len(parse.artists) for a in parse.artists: if count > max: break count+=1 name = a['name'] if not name: continue name = name.encode('utf8', 'replace') xbmc_directory.update(count, total, qobuz.lang(40005), name) if xbmc_directory.is_canceled(): break search_cache = Cache_search_artists(name) result = search_cache.fetch_data() if not result or len(result) < 1: warn(self, "No result for artist: " + name) continue for jartist in result: artist_id = jartist['id'] if artist_id in listid: continue artist = Node_artist() artist.set_data(jartist) artist.set_image(a['image']) listid[artist_id] = artist self.add_child(artist) return len(parse.artists)
def get_label(self): return qobuz.lang(39000)