Exemplo n.º 1
0
 def subscribe(self):
     if api.playlist_subscribe(playlist_id=self.nid):
         notifyH(lang(42001), lang(42005))
         self.delete_cache(self.nid)
         return True
     else:
         return False
Exemplo n.º 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 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(30078))
     k.doModal()
     if not k.isConfirmed():
         return False
     newname = k.getText()
     newname = newname.strip()
     if not newname:
         notifyH(dialogHeading, "Don't u call ure child something?", 
                 'icon-error-256')
         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)
     notifyH(lang(30078), (u"%s: %s") % (lang(39009), currentname))
     executeBuiltin(containerRefresh())
     return True
Exemplo n.º 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(39007), 
                    cmd=containerUpdate(url))

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

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

        url = self.make_url(nt=Flag.PLAYLIST, nm='gui_remove')
        menu.add(path='playlist/remove', label=lang(39010), 
                 cmd=runPlugin(url), color=colorCaution)

        ''' Calling base class '''
        super(Node_playlist, self).attach_context_menu(item, menu)
Exemplo n.º 4
0
 def __init__(self, parent=None, parameters=None):
     super(Node_favorites, self).__init__(parent, parameters)
     self.nt = Flag.FAVORITES
     self.set_label(lang(30079))
     self.name = lang(30079)
     self.label = lang(30079)
     self.content_type = 'albums'
     self.image = getImage('favorites')
     self.offset = self.get_parameter('offset') or 0
Exemplo n.º 5
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'
Exemplo n.º 6
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'
     self.offset = self.get_parameter('offset') or 0
     if self.search_type == 'all':
         self.label = '%s - %s' % (lang(30101), lang(30098))
     else:
         self.label = '%s - %s' % (lang(30101),
                                   self.search_type.capitalize())
Exemplo n.º 7
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'
     self.offset = self.get_parameter('offset') or 0
     if self.search_type == 'all':
         self.label = '%s - %s' % (lang(30101), lang(30098))
     else:
         self.label = '%s - %s' % (lang(30101),
                                   self.search_type.capitalize())
Exemplo n.º 8
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(40003), "%s : %s items" % (lang(40002), str(self.total_put)))
     self.close()
     return self.total_put
Exemplo n.º 9
0
 def __init__(self, parent=None, parameters=None):
     super(Node_public_playlists, self).__init__(parent, parameters)
     self.nt = Flag.PUBLIC_PLAYLISTS
     self.set_label(lang(42102))
     self.is_folder = True
     self.image = getImage("userplaylists")
     self.offset = self.get_parameter("offset") or 0
Exemplo n.º 10
0
 def __init__(self, parent=None, parameters=None):
     super(Node_label, self).__init__(parent, parameters)
     self.nt = Flag.LABEL
     self.set_label(lang(30188))
     self.url = None
     self.is_folder = True
     self.image = getImage('album')
Exemplo n.º 11
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(40000))
     self.line1 = ""
     self.line2 = ""
     self.line3 = ""
     self.percent = 0
     self.content_type = "files"
     self.nodes = nodeList
     self.replaceItems = False
     self.asLocalURL = False
Exemplo n.º 12
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
Exemplo n.º 13
0
 def search_type(self, st):
     if st == 'artists':
         self.label = lang(30015)
         self.content_type = 'files'
         self.image = getImage('artist')
     elif st == 'albums':
         self.label = lang(30014)
         self.content_type = 'albums'
         self.image = getImage('album')
     elif st == 'tracks':
         self.label = lang(30013)
         self.content_type = 'songs'
         self.image = getImage('song')
     else:
         raise QobuzXbmcError(who=self, what='invalid_type', additional=st)
     self._search_type = st
Exemplo n.º 14
0
 def __init__(self, parent=None, parameters=None):
     super(Node_purchases, self).__init__(parent, parameters)
     self.label = lang(30100)
     self.nt = Flag.PURCHASES
     self.content_type = 'albums'
     self.image = getImage('album')
     self.offset = self.get_parameter('offset') or 0
Exemplo n.º 15
0
 def __init__(self, parent=None, parameters=None):
     super(Node_genre, self).__init__(parent, parameters)
     self.nt = Flag.GENRE
     self.set_label(lang(42101))
     self.is_folder = True
     self.image = getImage('album')
     self.offset = self.get_parameter('offset') or 0
Exemplo n.º 16
0
 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
Exemplo n.º 17
0
 def __init__(self, parent=None, parameters=None):
     super(Node_genre, self).__init__(parent, parameters)
     self.nt = Flag.GENRE
     self.set_label(lang(42101))
     self.is_folder = True
     self.image = getImage('album')
     self.offset = self.get_parameter('offset') or 0
Exemplo n.º 18
0
 def __init__(self, parent=None, parameters=None):
     super(Node_purchases, self).__init__(parent, parameters)
     self.label = lang(30100)
     self.nt = Flag.PURCHASES
     self.content_type = 'albums'
     self.image = getImage('album')
     self.offset = self.get_parameter('offset') or 0
Exemplo n.º 19
0
 def search_type(self, st):
     if st == 'artists':
         self.label = lang(30015)
         self.content_type = 'files'
         self.image = getImage('artist')
     elif st == 'albums':
         self.label = lang(30014)
         self.content_type = 'albums'
         self.image = getImage('album')
     elif st == 'tracks':
         self.label = lang(30013)
         self.content_type = 'songs'
         self.image = getImage('song')
     else:
         raise QobuzXbmcError(who=self, what='invalid_type', additional=st)
     self._search_type = st
Exemplo n.º 20
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
Exemplo n.º 21
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
Exemplo n.º 22
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')
     self.genre_type = self.get_parameter('genre-type')
     self.set_label(lang(30084))
     self.image = getImage('album')
     self.offset = self.get_parameter('offset') or 0
Exemplo n.º 23
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:
         notifyH(dialogHeading, lang(3600))
         return False
     ret = xbmcgui.Dialog().select(lang(36006), [
        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
     notifyH(dialogHeading, 'Track(s) added to favorite')
     return True
Exemplo n.º 24
0
 def gui_add_albums(self):
     qnt, qid = int(self.get_parameter('qnt')), self.get_parameter('qid')
     nodes = self.list_albums(qnt, qid)
     if len(nodes) == 0:
         notifyH(dialogHeading, lang(36004))
         return False
     ret = xbmcgui.Dialog().select(lang(36005), [
        node.get_label() for node in nodes                              
     ])
     if ret == -1:
         return False
     album_ids = ','.join([node.nid for node in nodes])
     if not self.add_albums(album_ids):
         notifyH(dialogHeading, 'Cannot add album(s) to favorite')
         return False
     notifyH(dialogHeading, 'Album(s) added to favorite')
     return True
Exemplo n.º 25
0
 def gui_add_artists(self):
     qnt, qid = int(self.get_parameter('qnt')), self.get_parameter('qid')
     nodes = self.list_artists(qnt, qid)
     if len(nodes) == 0:
         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
Exemplo n.º 26
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))

        ''' Calling base class '''
        super(Node_friends, self).attach_context_menu(item, menu)
Exemplo n.º 27
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(40003), 
                 "%s : %s items" % (lang(40002), str(self.total_put)))
     self.close()
     return self.total_put
Exemplo n.º 28
0
 def __init__(self, parent=None, parameters=None):
     super(Node_user_playlists, self).__init__(parent, parameters)
     self.label = lang(30019)
     self.image = getImage('userplaylists')
     self.nt = Flag.USERPLAYLISTS
     self.content_type = 'files'
     display_by = self.get_parameter('display-by')
     if not display_by:
         display_by = 'songs'
     self.set_display_by(display_by)
     display_cover = getSetting('userplaylists_display_cover', isBool=True)
     self.display_product_cover = display_cover
     self.offset = self.get_parameter('offset') or 0
Exemplo n.º 29
0
 def __init__(self, parent=None, parameters=None):
     super(Node_user_playlists, self).__init__(parent, parameters)
     self.label = lang(30019)
     self.image = getImage('userplaylists')
     self.nt = Flag.USERPLAYLISTS
     self.content_type = 'files'
     display_by = self.get_parameter('display-by')
     if not display_by:
         display_by = 'songs'
     self.set_display_by(display_by)
     display_cover = getSetting('userplaylists_display_cover', isBool=True)
     self.display_product_cover = display_cover
     self.offset = self.get_parameter('offset') or 0
Exemplo n.º 30
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)
Exemplo n.º 31
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)
Exemplo n.º 32
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())
        self.offset = self.get_parameter('offset') or 0
Exemplo n.º 33
0
 def gui_create(self):
     name = self.get_parameter('query')
     if not name:
         from gui.util import Keyboard
         kb = Keyboard('', str(lang(41102)))
         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
Exemplo n.º 34
0
    def gui_create(self):
        name = self.get_parameter("query")
        if not name:
            from gui.util import Keyboard

            kb = Keyboard("", str(lang(41102)))
            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
Exemplo n.º 35
0
 def gui_create(self):
     query = self.get_parameter('query', unQuote=True)
     if not query:
         from gui.util import Keyboard
         k = Keyboard('', lang(42000))
         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']
Exemplo n.º 36
0
    def play(self, 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")
#            label = "Maybe an invalid track id"
#            item = xbmcgui.ListItem("No track information", label, '', 
#                                    getImage('icon-error-256'), '')
            return False
        if not track.is_playable():
            warn(self, "Cannot get streaming URL")
            return False
        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():
                notifyH("Qobuz", "Sample returned")
        xbmcgui.Window(10000).setProperty(keyTrackId, track_id) 
        """
            Notify
        """
        if getSetting('notification_playingsong', isBool=True):
            notifyH(lang(34000), track.get_label(), track.get_image())
        """
            We are called from playlist...
        """
        if qobuz.boot.handle == -1:
            super(QobuzPlayer, self).play(track.get_streaming_url(), 
                                          item, False)
        else:
            setResolvedUrl(handle=qobuz.boot.handle,
                succeeded=True,
                listitem=item)
        return True
Exemplo n.º 37
0
 def cache_remove(self):
     '''GUI/Removing all cached data
     '''
     from gui.util import yesno, notifyH, getImage
     from debug import log
     if not yesno(lang(30121), lang(30122)):
         log(self, "Deleting cached data aborted")
         return False
     if clean_all(cache):
         notifyH(lang(30119), lang(30123))
     else:
         notifyH(lang(30119), lang(30120),
                 getImage('icon-error-256'))
     return True
Exemplo n.º 38
0
 def play(self, 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")
         #            label = "Maybe an invalid track id"
         #            item = xbmcgui.ListItem("No track information", label, '',
         #                                    getImage('icon-error-256'), '')
         return False
     if not track.is_playable():
         warn(self, "Cannot get streaming URL")
         return False
     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():
             notifyH("Qobuz", "Sample returned")
     xbmcgui.Window(10000).setProperty(keyTrackId, track_id)
     """
         Notify
     """
     if getSetting('notification_playingsong', isBool=True):
         notifyH(lang(34000), track.get_label(), track.get_image())
     """
         We are called from playlist...
     """
     if qobuz.boot.handle == -1:
         super(QobuzPlayer, self).play(track.get_streaming_url(), item,
                                       False)
     else:
         setResolvedUrl(handle=qobuz.boot.handle,
                        succeeded=True,
                        listitem=item)
     return True
Exemplo n.º 39
0
    def gui_remove(self, playlist_id=None):
        if not playlist_id:
            playlist_id = self.nid
        if not playlist_id:
            notifyH(dialogHeading, 'Invalid playlist %s' % (str(playlist_id)))
            return False
#         import xbmcgui  # @UnresolvedImport
#         import xbmc  # @UnresolvedImport
#         cid = self.get_current_playlist()
        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))
            notifyH(lang(30183),
                    lang(30186) + name, getImage('icon-error-256'))
            return False
        self.delete_cache(playlist_id)
        notifyH(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
Exemplo n.º 40
0
 def gui_remove(self, playlist_id=None):
     if not playlist_id:
         playlist_id = self.nid
     if not playlist_id:
         notifyH(dialogHeading, 'Invalid playlist %s' % (str(playlist_id)))
         return False
     import xbmcgui
     import xbmc
     cid = self.get_current_playlist()
     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(39010),
                                 lang(30052),
                                 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))
         notifyH(lang(42001), lang(42004) +
                 name, getImage('icon-error-256'))
         return False
     self.delete_cache(playlist_id)
     notifyH(lang(42001), (lang(42002) + "%s" + lang(42003)) % (name))
     url = self.make_url(nt=Flag.USERPLAYLISTS, mode=Mode.VIEW, nm='', 
                         nid='')
     executeBuiltin(containerUpdate(url, True))
     return False
Exemplo n.º 41
0
    :part_of: xbmc-qobuz
    :copyright: (c) 2012 by Joachim Basmaison, Cyril Leclerc
    :license: GPLv3, see LICENSE for more details.
'''
import xbmcgui  # @UnresolvedImport
from inode import INode
from debug import warn
from gui.util import lang, getSetting
from gui.util import getImage, notifyH, executeBuiltin, containerUpdate
from node import getNode, Flag
from renderer import renderer
from api import api
from exception import QobuzXbmcError as Qerror
from cache import cache

dialogHeading = lang(30083)


class Node_favorite(INode):
    '''Displaying user favorites (track and album)
    '''
    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':
Exemplo n.º 42
0
 def get_label(self):
     return lang(30156)
Exemplo n.º 43
0
    def attach_context_menu(self, item, menu):
        """
            Note: Url made with make_url must set mode (like mode=Mode.VIEW)
            else we are copying current mode (for track it's Mode.PLAY ...)
        """
        ''' HOME '''
        colorCaution = getSetting('item_caution_color')

        url = self.make_url(nt=Flag.ROOT, mode=Mode.VIEW, nm='')
        menu.add(path='qobuz',
                 label="Qobuz",
                 cmd=containerUpdate(url, False),
                 id='',
                 pos=-5)
        ''' ARTIST '''
        if self.nt & (Flag.ALBUM | Flag.TRACK | Flag.ARTIST):
            artist_id = self.get_artist_id()
            # if not artist_id:
            #    import pprint
            #    print pprint.pformat(self.data)
            artist_name = self.get_artist()
            urlArtist = self.make_url(nt=Flag.ARTIST,
                                      nid=artist_id,
                                      mode=Mode.VIEW)
            menu.add(path='artist/all_album',
                     label="%s %s" % (lang(30157), artist_name),
                     cmd=containerUpdate(urlArtist),
                     pos=-10)
            ''' Similar artist '''
            url = self.make_url(nt=Flag.SIMILAR_ARTIST,
                                nid=artist_id,
                                mode=Mode.VIEW)
            menu.add(path='artist/similar',
                     label=lang(30160),
                     cmd=containerUpdate(url))
        ''' FAVORITES '''
        wf = self.nt & (~Flag.FAVORITE)
        if self.parent:
            wf = wf and self.parent.nt & ~Flag.FAVORITE
        if wf:
            ''' ADD TO FAVORITES / TRACKS'''
            url = self.make_url(nt=Flag.FAVORITE, nm='', mode=Mode.VIEW)
            menu.add(path='favorites',
                     label="Favorites",
                     cmd=containerUpdate(url, True),
                     pos=-9)
            url = self.make_url(nt=Flag.FAVORITE,
                                nm='gui_add_tracks',
                                qid=self.nid,
                                qnt=self.nt,
                                mode=Mode.VIEW)
            menu.add(path='favorites/add_tracks',
                     label=lang(30167) + ' tracks',
                     cmd=runPlugin(url))
            ''' ADD TO FAVORITES / Albums'''
            url = self.make_url(nt=Flag.FAVORITE,
                                nm='gui_add_albums',
                                qid=self.nid,
                                qnt=self.nt,
                                mode=Mode.VIEW)
            menu.add(path='favorites/add_albums',
                     label=lang(30167) + ' albums',
                     cmd=runPlugin(url))
            ''' ADD TO FAVORITES / Artists'''
            url = self.make_url(nt=Flag.FAVORITE,
                                nm='gui_add_artists',
                                qid=self.nid,
                                qnt=self.nt,
                                mode=Mode.VIEW)
            menu.add(path='favorites/add_artists',
                     label=lang(30167) + ' artists',
                     cmd=runPlugin(url))

        if self.parent and (self.parent.nt & Flag.FAVORITE):
            url = self.make_url(nt=Flag.FAVORITE, nm='', mode=Mode.VIEW)
            menu.add(path='favorites',
                     label="Favorites",
                     cmd=containerUpdate(url, True),
                     pos=-9)
            url = self.make_url(nt=Flag.FAVORITE,
                                nm='gui_remove',
                                qid=self.nid,
                                qnt=self.nt,
                                mode=Mode.VIEW)
            menu.add(path='favorites/remove',
                     label='Remove %s' % (self.get_label()),
                     cmd=runPlugin(url),
                     color=colorCaution)
        wf = ~Flag.USERPLAYLISTS
        #        if self.parent:
        #            wf = wf and self.parent.nt & (~Flag.USERPLAYLISTS)
        if wf:
            ''' PLAYLIST '''
            cmd = containerUpdate(
                self.make_url(nt=Flag.USERPLAYLISTS, nid='', mode=Mode.VIEW))
            menu.add(path='playlist',
                     pos=1,
                     label="Playlist",
                     cmd=cmd,
                     mode=Mode.VIEW)
            ''' ADD TO CURRENT PLAYLIST '''
            cmd = runPlugin(
                self.make_url(nt=Flag.PLAYLIST,
                              nm='gui_add_to_current',
                              qnt=self.nt,
                              mode=Mode.VIEW,
                              qid=self.nid))
            menu.add(path='playlist/add_to_current',
                     label=lang(30161),
                     cmd=cmd)
            label = self.get_label()
            try:
                label = label.encode('utf8', 'replace')
            except:
                warn(self, "Cannot set query..." + repr(label))
                label = ''
            label = urllib.quote_plus(label)
            ''' ADD AS NEW '''
            cmd = runPlugin(
                self.make_url(nt=Flag.PLAYLIST,
                              nm='gui_add_as_new',
                              qnt=self.nt,
                              query=label,
                              mode=Mode.VIEW,
                              qid=self.nid))
            menu.add(path='playlist/add_as_new', label=lang(30082), cmd=cmd)

#            ''' Show playlist '''
#            if not (self.nt ^ Flag.USERPLAYLISTS != Flag.USERPLAYLISTS):
#                cmd = containerUpdate(self.make_url(nt=Flag.USERPLAYLISTS,
#                                    id='', mode=Mode.VIEW))
#                menu.add(path='playlist/show',
#                          label=lang(30162), cmd=cmd)
        ''' PLAYLIST / CREATE '''
        cFlag = (Flag.PLAYLIST | Flag.USERPLAYLISTS)
        if self.nt | cFlag == cFlag:
            cmd = runPlugin(
                self.make_url(nt=Flag.PLAYLIST,
                              nm="gui_create",
                              mode=Mode.VIEW))
            menu.add(path='playlist/create', label=lang(30164), cmd=cmd)
        ''' VIEW BIG DIR '''
        cmd = containerUpdate(self.make_url(mode=Mode.VIEW_BIG_DIR))
        menu.add(path='qobuz/big_dir', label=lang(30158), cmd=cmd)
        ''' SCAN '''
        if getSetting('enable_scan_feature', isBool=True):
            query = urllib.quote_plus(self.make_url(mode=Mode.SCAN))
            url = self.make_url(nt=Flag.ROOT,
                                mode=Mode.VIEW,
                                nm='gui_scan',
                                query=query)
            menu.add(path='qobuz/scan', cmd=runPlugin(url), label='scan')
        if self.nt & (Flag.ALL & ~Flag.ALBUM & ~Flag.TRACK & ~Flag.PLAYLIST):
            ''' ERASE CACHE '''
            cmd = runPlugin(
                self.make_url(nt=Flag.ROOT, nm="cache_remove", mode=Mode.VIEW))
            menu.add(path='qobuz/erase_cache',
                     label=lang(30117),
                     cmd=cmd,
                     color=colorCaution,
                     pos=10)
Exemplo n.º 44
0
 def get_label(self):
     return lang(39000)
Exemplo n.º 45
0
 def get_label(self):
     return lang(30156)