def create(self, name=None): username = api.username password = api.password friendpl = api.get("/playlist/getUserPlaylists", username=name) if not friendpl: return False user = api.get("/user/login", username=username, password=password) if user["user"]["login"] == name: return False if not user: return False friends = user["user"]["player_settings"] if not "friends" in friends: friends = [] else: friends = friends["friends"] if name in friends: return False friends.append(name) newdata = {"friends": friends} # easyapi.get(name='user') if not api.user_update(player_settings=json.dumps(newdata)): return False # qobuz.registry.delete(name='user') executeBuiltin(containerRefresh()) return True
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 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(30078)) k.doModal() if not k.isConfirmed(): return False newname = k.getText() newname = newname.strip() if not newname: notifyH(dialogHeading, "Don't u call ure child something?", 'icon-error-256') 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) notifyH(lang(30078), (u"%s: %s") % (lang(39009), currentname)) executeBuiltin(containerRefresh()) return True
def remove(self): name = self.get_parameter("query") if name == "qobuz.com": return False if not name: return False user = self.get_user_data() if not user: return False friends = user["player_settings"] if not "friends" in friends: notifyH("Qobuz", "You don't have friend", "icon-error-256") warn(self, "No friends in user/player_settings") return False friends = friends["friends"] if not name in friends: notifyH("Qobuz", "You're not friend with %s" % (name), "icon-error-256") warn(self, "Friend " + repr(name) + " not in friends data") return False del friends[friends.index(name)] newdata = {"friends": friends} if not api.user_update(player_settings=json.dumps(newdata)): notifyH("Qobuz", "Friend %s added" % (name)) notifyH("Qobuz", "Cannot updata friend's list...", "icon-error-256") return False notifyH("Qobuz", "Friend %s removed" % (name)) self.delete_cache() executeBuiltin(containerRefresh()) return True
def create(self, name=None): username = api.username password = api.password friendpl = api.get('/playlist/getUserPlaylists', username=name) if not friendpl: return False user = api.get('/user/login', username=username, password=password) if user['user']['login'] == name: return False if not user: return False friends = user['user']['player_settings'] if not 'friends' in friends: friends = [] else: friends = friends['friends'] if name in friends: return False friends.append(name) newdata = {'friends': friends} #easyapi.get(name='user') if not api.user_update(player_settings=json.dumps(newdata)): return False # qobuz.registry.delete(name='user') executeBuiltin(containerRefresh()) return True
def remove(self): name = self.get_parameter('query') if name == 'qobuz.com': return False if not name: return False user = self.get_user_data() if not user: return False friends = user['player_settings'] if not 'friends' in friends: notifyH('Qobuz', "You don't have friend", 'icon-error-256') warn(self, "No friends in user/player_settings") return False friends = friends['friends'] if not name in friends: notifyH('Qobuz', "You're not friend with %s" % (name), 'icon-error-256') warn(self, "Friend " + repr(name) + " not in friends data") return False del friends[friends.index(name)] newdata = {'friends': friends} if not api.user_update(player_settings=json.dumps(newdata)): notifyH('Qobuz', 'Friend %s added' % (name)) notifyH('Qobuz', "Cannot updata friend's list...", 'icon-error-256') return False notifyH('Qobuz', 'Friend %s removed' % (name)) self.delete_cache() 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): notifyH(dialogHeading, 'Cannot remove track!', 'icon-error-256') return False self.delete_cache(self.nid) print "Error API: %s (%s)" % (api.error, api.status_code) notifyH(dialogHeading, 'Track removed from playlist') executeBuiltin(containerRefresh()) return True
def gui_remove(self, playlist_id=None): if not playlist_id: playlist_id = self.nid if not playlist_id: notifyH(dialogHeading, 'Invalid playlist %s' % (str(playlist_id))) return False # import xbmcgui # @UnresolvedImport # import xbmc # @UnresolvedImport # cid = self.get_current_playlist() 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)) notifyH(lang(30183), lang(30186) + name, getImage('icon-error-256')) return False self.delete_cache(playlist_id) notifyH(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_create(self): query = self.get_parameter('query', unQuote=True) if not query: from gui.util import Keyboard k = Keyboard('', lang(42000)) k.doModal() if not k.isConfirmed(): warn(self, 'Creating playlist aborted') return None query = k.getText() ret = self.create(query) if not ret: warn(self, "Cannot create playlist named '" + query + "'") return None self.set_as_current(ret['id']) self.delete_cache(ret['id']) url = self.make_url(nt=Flag.USERPLAYLISTS) executeBuiltin(containerUpdate(url)) return ret['id']
def gui_remove(self, playlist_id=None): if not playlist_id: playlist_id = self.nid if not playlist_id: notifyH(dialogHeading, 'Invalid playlist %s' % (str(playlist_id))) return False import xbmcgui import xbmc cid = self.get_current_playlist() 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(39010), lang(30052), 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)) notifyH(lang(42001), lang(42004) + name, getImage('icon-error-256')) return False self.delete_cache(playlist_id) notifyH(lang(42001), (lang(42002) + "%s" + lang(42003)) % (name)) url = self.make_url(nt=Flag.USERPLAYLISTS, mode=Mode.VIEW, nm='', nid='') executeBuiltin(containerUpdate(url, True)) return False
def gui_remove(self): qnt, qid = int(self.get_parameter('qnt')), self.get_parameter('qid') node = getNode(qnt, {'nid': qid}) ret = None if qnt & Flag.TRACK == Flag.TRACK: ret = self.del_track(node.nid) elif qnt & Flag.ALBUM == Flag.ALBUM: ret = self.del_album(node.nid) elif qnt & Flag.ARTIST == Flag.ARTIST: ret = self.del_artist(node.nid) else: raise Qerror(who=self, what='invalid_node_type', additional=self.nt) if not ret: notifyH(dialogHeading, 'Cannot remove item: %s' % (node.get_label())) return False notifyH(dialogHeading, 'Item successfully removed: %s' % (node.get_label())) url = self.make_url(nt=self.nt, nid='', nm='') executeBuiltin(containerUpdate(url, True)) return True
def gui_scan(self): '''Scanning directory specified in query parameter ''' query = self.get_parameter('query', unQuote=True) print "Scanning folder: %s" % (query) executeBuiltin('XBMC.UpdateLibrary("music", "%s")' % (query))