Example #1
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)
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'))
Example #3
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)
Example #4
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)
Example #5
0
 def attach_context_menu(self, item, menu):
     colorWarn = theme.get('item/caution/color')
     url = self.make_url()
     menu.add(path='friend', label=self.name, cmd=containerUpdate(url))
     cmd = runPlugin(self.make_url(nt=Flag.FRIEND, nm='remove'))
     menu.add(path='friend/remove',
              label='Remove',
              cmd=cmd,
              color=colorWarn)
     super(Node_friend, self).attach_context_menu(item, menu)
Example #6
0
 def attach_context_menu(self, item, menu):
     colorWarn = theme.get('item/caution/color')
     url = self.make_url()
     menu.add(path='friend', label=self.name, cmd=containerUpdate(url))
     cmd = runPlugin(self.make_url(nt=Flag.FRIEND, nm='remove'))
     menu.add(path='friend/remove',
              label='Remove',
              cmd=cmd,
              color=colorWarn)
     super(Node_friend, self).attach_context_menu(item, menu)
Example #7
0
    def attach_context_menu(self, item, menu):
        colorWarn = getSetting('item_caution_color')
        url = self.make_url()
        menu.add(path='friend', label=self.name, cmd=containerUpdate(url))
        cmd = runPlugin(self.make_url(nt=Flag.FRIEND, nm="remove"))
        menu.add(path='friend/remove', label='Remove', cmd=cmd,
                 color=colorWarn)

        ''' Calling base class '''
        super(Node_friend, self).attach_context_menu(item, menu)
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))
Example #9
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']
Example #10
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
Example #11
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
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))
Example #13
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.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))
Example #15
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()
            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', asBool=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)
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))