def subscribe(self): if api.playlist_subscribe(playlist_id=self.nid): notify_log(lang(30183), lang(30187)) self.delete_cache(self.nid) return True else: return False
def gui_rename(self, playlist_id=None): if not playlist_id: playlist_id = self.nid if not playlist_id: warn(self, "Can't rename playlist without id") return False from qobuz.gui.util import Keyboard data = api.get('/playlist/get', playlist_id=playlist_id) if not data: warn(self, "Something went wrong while renaming playlist") return False self.data = data currentname = self.get_name() k = Keyboard(currentname, lang(30080)) k.doModal() if not k.isConfirmed(): return False newname = k.getText() newname = newname.strip() if not newname: notify_error(dialogHeading, "Don't u call ure child something?") return False if newname == currentname: return True res = api.playlist_update(playlist_id=playlist_id, name=newname) if not res: warn(self, "Cannot rename playlist with name %s" % (newname)) return False self.delete_cache(playlist_id) notify_log(lang(30080), (u"%s: %s") % (lang(30165), currentname)) executeBuiltin(containerRefresh()) return True
def gui_add_to_current(self): cid = self.get_current_playlist() qnt = int(self.get_parameter('qnt')) qid = self.get_parameter('qid') nodes = [] if qnt & Flag.SEARCH == Flag.SEARCH: self.del_parameter('query') if qnt & Flag.TRACK == Flag.TRACK: node = getNode(qnt, {'nid': qid}) node.fetch(None, None, None, Flag.NONE) nodes.append(node) else: render = renderer(qnt, self.parameters) render.depth = -1 render.whiteFlag = Flag.TRACK render.asList = True render.run() nodes = render.nodes ret = xbmcgui.Dialog().select('Add to current playlist', [ node.get_label() for node in nodes ]) if ret == -1: return False ret = self._add_tracks(cid, nodes) if not ret: notify_warn('Qobuz', 'Failed to add tracks') return False self.delete_cache(cid) notify_log('Qobuz / Tracks added', '%s added' % (len(nodes))) return True
def gui_rename(self, playlist_id=None): if not playlist_id: playlist_id = self.nid if not playlist_id: logger.warn('Can\'t rename playlist without id') return False node = getNode(Flag.PLAYLIST, parameters={'nid': playlist_id}) data = node.fetch() if not data: logger.warn('Something went wrong while renaming playlist') return False self.data = data currentname = self.get_name() newname = ask(currentname, lang(30080)) if newname is None: return False if newname == '': notify_error(dialogHeading, 'Don\'t u call ure child something?') return False if newname == currentname: return True res = api.playlist_update(playlist_id=playlist_id, name=newname) if not res: logger.warn('Cannot rename playlist with name %s' % newname) return False self.delete_cache(playlist_id) notify_log(lang(30080), u'%s: %s' % (lang(30165), currentname)) executeBuiltin(containerRefresh()) return True
def gui_remove(self, playlist_id=None): playlist_id = self._get_playlist_id(playlist_id=playlist_id) if not playlist_id: notify_error(dialogHeading, 'Invalid playlist %s' % (str(playlist_id))) return False data = api.get('/playlist/get', playlist_id=playlist_id, limit=self.limit, offset=self.offset) if data is None: logger.error('Cannot get playlist with id %s', playlist_id) return False name = '' if 'name' in data: name = data['name'] ok = xbmcgui.Dialog().yesno( lang(30166), lang(30054), color('FFFF0000', name)) if not ok: return False if data['owner']['name'] == user.username: res = api.playlist_delete(playlist_id=playlist_id) else: res = api.playlist_unsubscribe(playlist_id=playlist_id) if not res: logger.warn('Cannot delete playlist with id ' + str(playlist_id)) notify_error(lang(30183), lang(30186) + name) return False self.delete_cache(playlist_id) executeBuiltin(containerRefresh()) notify_log(lang(30183), (lang(30184) + ' %s ' + lang(30185)) % name) return True
def gui_add_to_current(self): cid = self.get_current_playlist() qnt = int(self.get_parameter('qnt')) qid = self.get_parameter('qid') nodes = [] if qnt & Flag.SEARCH == Flag.SEARCH: self.del_parameter('query') if qnt & Flag.TRACK == Flag.TRACK: node = getNode(qnt, parameters={'nid': qid}) node.data = node.fetch() nodes.append(node) else: render = renderer( qnt, parameters=self.parameters, depth=-1, whiteFlag=Flag.TRACK, asList=True) render.run() nodes = render.nodes ret = xbmcgui.Dialog().select('Add to current playlist', [node.get_label() for node in nodes]) if ret == -1: return False ret = self._add_tracks(cid, nodes) if not ret: notify_warn('Qobuz', 'Failed to add tracks') return False self.delete_cache(cid) notify_log('Qobuz / Tracks added', '%s added' % (len(nodes))) executeBuiltin(containerRefresh()) return True
def gui_remove_track(self): qid = self.get_parameter('qid') if not self.remove_tracks(qid): notify_error(dialogHeading, 'Cannot remove track!') return False self.delete_cache(self.nid) notify_log(dialogHeading, 'Track removed from playlist') executeBuiltin(containerRefresh()) return True
def gui_remove_track(self): qid = self.get_parameter('qid') print "Removing track %s from playlist %s" % (qid, self.nid) if not self.remove_tracks(qid): notify_error(dialogHeading, 'Cannot remove track!') return False self.delete_cache(self.nid) notify_log(dialogHeading, 'Track removed from playlist') executeBuiltin(containerRefresh()) return True
def toggle_privacy(self): if self.data is None: self.data = self.fetch() privacy = not self.get_property('is_public', to='bool') res = api.playlist_update( playlist_id=self.nid, is_public=str(privacy).lower()) if res is None: notify_error('Qobuz', 'Cannot toggle privacy') return False self.delete_cache(self.nid) notify_log(dialogHeading, 'Privacy changed public: %s' % privacy) executeBuiltin(containerRefresh()) return True
def _callback(self, _elapsed): msg = u', '.join([str(n.text) for n in self.store]) msg = msg[:-2] visited = len(self.store) self.total += visited self.store = [] if hasattr(self.title, '__call__'): title = self.title() else: title = self.title util.notify_log( '%s nodes: %s' % (title, self.total), '%s' % msg, mstime=self.duration * 1000) return True
def gui_add_as_new(self, _=None): nodes = [] qnt = int(self.get_parameter('qnt')) qid = self.get_parameter('qid') name = self.get_parameter('query', to='unquote', default=None) if qnt & Flag.SEARCH: self.del_parameter('query') if qnt & Flag.TRACK == Flag.TRACK: node = getNode(qnt, parameters={'nid': qid}) node.data = node.fetch() nodes.append(node) else: render = renderer( qnt, parameters=self.parameters, depth=-1, whiteFlag=Flag.TRACK, asList=True) render.run() nodes = render.nodes if len(nodes) == 0: return False if name is None: name = ask('Playlist name? (i8n)') if name is None: return False ret = xbmcgui.Dialog().select('Create playlist %s' % name, [node.get_label() for node in nodes]) if ret == -1: return False playlist = self.create(name) if not playlist: notify_error('Qobuz', 'Playlist creationg failed') logger.warn('Cannot create playlist...') return False if not self._add_tracks(playlist['id'], nodes): notify_error('Qobuz / Cannot add tracks', '%s' % name) return False self.delete_cache(playlist['id']) notify_log('Qobuz / Playlist added', '[%s] %s' % (len(nodes), name)) executeBuiltin(containerRefresh()) return True
def gui_remove(self, playlist_id=None): if not playlist_id: playlist_id = self.nid if not playlist_id: notify_error(dialogHeading, 'Invalid playlist %s' % (str(playlist_id))) return False login = getSetting('username') offset = 0 limit = getSetting('pagination_limit') data = api.get('/playlist/get', playlist_id=playlist_id, limit=limit, offset=offset) name = '' if 'name' in data: name = data['name'] ok = xbmcgui.Dialog().yesno(lang(30166), lang(30054), color('FFFF0000', name)) if not ok: info(self, "Deleting playlist aborted...") return False res = False if data['owner']['name'] == login: info(self, "Deleting playlist: " + str(playlist_id)) res = api.playlist_delete(playlist_id=playlist_id) else: info(self, 'Unsuscribe playlist' + str(playlist_id)) res = api.playlist_unsubscribe(playlist_id=playlist_id) if not res: warn(self, "Cannot delete playlist with id " + str(playlist_id)) notify_error(lang(30183), lang(30186) + name) return False self.delete_cache(playlist_id) notify_log(lang(30183), (lang(30184) + "%s" + lang(30185)) % (name)) url = self.make_url(nt=Flag.USERPLAYLISTS, mode=Mode.VIEW, nm='', nid='') executeBuiltin(containerUpdate(url, True)) return False
def gui_add_as_new(self, name=None): nodes = [] qnt = int(self.get_parameter('qnt')) qid = self.get_parameter('qid') if qnt & Flag.SEARCH: self.del_parameter('query') if qnt & Flag.TRACK == Flag.TRACK: node = getNode(qnt, {'nid': qid}) node.fetch(None, None, None, Flag.NONE) nodes.append(node) else: render = renderer(qnt, self.parameters) render.depth = -1 render.whiteFlag = Flag.TRACK render.asList = True render.run() nodes = render.nodes if name is None: name = self.get_parameter('query', unQuote=True, default=None) \ or self.get_label() ret = xbmcgui.Dialog().select('Create playlist %s' % (name), [ node.get_label() for node in nodes ]) if ret == -1: return False playlist = self.create(name) if not playlist: notify_error('Qobuz', 'Playlist creationg failed') warn(self, "Cannot create playlist...") return False if not self._add_tracks(playlist['id'], nodes): notify_error('Qobuz / Cannot add tracks', "%s" % (name)) return False self.delete_cache(playlist['id']) notify_log('Qobuz / Playlist added', '[%s] %s' % (len(nodes), name)) executeBuiltin(containerRefresh()) return True
def subscribe(self): if api.playlist_subscribe(playlist_id=self.nid): notify_log(lang(30183), lang(30187)) self.delete_cache(self.nid) return True return False