def attach_context_menu(node, item, menu):
    isOwner = True
    cmd = containerUpdate(
        node.make_url(nt=Flag.USERPLAYLISTS, id='', mode=Mode.VIEW))
    menu.add(path='playlist', pos=1, label='Playlist', cmd=cmd, mode=Mode.VIEW)
    if user.username != node.get_property('owner/name'):
        isOwner = False
    if isOwner:
        url = node.make_url(nt=Flag.PLAYLIST,
                            mode=Mode.VIEW,
                            nm='set_as_current')
        menu.add(path='playlist/set_as_current',
                 label=color(lang(30163)),
                 cmd=runPlugin(url))
        url = node.make_url(nt=Flag.PLAYLIST, nm='gui_rename')
        menu.add(path='playlist/rename',
                 label=color(lang(30165)),
                 cmd=runPlugin(url))
        url = node.make_url(nt=Flag.PLAYLIST,
                            mode=Mode.VIEW,
                            nm='toggle_privacy')
        menu.add(path='playlist/toggle_privacy',
                 post=2,
                 label=color('Toggle privacy'),
                 cmd=containerUpdate(url))
    elif node.parent and node.parent.nt & (Flag.ALL ^ Flag.USERPLAYLISTS):
        url = node.make_url(nt=Flag.PLAYLIST, nm='subscribe')
        menu.add(path='playlist/subscribe',
                 label=color(lang(30168)),
                 cmd=runPlugin(url))
    url = node.make_url(nt=Flag.PLAYLIST, nm='gui_remove')
    menu.add(path='playlist/remove',
             label=color(lang(30166)),
             cmd=runPlugin(url),
             color=theme.get('item/caution/color'))
Exemple #2
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
Exemple #3
0
    def attach_context_menu(self, item, menu):
        colorCaution = getSetting('item_caution_color')
        login = getSetting('username')
        isOwner = True
        cmd = containerUpdate(self.make_url(nt=Flag.USERPLAYLISTS,
                                            id='', mode=Mode.VIEW))
        menu.add(path='playlist', pos=1,
                 label="Playlist", cmd=cmd, mode=Mode.VIEW)
        if login != self.get_property('owner/name'):
            isOwner = False

        if isOwner:
            url = self.make_url(nt=Flag.PLAYLIST, mode=Mode.VIEW,
                                nm='set_as_current')
            menu.add(path='playlist/set_as_current', label=lang(30163),
                     cmd=containerUpdate(url))

            url = self.make_url(nt=Flag.PLAYLIST, nm='gui_rename')
            menu.add(path='playlist/rename', label=lang(30165),
                     cmd=runPlugin(url))

        else:
            url = self.make_url(nt=Flag.PLAYLIST, nm='subscribe')
            menu.add(path='playlist/subscribe', label=lang(30168),
                     cmd=runPlugin(url))

        url = self.make_url(nt=Flag.PLAYLIST, nm='gui_remove')
        menu.add(path='playlist/remove', label=lang(30166),
                 cmd=runPlugin(url), color=colorCaution)
        super(Node_playlist, self).attach_context_menu(item, menu)
Exemple #4
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
Exemple #5
0
 def subscribe(self):
     if api.playlist_subscribe(playlist_id=self.nid):
         notify_log(lang(30183), lang(30187))
         self.delete_cache(self.nid)
         return True
     else:
         return False
 def gui_add_tracks(self):
     qnt, qid = int(self.get_parameter('qnt')), self.get_parameter('qid')
     nodes = self.list_tracks(qnt, qid)
     if len(nodes) == 0:
         notifyH(dialogHeading, lang(3600))
         return False
     label = lang(30145)
     from qobuz.gui.dialog import DialogSelect
     for node in nodes:
         try:
             label = node.get_label()
             if label is not None:
                 label = label.encode('utf8', errors='ignore')
         except Exception as e:
             logger.error(u'Error: %s', e)
     dialog = DialogSelect(
         label=label, items=[node.get_label() for node in nodes])
     if dialog.open() == -1:
         return False
     track_ids = ','.join([str(node.nid) for node in nodes])
     if not self.add_tracks(track_ids):
         notifyH(dialogHeading, 'Cannot add track(s) to favorite')
         return False
     self._delete_cache()
     notifyH(dialogHeading, 'Track(s) added to favorite')
     return True
 def get_label(self, default=None):
     if self.label is not None:
         return self.label
     if self.search_type is None:
         return lang(30081)
     elif self.search_type == 'all':
         return lang(30098)
     return self.search_type.capitalize()
Exemple #8
0
 def __init__(self, parent=None, parameters=None):
     super(Node_friends, self).__init__(parent, parameters)
     self.nt = Flag.FRIENDS
     self.name = self.get_parameter('query')
     self.image = getImage('artist')
     self.label = str(self.name) + lang(30179) if (
         self.name) else lang(30180)
     self.url = None
     self.is_folder = True
     self.content_type = 'artists'
Exemple #9
0
 def __init__(self, parent=None, parameters=None, data=None):
     parameters = {} if parameters is None else parameters
     super(Node_friends, self).__init__(
         parent=parent, parameters=parameters, data=data)
     self.nt = Flag.FRIENDS
     self.name = self.get_parameter('query')
     self.image = getImage('artist')
     self.label = str(self.name) + lang(30179) if (
         self.name) else lang(30180)
     self.url = None
     self.content_type = 'songs'
Exemple #10
0
 def __init__(self, parent=None, parameters=None):
     super(Node_purchase, self).__init__(parent, parameters)
     self.nt = Flag.PURCHASE
     self.content_type = 'albums'
     self.image = getImage('album')
     self.search_type = self.get_parameter('search-type') or 'all'
     if self.search_type == 'all':
         self.label = '%s - %s' % (lang(30101), lang(30098))
     else:
         self.label = '%s - %s' % (lang(30101),
                                   self.search_type.capitalize())
Exemple #11
0
 def __init__(self, parent=None, parameters=None, data=None):
     parameters = {} if parameters is None else parameters
     super(Node_friends, self).__init__(parent=parent,
                                        parameters=parameters,
                                        data=data)
     self.nt = Flag.FRIENDS
     self.name = self.get_parameter('query')
     self.image = getImage('artist')
     self.label = str(self.name) + lang(30179) if (
         self.name) else lang(30180)
     self.url = None
     self.content_type = 'songs'
Exemple #12
0
 def attach_context_menu(self, item, menu):
     label = self.get_label()
     url = self.make_url()
     menu.add(path='friend', label=label, cmd=containerUpdate(url))
     url = self.make_url(nt=Flag.FRIEND, nm='gui_create', nid=self.nid)
     menu.add(path='friend/add', label=lang(30181), cmd=runPlugin(url))
     super(Node_friends, self).attach_context_menu(item, menu)
Exemple #13
0
 def __init__(self, root, nodeList=[], **ka):
     self.nodes = []
     self.label = "Qobuz Progress / "
     self.root = root
     self.asList = False
     self.handle = None
     self.put_item_ok = True
     withProgress = True
     if 'withProgress' in ka:
         if ka['withProgress']:
             withProgress = True
         else:
             withProgress = False
     self.Progress = Progress(withProgress)
     self.total_put = 0
     self.started_on = time.time()
     self.Progress.create(self.label + root.get_label())
     self.update({'count': 0, 'total': 100}, lang(30169))
     self.line1 = ''
     self.line2 = ''
     self.line3 = ''
     self.percent = 0
     self.content_type = 'files'
     self.nodes = nodeList
     self.replaceItems = False
     self.asLocalURL = False
 def __init__(self, parent=None, parameters=None):
     super(Node_public_playlists, self).__init__(parent, parameters)
     self.nt = Flag.PUBLIC_PLAYLISTS
     self.set_label(lang(30190))
     self.is_folder = True
     self.image = getImage("userplaylists")
     self.offset = self.get_parameter("offset") or 0
 def __init__(self, parent=None, parameters=None, data=None):
     parameters = {} if parameters is None else parameters
     super(Node_similar_artist, self).__init__(
         parent=parent, parameters=parameters, data=data)
     self.nt = Flag.SIMILAR_ARTIST
     self.content_type = 'artists'
     self.lang = lang(30156)
Exemple #16
0
 def __init__(self, parent=None, parameters=None):
     super(Node_recommendation, self).__init__(parent, parameters)
     self.nt = Flag.RECOMMENDATION
     self.genre_id = self.get_parameter('genre-id', default=None)
     self.genre_type = self.get_parameter('genre-type', default=None)
     self.set_label(lang(30084))
     self.image = getImage('album')
Exemple #17
0
 def attach_context_menu(self, item, menu):
     label = self.get_label()
     url = self.make_url()
     menu.add(path='friend', label=label, cmd=containerUpdate(url))
     url = self.make_url(nt=Flag.FRIEND, nm='gui_create', nid=self.nid)
     menu.add(path='friend/add', label=lang(30181), cmd=runPlugin(url))
     super(Node_friends, self).attach_context_menu(item, menu)
Exemple #18
0
 def __init__(self, parent=None, parameters=None):
     super(Node_genre, self).__init__(parent, parameters)
     self.nt = Flag.GENRE
     self.set_label(lang(30189))
     self.is_folder = True
     self.image = getImage('album')
     self.offset = self.get_parameter('offset') or 0
Exemple #19
0
 def gui_add_artists(self):
     qnt, qid = int(self.get_parameter('qnt')), self.get_parameter('qid')
     nodes = self.list_artists(qnt, qid)
     if not nodes:
         notifyH(dialogHeading, lang(30143))
         return False
     ret = xbmcgui.Dialog().select(
         lang(30146), [node.get_label() for node in nodes])
     if ret == -1:
         return False
     artist_ids = ','.join([str(node.nid) for node in nodes])
     if not self.add_artists(artist_ids):
         notifyH(dialogHeading, 'Cannot add artist(s) to favorite')
         return False
     self._delete_cache()
     notifyH(dialogHeading, 'Artist(s) added to favorite')
     return True
Exemple #20
0
 def __init__(self, parent=None, parameters=None, data=None):
     parameters = {} if parameters is None else parameters
     super(Node_similar_artist, self).__init__(parent=parent,
                                               parameters=parameters,
                                               data=data)
     self.nt = Flag.SIMILAR_ARTIST
     self.content_type = 'artists'
     self.lang = lang(30156)
Exemple #21
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
Exemple #22
0
 def get_label(self, default=None):
     if self.search_type is None:
         return lang(30022)
     query = self.get_parameter('query', to='unquote')
     if query is not None:
         return 'search %s: %s [%s/%s]' % (self.search_type,
                                           self.get_parameter('query'),
                                           self.offset, self.limit)
     return data_search_type[self.search_type]['label']
 def __init__(self, parent=None, parameters=None, data=None):
     parameters = {} if parameters is None else parameters
     super(Node_recommendation, self).__init__(
         parent=parent, parameters=parameters, data=data)
     self.nt = Flag.RECOMMENDATION
     self.genre_id = self.get_parameter('genre-id', default=None)
     self.genre_type = self.get_parameter('genre-type', default=None)
     self.set_label(lang(30084))
     self.image = getImage('album')
     self.content_type = 'albums'
 def __init__(self, parent=None, parameters=None, data=None):
     parameters = {} if parameters is None else parameters
     super(Node_user_playlists, self).__init__(
         parent=parent, parameters=parameters, data=data)
     self.nt = Flag.USERPLAYLISTS
     self.label = lang(30021)
     self.image = getImage('userplaylists')
     self.content_type = 'albums'
     self.display_product_cover = config.app.registry.get(
         'userplaylists_display_cover', to='bool')
Exemple #25
0
 def gui_add_tracks(self):
     qnt, qid = int(self.get_parameter('qnt')), self.get_parameter('qid')
     nodes = self.list_tracks(qnt, qid)
     if len(nodes) == 0:
         # ERROR: Missing translation for 3600
         notifyH(dialogHeading, lang(3600))
         return False
     ret = xbmcgui.Dialog().select(lang(30145), [
         node.get_label() for node in nodes
     ])
     if ret == -1:
         return False
     track_ids = ','.join([str(node.nid) for node in nodes])
     if not self.add_tracks(track_ids):
         notifyH(dialogHeading, 'Cannot add track(s) to favorite')
         return False
     self._delete_cache()
     notifyH(dialogHeading, 'Track(s) added to favorite')
     return True
Exemple #26
0
 def __init__(self, parent=None, parameters=None, data=None):
     parameters = {} if parameters is None else parameters
     super(Node_user_playlists, self).__init__(parent=parent,
                                               parameters=parameters,
                                               data=data)
     self.nt = Flag.USERPLAYLISTS
     self.label = lang(30021)
     self.image = getImage('userplaylists')
     self.content_type = 'albums'
     self.display_product_cover = config.app.registry.get(
         'userplaylists_display_cover', to='bool')
 def __init__(self, parent=None, parameters=None, data=None):
     parameters = {} if parameters is None else parameters
     super(Node_public_playlists, self).__init__(
         parent=parent, parameters=parameters, data=data)
     self.nt = Flag.PUBLIC_PLAYLISTS
     self.image = getImage('userplaylists')
     self.content_type = 'albums'
     self.type = self.get_parameter('type', default='last-created')
     if self.type not in featured_type:
         raise RuntimeError('InvalidFeaturedType: {}'.format(self.type))
     self.label = '%s (%s)' % (lang(30190), self.type)
Exemple #28
0
 def set_search_type(self, st):
     if st == 'artists':
         self.label = lang(30017)
         self.content_type = 'files'
         self.image = getImage('artist')
     elif st == 'albums':
         self.label = lang(30016)
         self.content_type = 'albums'
         self.image = getImage('album')
     elif st == 'tracks':
         self.label = lang(30015)
         self.content_type = 'songs'
         self.image = getImage('song')
     elif st == 'collection':
         self.label = lang(30018)
         self.content_type = 'files'
         self.image = getImage('song')
     else:
         raise QobuzXbmcError(who=self, what='invalid_type', additional=st)
     self._search_type = st
Exemple #29
0
 def __init__(self, parent=None, parameters=None, data=None):
     parameters = {} if parameters is None else parameters
     super(Node_recommendation, self).__init__(parent=parent,
                                               parameters=parameters,
                                               data=data)
     self.nt = Flag.RECOMMENDATION
     self.genre_id = self.get_parameter('genre-id', default=None)
     self.genre_type = self.get_parameter('genre-type', default=None)
     self.set_label(lang(30084))
     self.image = getImage('album')
     self.content_type = 'albums'
Exemple #30
0
 def end_of_directory(self, forceStatus=None):
     """This will tell xbmc that our plugin has finished, and that
     he can display our items
     """
     success = True
     if forceStatus != None:
         success = forceStatus
     if not self.put_item_ok or (self.total_put == 0):
         success = False
     if not self.asList:
         xbmcplugin.setContent(
             handle=self.handle,
             content=self.content_type)
         xbmcplugin.endOfDirectory(handle=self.handle,
                                   succeeded=success,
                                   updateListing=False,
                                   cacheToDisc=success)
     self.update({'count': 100, 'total': 100}, lang(30172),
                 "%s : %s items" % (lang(30171), str(self.total_put)))
     self.close()
     return self.total_put
Exemple #31
0
 def __init__(self, parent=None, parameters=None, data=None):
     parameters = {} if parameters is None else parameters
     super(Node_public_playlists, self).__init__(parent=parent,
                                                 parameters=parameters,
                                                 data=data)
     self.nt = Flag.PUBLIC_PLAYLISTS
     self.image = getImage('userplaylists')
     self.content_type = 'albums'
     self.type = self.get_parameter('type', default='last-created')
     if self.type not in featured_type:
         raise RuntimeError('InvalidFeaturedType: {}'.format(self.type))
     self.label = '%s (%s)' % (lang(30190), self.type)
Exemple #32
0
 def __init__(self, parent=None, parameters=None):
     super(Node_user_playlists, self).__init__(parent, parameters)
     self.label = lang(30021)
     self.image = getImage('userplaylists')
     self.nt = Flag.USERPLAYLISTS
     self.content_type = 'files'
     display_by = self.get_parameter('display-by', default=None)
     if display_by is None:
         display_by = 'songs'
     self.set_display_by(display_by)
     display_cover = getSetting('userplaylists_display_cover', asBool=True)
     self.display_product_cover = display_cover
Exemple #33
0
    def __init__(self, parent=None, parameters=None):
        super(Node_favorite, self).__init__(parent, parameters)
        self.nt = Flag.FAVORITE

        self.name = lang(30073)
        self.image = getImage('favorites')
        self.method = self.get_parameter('nm')
        self.search_type = self.get_parameter('search-type')
        self.content_type = 'files'
        if self.search_type == 'all':
            self.search_type = None
        elif self.search_type == 'albums':
            self.content_type = 'albums'
        elif self.search_type == 'tracks':
            self.content_type = 'files'
        elif self.search_type == 'artists':
            self.content_type = 'artists'
        if self.search_type is None:
            self.label = '%s - %s' % (lang(30081), lang(30098))
        else:
            self.label = '%s - %s' % (lang(30081),
                                      self.search_type.capitalize())
Exemple #34
0
 def __init__(self, parent=None, parameters=None):
     super(Node_collection, self).__init__(parent, parameters)
     self.nt = Flag.COLLECTION
     self.url = None
     self.is_folder = True
     self.image = getImage('songs')
     self.search_type = self.get_parameter('search-type', default='tracks')
     self.query = self.get_parameter('query', unQuote=True)
     self.source = self.get_parameter('source')
     self.seen_artist = {}
     self.seen_album = {}
     self.seen_track = {}
     self.label = '%s - %s' % (lang(30194),  self.search_type.capitalize())
Exemple #35
0
    def attach_context_menu(self, item, menu):
        if self.parent and (self.parent.nt & Flag.PLAYLIST == Flag.PLAYLIST):
            colorCaution = getSetting('item_caution_color')
            url = self.parent.make_url(nt=Flag.PLAYLIST,
                                       id=self.parent.nid,
                                       qid=self.get_playlist_track_id(),
                                       nm='gui_remove_track',
                                       mode=Mode.VIEW)
            menu.add(path='playlist/remove',
                     label=lang(30075),
                     cmd=runPlugin(url), color=colorCaution)

        ''' Calling base class '''
        super(Node_track, self).attach_context_menu(item, menu)
Exemple #36
0
 def gui_create(self):
     name = self.get_parameter('query')
     if not name:
         from qobuz.gui.util import Keyboard
         kb = Keyboard('', str(lang(30181)))
         kb.doModal()
         name = ''
         if not kb.isConfirmed():
             return False
         name = kb.getText().strip()
     if not name:
         return False
     if not self.create(name):
         notifyH('Qobuz', 'Cannot add friend %s' % name)
         return False
     notifyH('Qobuz', 'Friend %s added' % name)
     return True
Exemple #37
0
 def gui_create(self):
     name = self.get_parameter('query')
     if not name:
         from qobuz.gui.util import Keyboard
         kb = Keyboard('', str(lang(30181)))
         kb.doModal()
         name = ''
         if not kb.isConfirmed():
             return False
         name = kb.getText().strip()
     if not name:
         return False
     if not self.create(name):
         notifyH('Qobuz', 'Cannot add friend %s' % name)
         return False
     notifyH('Qobuz', 'Friend %s added' % name)
     return True
Exemple #38
0
 def cache_remove(cls):
     '''GUI/Removing all cached data
     '''
     if not yesno(lang(30121), lang(30122)):
         logger.warn('Deleting cached data aborted')
         return False
     cleanfs_combined_covers()
     if clean_all(cache):
         notifyH(lang(30119), lang(30123))
     else:
         notifyH(lang(30119), lang(30120), getImage('icon-error-256'))
     return True
def attach_context_menu(node, item, menu):
    if node.parent and (node.parent.nt & Flag.PLAYLIST == Flag.PLAYLIST):
        url = node.parent.make_url(nt=Flag.PLAYLIST,
                                   nid=node.parent.nid,
                                   qid=node.get_playlist_track_id(),
                                   nm='gui_remove_track',
                                   mode=Mode.VIEW)
        menu.add(path='playlist/remove',
                 label=lang(30075),
                 cmd=runPlugin(url),
                 color=theme.get('item/caution/color'))
    label = node.get_album_label(default=None)
    if label is not None:
        label_id = node.get_album_label_id()
        url = node.make_url(nt=Flag.LABEL, nid=label_id, mode=Mode.VIEW)
        menu.add(path='label/view',
                 label='View label (i8n): %s' % label,
                 cmd=containerUpdate(url))
Exemple #40
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']
Exemple #41
0
    def play(self, track_id, params={}):
        """Playing track given a track id
        """
        track = getNode(Flag.TRACK, {'nid': track_id})
        if not track.fetch(None, 1, Flag.TRACK, Flag.NONE):
            warn(self, "Cannot get track data")
            return False
        if not track.is_playable():
            warn(self, "Cannot get streaming URL")
            return False
        if 'purchased' in params:
            track.parameters['purchased']= True
        item = track.makeListItem()
        track.item_add_playing_property(item)
        """Some tracks are not authorized for stream and a 60s sample is
        returned, in that case we overwrite the song duration
        """
        if track.is_sample():
            item.setInfo(
                'music', infoLabels={
                    'duration': 60,
                })
            """Don't warn for free account (all songs except purchases are 60s
            limited)
            """
            if not isFreeAccount():
                notify_warn("Qobuz", "Sample returned")
        xbmcgui.Window(10000).setProperty(keyTrackId, track_id)
        """Notify
        """
        if getSetting('notification_playingsong', asBool=True):
            notify_restriction(track)
            notifyH(lang(30132), track.get_label(), image=track.get_image())

        """We are called from playlist...
        """
        if config.app.handle == -1:
            super(QobuzPlayer, self).play(track.get_streaming_url(),
                                          item, False)
        else:
            setResolvedUrl(handle=config.app.handle,
                           succeeded=True,
                           listitem=item)
        return True
Exemple #42
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']
Exemple #43
0
    def play(self, track_id, params=None):
        """ Playing track given a track id """
        params = {} if params is None else params
        track = getNode(Flag.TRACK, {'nid': track_id})
        data = track.fetch(helper.TreeTraverseOpts(
            lvl=1,
            whiteFlag=Flag.TRACK,
            blackFlag=Flag.NONE))
        if data is None:
            logger.warn('Cannot get track data')
            return False
        track.data = data
        if not track.is_playable():
            logger.warn('Cannot get streaming URL')
            return False
        if 'purchased' in params:
            track.parameters['purchased'] = True
        item = track.makeListItem()
        track.item_add_playing_property(item)
        # Some tracks are not authorized for stream and a 60s sample is
        # returned, in that case we overwrite the song duration
        if track.is_sample():
            item.setInfo('Music', infoLabels={'duration': 60, })
            # Don't warn for free account (all songs except purchases are 60s
            # limited)

            if not isFreeAccount():
                notify_warn("Qobuz / Free Account", "Sample returned")
            if track.is_uncredentialed():
                notify_warn("Qobuz / Uncredentialed", "Sample returned")
        xbmcgui.Window(10000).setProperty(keyTrackId, track_id)
        # Notify
        if config.app.registry.get('notification_playingsong', to='bool'):
            notify_restriction(track)
            notifyH(lang(30132), track.get_label(), image=track.get_image())
        # We are called from playlist...
        if config.app.handle == -1:
            super(QobuzPlayer, self).play(track.get_streaming_url(), item,
                                          False)
        else:
            setResolvedUrl(
                handle=config.app.handle, succeeded=True, listitem=item)
        return True
Exemple #44
0
 def get_label(self, default=None):
     label = self.get_property('name', default=None)
     if label is not None:
         return label
     return lang(30189)
Exemple #45
0
from qobuz.node import getNode, Flag
from qobuz.node.inode import INode

logger = getLogger(__name__)

RECOS_TYPE_IDS = {
    1: 'new-releases',
    2: 'press-awards',
    3: 'best-sellers',
    4: 'editor-picks',
    5: 'most-featured',
    6: 'most-streamed'
}

RECOS_TYPES = {
    1: lang(30086),
    2: lang(30085),
    3: lang(30087),
    4: lang(30088),
    5: lang(30103),
    6: lang(30192)
}

RECOS_GENRES = {
    2: lang(30095),
    10: lang(30097),
    6: lang(30092),
    59: lang(30100),
    73: lang(30105),
    80: lang(30091),
    64: lang(30106),
 def get_label(self, default=None):
     if self.search_type is None:
         return lang(30194)
     return '%s - %s' % (lang(30194), self.search_type.capitalize())
Exemple #47
0
 def subscribe(self):
     if api.playlist_subscribe(playlist_id=self.nid):
         notify_log(lang(30183), lang(30187))
         self.delete_cache(self.nid)
         return True
     return False
Exemple #48
0
'''
from kodi_six import xbmcgui  # pylint:disable=E0401

from qobuz import exception
from qobuz.api import api
from qobuz.api.user import current as user
from qobuz.cache import cache
from qobuz.debug import getLogger
from qobuz.gui.util import getImage, notifyH, executeBuiltin, containerUpdate
from qobuz.gui.util import lang
from qobuz.node import getNode, Flag, helper
from qobuz.node.inode import INode
from qobuz.renderer import renderer

logger = getLogger(__name__)
dialogHeading = lang(30083)
all_kinds = ['albums', 'tracks', 'artists']


class Node_favorite(INode):
    def __init__(self, parent=None, parameters=None, data=None):
        parameters = {} if parameters is None else parameters
        super(Node_favorite, self).__init__(
            parent=parent, parameters=parameters, data=data)
        self.nt = Flag.FAVORITE
        self.image = getImage('favorites')
        self.method = self.get_parameter('nm')
        self.search_type = self.get_parameter('search-type')
        self.content_type = 'songs'

    def get_label(self, default=None):
Exemple #49
0
'''
    qobuz.node.search
    ~~~~~~~~~~~~~~~~~

    :part_of: kodi-qobuz
    :copyright: (c) 2012-2018 by Joachim Basmaison, Cyril Leclerc
    :license: GPLv3, see LICENSE for more details.
'''
from qobuz.api import api
from qobuz.gui.util import lang, getImage
from qobuz.node import getNode, Flag
from qobuz.node.inode import INode

data_search_type = {
    'artists': {
        'label': lang(30017),
        'content_type': 'artists',
        'image': getImage('artist'),
    },
    'albums': {
        'label': lang(30016),
        'content_type': 'albums',
        'image': getImage('album'),
    },
    'tracks': {
        'label': lang(30015),
        'content_type': 'albums',
        'image': getImage('song'),
    },
}
Exemple #50
0
 def get_label(self, default=None):
     if self.nid is None:
         return lang(30188)
     return self.get_property('name')