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 'friends' not in friends: notifyH('Qobuz', 'You don\'t have friend', 'icon-error-256') logger.warn('No friends in user/player_settings') return False friends = friends['friends'] if name not in friends: notifyH('Qobuz', 'You\'re not friend with %s' % name, 'icon-error-256') logger.warn('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): friendpl = api.get('/playlist/getUserPlaylists', username=name, type='last-created') if not friendpl: return False data = api.get('/user/login', username=user.username, password=user.password) if not data: return False if data['user']['login'] == name: return False friends = data['user']['player_settings'] if 'friends' not in friends: friends = [] else: friends = friends['friends'] if name in friends: return False friends.append(name) newdata = {'friends': friends} if not api.user_update(player_settings=json.dumps(newdata)): return False self.delete_cache() 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} if not api.user_update(player_settings=json.dumps(newdata)): return False executeBuiltin(containerRefresh()) return True