def fetch(self, options=None): if self.search_type is None: return {} if self.search_type != 'all': return api.get('/favorite/getUserFavorites', user_id=user.get_id(), type=self.search_type, limit=self.limit, offset=self.offset) return api.get('/favorite/getUserFavorites', user_id=user.get_id(), limit=self.limit, offset=self.offset)
def fetch(self, options=None): if self.search_type is None: return {} return api.get('/purchase/getUserPurchases', limit=self.limit, offset=self.offset, user_id=user.get_id())
def get_user_storage(self): if self.user_storage is not None: return self.user_storage filename = os.path.join(cache.base_path, 'user-%s.local' % str(current_user.get_id())) self.user_storage = Storage(filename) return self.user_storage
def _delete_cache(self): keys = [cache.make_key( '/favorite/getUserFavorites', user_id=user.get_id(), limit=self.limit, offset=self.offset)] for kind in ['artists', 'albums', 'tracks']: keys.append( cache.make_key( '/favorite/getUserFavorites', user_id=user.get_id(), limit=self.limit, type=kind, offset=self.offset)) ret = False for key in keys: if cache.delete(key): ret = True return ret
def __getFileUrl(self): if self._intent is None: self._intent = user.stream_format(track=self) format_id, intent, _description = self._intent data = api.get('/track/getFileUrl', format_id=format_id, track_id=self.nid, user_id=user.get_id(), intent=intent) if not data: logger.warn('Cannot get stream type for track (network problem?)') return None return data
def populate(self, options=None): user_data = api.get('/user/login', username=user.username, password=user.password) if 'user' not in user_data: return False friend_data = user_data['user']['player_settings']['friends'] if self.name is not None: data = api.get('/playlist/getUserPlaylists', username=self.name, limit=self.limit, offset=self.offset, type='last-created') else: data = api.get('/playlist/getUserPlaylists', user_id=user.get_id(), limit=self.limit, offset=self.offset, type='last-created') if data is None: logger.warn('No friend data') return False friend_list = {} def add_name(name): if name in friend_list: return None if name == user_data['user']['login']: return None if name == self.name: return None friend_list[name] = 1 node = getNode(Flag.FRIEND, {'query': str(name)}) node.label = 'Friend / %s' % node.label self.add_child(node) return node for item in data['playlists']['items']: add_name(item['owner']['name']) for name in friend_data: add_name(name) return True
def playlist_getUserPlaylists(self, **ka): self._check_ka(ka, ['type'], ['user_id', 'username', 'order', 'offset', 'limit']) if 'user_id' not in ka and 'username' not in ka: ka['user_id'] = user.get_id() return self._api_request(ka, '/playlist/getUserPlaylists')
def track_resportStreamingStart(self, track_id): # Any use of the API implies your full acceptance # of the General Terms and Conditions # (http://www.qobuz.com/apps/api/QobuzAPI-TermsofUse.pdf) params = {'user_id': user.get_id(), 'track_id': track_id} return self._api_request(params, '/track/reportStreamingStart')
def _get_node_storage_filename(self): return u'userdata-{user_id}-favorite-{nid}.local'.format( user_id=user.get_id(), nid=self.nid)
def fetch(self, options=None): return api.get('/playlist/getUserPlaylists', limit=self._get_limit(), offset=self.offset, user_id=user.get_id(), type='last-created')