def bootstrap_registry(self): from api import api cache.base_path = qobuz.path.cache api.stream_format = 6 if getSetting('streamtype') == 'flac' else 5 if not api.login(getSetting('username'), getSetting('password')): dialogLoginFailure() #@TODO sys.exit killing XBMC? FRODO BUG ? # sys.exit(1) containerRefresh() raise QobuzXbmcError( who=self, what='invalid_login', additional=None)
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 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 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