Exemplo n.º 1
0
 def bootstrap_registry(cls):
     from qobuz.api import api
     if not api.login(config.app.registry.get('username'),
                      config.app.registry.get('password')):
         if api.status_code == 503:
             dialogServiceTemporarilyUnavailable()
         else:
             dialogLoginFailure()
         containerRefresh()
         raise exception.InvalidLogin(None)
Exemplo n.º 2
0
 def bootstrap_registry(cls):
     from qobuz.api import api
     if not api.login(
             config.app.registry.get('username'),
             config.app.registry.get('password')):
         if api.status_code == 503:
             dialogServiceTemporarilyUnavailable()
         else:
             dialogLoginFailure()
         containerRefresh()
         raise exception.InvalidLogin(None)
Exemplo n.º 3
0
 def bootstrap_registry(self):
     from qobuz.api import api
     cache.base_path = config.path.cache
     api.stream_format = 6 if getSetting('streamtype') == 'flac' else 5
     if not api.login(getSetting('username'), getSetting('password')):
         if api.status_code == 503:
             dialogServiceTemporarilyUnavailable()
         else:
             dialogLoginFailure()
         #@TODO sys.exit killing XBMC? FRODO BUG ?
         # sys.exit(1)
         containerRefresh()
         raise QobuzXbmcError(
             who=self, what='invalid_login', additional=None)
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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 qobuz.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(30080))
     k.doModal()
     if not k.isConfirmed():
         return False
     newname = k.getText()
     newname = newname.strip()
     if not newname:
         notify_error(dialogHeading, "Don't u call ure child something?")
         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)
     notify_log(lang(30080), (u"%s: %s") % (lang(30165), currentname))
     executeBuiltin(containerRefresh())
     return True
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
 def gui_rename(self, playlist_id=None):
     if not playlist_id:
         playlist_id = self.nid
     if not playlist_id:
         logger.warn('Can\'t rename playlist without id')
         return False
     node = getNode(Flag.PLAYLIST, parameters={'nid': playlist_id})
     data = node.fetch()
     if not data:
         logger.warn('Something went wrong while renaming playlist')
         return False
     self.data = data
     currentname = self.get_name()
     newname = ask(currentname, lang(30080))
     if newname is None:
         return False
     if newname == '':
         notify_error(dialogHeading, 'Don\'t u call ure child something?')
         return False
     if newname == currentname:
         return True
     res = api.playlist_update(playlist_id=playlist_id, name=newname)
     if not res:
         logger.warn('Cannot rename playlist with name %s' % newname)
         return False
     self.delete_cache(playlist_id)
     notify_log(lang(30080), u'%s: %s' % (lang(30165), currentname))
     executeBuiltin(containerRefresh())
     return True
Exemplo n.º 11
0
 def gui_remove(self, playlist_id=None):
     playlist_id = self._get_playlist_id(playlist_id=playlist_id)
     if not playlist_id:
         notify_error(dialogHeading,
                      'Invalid playlist %s' % (str(playlist_id)))
         return False
     data = api.get('/playlist/get',
                    playlist_id=playlist_id,
                    limit=self.limit,
                    offset=self.offset)
     if data is None:
         logger.error('Cannot get playlist with id %s', playlist_id)
         return False
     name = ''
     if 'name' in data:
         name = data['name']
     ok = xbmcgui.Dialog().yesno(
         lang(30166), lang(30054), color('FFFF0000', name))
     if not ok:
         return False
     if data['owner']['name'] == user.username:
         res = api.playlist_delete(playlist_id=playlist_id)
     else:
         res = api.playlist_unsubscribe(playlist_id=playlist_id)
     if not res:
         logger.warn('Cannot delete playlist with id ' + str(playlist_id))
         notify_error(lang(30183), lang(30186) + name)
         return False
     self.delete_cache(playlist_id)
     executeBuiltin(containerRefresh())
     notify_log(lang(30183), (lang(30184) + ' %s ' + lang(30185)) % name)
     return True
Exemplo n.º 12
0
 def gui_add_to_current(self):
     cid = self.get_current_playlist()
     qnt = int(self.get_parameter('qnt'))
     qid = self.get_parameter('qid')
     nodes = []
     if qnt & Flag.SEARCH == Flag.SEARCH:
         self.del_parameter('query')
     if qnt & Flag.TRACK == Flag.TRACK:
         node = getNode(qnt, parameters={'nid': qid})
         node.data = node.fetch()
         nodes.append(node)
     else:
         render = renderer(
             qnt,
             parameters=self.parameters,
             depth=-1,
             whiteFlag=Flag.TRACK,
             asList=True)
         render.run()
         nodes = render.nodes
     ret = xbmcgui.Dialog().select('Add to current playlist',
                                   [node.get_label() for node in nodes])
     if ret == -1:
         return False
     ret = self._add_tracks(cid, nodes)
     if not ret:
         notify_warn('Qobuz', 'Failed to add tracks')
         return False
     self.delete_cache(cid)
     notify_log('Qobuz / Tracks added', '%s added' % (len(nodes)))
     executeBuiltin(containerRefresh())
     return True
Exemplo n.º 13
0
 def gui_remove_track(self):
     qid = self.get_parameter('qid')
     if not self.remove_tracks(qid):
         notify_error(dialogHeading, 'Cannot remove track!')
         return False
     self.delete_cache(self.nid)
     notify_log(dialogHeading, 'Track removed from playlist')
     executeBuiltin(containerRefresh())
     return True
Exemplo n.º 14
0
 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):
         notify_error(dialogHeading, 'Cannot remove track!')
         return False
     self.delete_cache(self.nid)
     notify_log(dialogHeading, 'Track removed from playlist')
     executeBuiltin(containerRefresh())
     return True
Exemplo n.º 15
0
 def set_as_current(self, playlist_id=None):
     if playlist_id is None:
         playlist_id = self.nid
     if playlist_id is None:
         logger.warn('Cannot set current playlist without id')
         return False
     userdata = self.get_user_storage()
     userdata['current_playlist'] = int(playlist_id)
     if not userdata.sync():
         return False
     executeBuiltin(containerRefresh())
     return True
Exemplo n.º 16
0
 def toggle_privacy(self):
     if self.data is None:
         self.data = self.fetch()
     privacy = not self.get_property('is_public', to='bool')
     res = api.playlist_update(
         playlist_id=self.nid, is_public=str(privacy).lower())
     if res is None:
         notify_error('Qobuz', 'Cannot toggle privacy')
         return False
     self.delete_cache(self.nid)
     notify_log(dialogHeading, 'Privacy changed public: %s' % privacy)
     executeBuiltin(containerRefresh())
     return True
Exemplo n.º 17
0
 def gui_create(self):
     query = self.get_parameter('query', to='unquote')
     if not query:
         query = ask('', lang(30182))
         if query is None:
             logger.warn('Creating playlist aborted')
             return None
         if query == '':
             logger.warn('Cannot create playlist without name')
             return None
     ret = self.create(query)
     if not ret:
         logger.warn('Cannot create playlist named ' ' + query + ' '')
         return None
     self.set_as_current(ret['id'])
     self.delete_cache(ret['id'])
     executeBuiltin(containerRefresh())
     return ret['id']
Exemplo n.º 18
0
 def gui_add_as_new(self, _=None):
     nodes = []
     qnt = int(self.get_parameter('qnt'))
     qid = self.get_parameter('qid')
     name = self.get_parameter('query', to='unquote', default=None)
     if qnt & Flag.SEARCH:
         self.del_parameter('query')
     if qnt & Flag.TRACK == Flag.TRACK:
         node = getNode(qnt, parameters={'nid': qid})
         node.data = node.fetch()
         nodes.append(node)
     else:
         render = renderer(
             qnt,
             parameters=self.parameters,
             depth=-1,
             whiteFlag=Flag.TRACK,
             asList=True)
         render.run()
         nodes = render.nodes
     if len(nodes) == 0:
         return False
     if name is None:
         name = ask('Playlist name? (i8n)')
         if name is None:
             return False
     ret = xbmcgui.Dialog().select('Create playlist %s' % name,
                                   [node.get_label() for node in nodes])
     if ret == -1:
         return False
     playlist = self.create(name)
     if not playlist:
         notify_error('Qobuz', 'Playlist creationg failed')
         logger.warn('Cannot create playlist...')
         return False
     if not self._add_tracks(playlist['id'], nodes):
         notify_error('Qobuz / Cannot add tracks', '%s' % name)
         return False
     self.delete_cache(playlist['id'])
     notify_log('Qobuz / Playlist added', '[%s] %s' % (len(nodes), name))
     executeBuiltin(containerRefresh())
     return True
Exemplo n.º 19
0
    def gui_add_as_new(self, name=None):
        nodes = []
        qnt = int(self.get_parameter('qnt'))
        qid = self.get_parameter('qid')
        if qnt & Flag.SEARCH:
            self.del_parameter('query')
        if qnt & Flag.TRACK == Flag.TRACK:
            node = getNode(qnt, {'nid': qid})
            node.fetch(None, None, None, Flag.NONE)
            nodes.append(node)
        else:
            render = renderer(qnt, self.parameters)
            render.depth = -1
            render.whiteFlag = Flag.TRACK
            render.asList = True
            render.run()
            nodes = render.nodes

        if name is None:
            name = self.get_parameter('query', unQuote=True, default=None) \
                or self.get_label()
        ret = xbmcgui.Dialog().select('Create playlist %s' % (name), [
            node.get_label() for node in nodes
        ])
        if ret == -1:
            return False
        playlist = self.create(name)
        if not playlist:
            notify_error('Qobuz', 'Playlist creationg failed')
            warn(self, "Cannot create playlist...")
            return False
        if not self._add_tracks(playlist['id'], nodes):
            notify_error('Qobuz / Cannot add tracks', "%s" % (name))
            return False
        self.delete_cache(playlist['id'])
        notify_log('Qobuz / Playlist added', '[%s] %s' % (len(nodes), name))
        executeBuiltin(containerRefresh())
        return True
Exemplo n.º 20
0
 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