Beispiel #1
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
Beispiel #2
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
Beispiel #3
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
Beispiel #4
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
Beispiel #5
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
Beispiel #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
Beispiel #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 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
Beispiel #8
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
Beispiel #9
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
Beispiel #10
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
Beispiel #11
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
Beispiel #12
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
Beispiel #13
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
Beispiel #14
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']
Beispiel #15
0
 def gui_create(self):
     query = self.get_parameter('query', unQuote=True)
     if not query:
         from qobuz.gui.util import Keyboard
         k = Keyboard('', lang(30182))
         k.doModal()
         if not k.isConfirmed():
             warn(self, 'Creating playlist aborted')
             return None
         query = k.getText()
     ret = self.create(query)
     if not ret:
         warn(self, "Cannot create playlist named '" + query + "'")
         return None
     self.set_as_current(ret['id'])
     self.delete_cache(ret['id'])
     url = self.make_url(nt=Flag.USERPLAYLISTS)
     executeBuiltin(containerUpdate(url))
     return ret['id']
Beispiel #16
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
Beispiel #17
0
 def gui_remove(self):
     qnt, qid = int(self.get_parameter('qnt')), self.get_parameter('qid')
     node = getNode(qnt, {'nid': qid})
     ret = None
     if qnt & Flag.TRACK == Flag.TRACK:
         ret = self.del_track(node.nid)
     elif qnt & Flag.ALBUM == Flag.ALBUM:
         ret = self.del_album(node.nid)
     elif qnt & Flag.ARTIST == Flag.ARTIST:
         ret = self.del_artist(node.nid)
     else:
         raise exception.InvalidNodeType(self.nt)
     if not ret:
         notifyH(dialogHeading,
                 'Cannot remove item: %s' % (node.get_label()))
         return False
     notifyH(dialogHeading,
             'Item successfully removed: %s' % (node.get_label()))
     url = self.make_url(nt=self.nt, nid=None, nm=None)
     executeBuiltin(containerUpdate(url, True))
     return True
Beispiel #18
0
 def gui_remove(self, playlist_id=None):
     if not playlist_id:
         playlist_id = self.nid
     if not playlist_id:
         notify_error(dialogHeading,
                      'Invalid playlist %s' % (str(playlist_id)))
         return False
     login = getSetting('username')
     offset = 0
     limit = getSetting('pagination_limit')
     data = api.get('/playlist/get', playlist_id=playlist_id, limit=limit,
                    offset=offset)
     name = ''
     if 'name' in data:
         name = data['name']
     ok = xbmcgui.Dialog().yesno(lang(30166),
                                 lang(30054),
                                 color('FFFF0000', name))
     if not ok:
         info(self, "Deleting playlist aborted...")
         return False
     res = False
     if data['owner']['name'] == login:
         info(self, "Deleting playlist: " + str(playlist_id))
         res = api.playlist_delete(playlist_id=playlist_id)
     else:
         info(self, 'Unsuscribe playlist' + str(playlist_id))
         res = api.playlist_unsubscribe(playlist_id=playlist_id)
     if not res:
         warn(self, "Cannot delete playlist with id " + str(playlist_id))
         notify_error(lang(30183), lang(30186) + name)
         return False
     self.delete_cache(playlist_id)
     notify_log(lang(30183), (lang(30184) + "%s" + lang(30185)) % (name))
     url = self.make_url(nt=Flag.USERPLAYLISTS, mode=Mode.VIEW, nm='',
                         nid='')
     executeBuiltin(containerUpdate(url, True))
     return False
Beispiel #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
Beispiel #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
Beispiel #21
0
 def gui_scan(self):
     '''Scanning directory specified in query parameter
     '''
     executeBuiltin('UpdateLibrary("music", "%s")' % (self.get_parameter(
         'query', to='unquote')))
from qobuz.gui.util import containerUpdate, executeBuiltin
from qobuz.node import getNode, Flag
from qobuz.plugin import Plugin
from qobuz.util.converter import converter

if __name__ == '__main__':
    app = Application(Plugin('plugin.audio.qobuz'))
    app.bootstrap.init_app()
    tag = sys.listitem.getMusicInfoTag()
    query = converter.quote(tag.getArtist())
    node = getNode(Flag.SEARCH,
                   parameters={
                       'search-type': 'artists',
                       'query': query
                   })
    node.data = node.fetch()
    if node.data is None:
        sys.exit(0)
    query = tag.getArtist().lower().strip()
    artist = None
    for _artist in node.data['artists']['items']:
        name = _artist['name'].lower().strip()
        if name == query:
            artist = _artist
            break
    if artist is None:
        sys.exit(0)
    node = getNode(Flag.ALBUMS_BY_ARTIST, parameters={'nid': artist['id']})
    url = 'plugin://plugin.audio.qobuz/%s' % node.make_url()
    executeBuiltin(containerUpdate(url, True))
Beispiel #23
0
 def gui_scan(self):
     """Scanning directory specified in query parameter
     """
     query = self.get_parameter('query', unQuote=True)
     executeBuiltin('XBMC.UpdateLibrary("music", "%s")' % (query))
from qobuz.node import getNode, Flag
from qobuz.plugin import Plugin
from qobuz.util.converter import converter

if __name__ == '__main__':
    app = Application(Plugin('plugin.audio.qobuz'))
    app.bootstrap.init_app()
    tag = sys.listitem.getMusicInfoTag()
    query = converter.quote(tag.getArtist())
    node = getNode(
        Flag.SEARCH, parameters={'search-type': 'artists',
                                 'query': query})
    node.data = node.fetch()
    if node.data is None:
        sys.exit(0)
    query = tag.getArtist().lower().strip()
    artist = None
    for _artist in node.data['artists']['items']:
        name = _artist['name'].lower().strip()
        if name == query:
            artist = _artist
            break
    if artist is None:
        sys.exit(0)
    node = getNode(Flag.SIMILAR_ARTIST, parameters={'nid': int(artist['id'])})
    node.data = node.fetch()
    if node.data is None or node.count() == 0:
        sys.exit(0)
    url = 'plugin://plugin.audio.qobuz/%s' % node.make_url()
    executeBuiltin(containerUpdate(url, False))
Beispiel #25
0
from qobuz.util.converter import converter

if __name__ == '__main__':
    app = Application(Plugin('plugin.audio.qobuz'))
    app.bootstrap.init_app()
    tag = sys.listitem.getMusicInfoTag()
    query = converter.quote(tag.getArtist())
    node = getNode(Flag.SEARCH,
                   parameters={
                       'search-type': 'artists',
                       'query': query
                   })
    node.data = node.fetch()
    if node.data is None:
        sys.exit(0)
    query = tag.getArtist().lower().strip()
    artist = None
    for _artist in node.data['artists']['items']:
        name = _artist['name'].lower().strip()
        if name == query:
            artist = _artist
            break
    if artist is None:
        sys.exit(0)
    node = getNode(Flag.SIMILAR_ARTIST, parameters={'nid': int(artist['id'])})
    node.data = node.fetch()
    if node.data is None or node.count() == 0:
        sys.exit(0)
    url = 'plugin://plugin.audio.qobuz/%s' % node.make_url()
    executeBuiltin(containerUpdate(url, False))
from qobuz.application import Application
from qobuz.gui.util import containerUpdate, executeBuiltin
from qobuz.node import getNode, Flag
from qobuz.plugin import Plugin
from qobuz.util.converter import converter

if __name__ == '__main__':
    app = Application(Plugin('plugin.audio.qobuz'))
    app.bootstrap.init_app()
    tag = sys.listitem.getMusicInfoTag()
    query = converter.quote(tag.getArtist())
    node = getNode(
        Flag.SEARCH, parameters={'search-type': 'artists',
                                 'query': query})
    node.data = node.fetch()
    if node.data is None:
        sys.exit(0)
    query = tag.getArtist().lower().strip()
    artist = None
    for _artist in node.data['artists']['items']:
        name = _artist['name'].lower().strip()
        if name == query:
            artist = _artist
            break
    if artist is None:
        sys.exit(0)
    node = getNode(Flag.ALBUMS_BY_ARTIST, parameters={'nid': artist['id']})
    url = 'plugin://plugin.audio.qobuz/%s' % node.make_url()
    executeBuiltin(containerUpdate(url, True))