예제 #1
0
 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)
예제 #2
0
 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())
예제 #3
0
 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
예제 #4
0
 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())
예제 #5
0
 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
예제 #6
0
 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
예제 #7
0
 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
예제 #8
0
    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
예제 #9
0
    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
예제 #10
0
 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')
예제 #11
0
 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')
예제 #12
0
 def _get_node_storage_filename(self):
     return u'userdata-{user_id}-favorite-{nid}.local'.format(
         user_id=user.get_id(), nid=self.nid)
예제 #13
0
 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')
예제 #14
0
 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')
예제 #15
0
 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')
예제 #16
0
 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')