Example #1
0
def root():
    util.add_dir(__str__(30016), {'ctrl': 'list'}, '')
    util.add_dir(__str__(200), {'queue': 'list'}, '')
    util.add_dir(__str__(201), {'files': 'list'}, '')
    util.add_dir(__str__(202), {'artists': 'list'}, '')
    util.add_dir(__str__(203), {'pls': 'list'}, '')
    #    util.add_dir(__str__(112),{'settings':'list'},'')
    xbmcplugin.endOfDirectory(int(sys.argv[1]))
Example #2
0
 def list_artists(self):
     for artist in self.mpd.list('artist'):
         menu={
                 __str__(30030):{self.key:'queue_add','art':artist},
                 __str__(30031):{self.key:'queue_repl','art':artist}
         }
         util.add_dir(artist,{self.key:'artist','name':artist},infoLabels={},menuItems=menu,replace=True)
     xbmcplugin.addSortMethod( handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_LABEL, label2Mask="%X")
Example #3
0
def root():
    util.add_dir(__str__(30016),{'ctrl':'list'},'')
    util.add_dir(__str__(200),{'queue':'list'},'')
    util.add_dir(__str__(201),{'files':'list'},'')
    util.add_dir(__str__(202),{'artists':'list'},'')
    util.add_dir(__str__(203),{'pls':'list'},'')
#    util.add_dir(__str__(112),{'settings':'list'},'')
    xbmcplugin.endOfDirectory(int(sys.argv[1]))
Example #4
0
 def list(self):
     for item in self.mpd.listplaylists():
         menu={
             __str__(30030):{self.key:'queue_add','name':item['playlist']},
             __str__(30031):{self.key:'queue_repl','name':item['playlist']}
         }
         title = item['playlist']
         util.add_dir(title,{self.key:'playlist','name':item['playlist']},infoLabels={},menuItems=menu,replace=True)
     xbmcplugin.addSortMethod( handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_LABEL, label2Mask="%X")
Example #5
0
def render(data):
    if data == None:
        raise Exception('Addon error, no data returned')
    listed = 0
    for item in data:
        if item['type'] == 'play':
            print 'Playing MPD Stream ' + item['path']
            li = xbmcgui.ListItem(path=item['path'],
                                  iconImage='DefaulAudio.png')
            return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
        if item['type'] == 'dummy':
            listed += 1
        if item['type'] == 'dir':
            listed += 1
            params = item['params']
            params.update({'m': item['m']})
            util.add_dir(item['title'],
                         params,
                         icon(item['icon']),
                         menuItems=item['menu'],
                         replace=True)
        if item['type'] == 'audio':
            listed += 1
            params = item['params']
            params.update({'m': item['m']})
            util.add_song(item['title'],
                          params,
                          icon(item['icon']),
                          menuItems=item['menu'],
                          playable=str(item['play']).lower(),
                          replace=True)
        if item['type'] == 'func':
            print 'Executing %s' % item['func']
            xbmc.executebuiltin(item['func'])
        if item['type'] == 'sort':
            sort_methods(item['keys'])
        if item['type'] == 'notify':
            notify(item['title'], item['message'])
        if item['type'] == 'search':
            what = item['for']
            if what == '#':
                kb = xbmc.Keyboard('', __str__(30071), False)
                kb.doModal()
                if kb.isConfirmed():
                    what = kb.getText()
            if not (what == '' or what == '#'):
                render(item['func'](what))
            return

    if listed > 0:
        xbmcplugin.endOfDirectory(int(sys.argv[1]))
Example #6
0
    def list(self, params):
        uri = ''
        if 'path' in params.keys():
            uri = params['path']
        for item in self.mpd.lsinfo(uri):
            print item
            if 'directory' in item:
                menu = {
                    __str__(30030): {
                        self.key: 'queue_add',
                        'path': item['directory']
                    },
                    __str__(30031): {
                        self.key: 'queue_repl',
                        'path': item['directory']
                    }
                }
                title = os.path.basename(item['directory'])
                util.add_dir(title, {
                    self.key: 'list',
                    'path': item['directory']
                },
                             infoLabels={},
                             menuItems=menu,
                             replace=True)
            elif 'file' in item:
                menu = {
                    __str__(30030): {
                        self.key: 'queue_add',
                        'path': item['file']
                    },
                    __str__(30031): {
                        self.key: 'queue_repl',
                        'path': item['file']
                    }
                }
                title = os.path.basename(item['file'])
                util.add_song(title, {
                    self.key: 'list',
                    'path': item['file']
                },
                              infoLabels={},
                              menuItems=menu,
                              replace=True)

        xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                                 sortMethod=xbmcplugin.SORT_METHOD_LABEL,
                                 label2Mask="%X")
Example #7
0
 def list_albums(self,artist):
     for album in self.mpd.list('album','artist',artist):
         date = 0
         dates = self.mpd.list('date','album',album,'artist',artist)
         if len(dates) > 0:
             try:
                 date = int(dates[0])
             except:
                 pass
         title = '%s' % album
         if date > 0:
             title = '%s (%d)' % (album,date)
         info={'year':date,'artist':artist}
         menu={
                 __str__(30030):{self.key:'queue_add','art':artist,'album':album},
                 __str__(30031):{self.key:'queue_repl','art':artist,'album':album}
         }
         util.add_dir(title,{self.key:'album','name':album,'art':artist},infoLabels=info,menuItems=menu,replace=True)
     xbmcplugin.addSortMethod( handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_LABEL, label2Mask="%X")
     xbmcplugin.addSortMethod( handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_DATE)
Example #8
0
def render(data):
    if data == None:
        raise Exception('Addon error, no data returned')
    listed = 0
    for item in data:
        if item['type'] == 'play':
            print 'Playing MPD Stream '+item['path']
            li = xbmcgui.ListItem(path=item['path'],iconImage='DefaulAudio.png')
            return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
        if item['type'] == 'dummy':
            listed+=1
        if item['type'] == 'dir':
            listed+=1
            params = item['params']
            params.update({'m':item['m']})
            util.add_dir(item['title'],params,icon(item['icon']),menuItems=item['menu'],replace=True) 
        if item['type'] == 'audio':
            listed+=1
            params = item['params']
            params.update({'m':item['m']})
            util.add_song(item['title'],params,icon(item['icon']),menuItems=item['menu'],playable=str(item['play']).lower(),replace=True) 
        if item['type'] == 'func':
            print 'Executing %s' % item['func']
            xbmc.executebuiltin(item['func'])
        if item['type'] == 'sort':
            sort_methods(item['keys'])
        if item['type'] == 'notify':
            notify(item['title'],item['message'])
        if item['type'] == 'search':
            what = item['for']
            if what == '#':
                kb = xbmc.Keyboard('',__str__(30071),False)
                kb.doModal()
                if kb.isConfirmed():
                    what = kb.getText()
            if not (what == '' or what == '#'):
                render(item['func'](what))
            return

    if listed > 0:
        xbmcplugin.endOfDirectory(int(sys.argv[1]))
Example #9
0
    def list(self,params):
        uri = ''
        if 'path' in params.keys():
            uri = params['path']
        for item in self.mpd.lsinfo(uri):
            print item
            if 'directory' in item:
                menu={
                    __str__(30030):{self.key:'queue_add','path':item['directory']},
                    __str__(30031):{self.key:'queue_repl','path':item['directory']}
                }
                title = os.path.basename(item['directory'])
                util.add_dir(title,{self.key:'list','path':item['directory']},infoLabels={},menuItems=menu,replace=True)
            elif 'file' in item:
                menu={
                    __str__(30030):{self.key:'queue_add','path':item['file']},
                    __str__(30031):{self.key:'queue_repl','path':item['file']}
                }
                title = os.path.basename(item['file'])
                util.add_song(title,{self.key:'list','path':item['file']},infoLabels={},menuItems=menu,replace=True)

        xbmcplugin.addSortMethod( handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_LABEL, label2Mask="%X")
Example #10
0
 def list_artists(self):
     for artist in self.mpd.list('artist'):
         menu = {
             __str__(30030): {
                 self.key: 'queue_add',
                 'art': artist
             },
             __str__(30031): {
                 self.key: 'queue_repl',
                 'art': artist
             }
         }
         util.add_dir(artist, {
             self.key: 'artist',
             'name': artist
         },
                      infoLabels={},
                      menuItems=menu,
                      replace=True)
     xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                              sortMethod=xbmcplugin.SORT_METHOD_LABEL,
                              label2Mask="%X")
Example #11
0
 def list_albums(self, artist):
     for album in self.mpd.list('album', 'artist', artist):
         date = 0
         dates = self.mpd.list('date', 'album', album, 'artist', artist)
         if len(dates) > 0:
             try:
                 date = int(dates[0])
             except:
                 pass
         title = '%s' % album
         if date > 0:
             title = '%s (%d)' % (album, date)
         info = {'year': date, 'artist': artist}
         menu = {
             __str__(30030): {
                 self.key: 'queue_add',
                 'art': artist,
                 'album': album
             },
             __str__(30031): {
                 self.key: 'queue_repl',
                 'art': artist,
                 'album': album
             }
         }
         util.add_dir(title, {
             self.key: 'album',
             'name': album,
             'art': artist
         },
                      infoLabels=info,
                      menuItems=menu,
                      replace=True)
     xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                              sortMethod=xbmcplugin.SORT_METHOD_LABEL,
                              label2Mask="%X")
     xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                              sortMethod=xbmcplugin.SORT_METHOD_DATE)
Example #12
0
 def list(self):
     for item in self.mpd.listplaylists():
         menu = {
             __str__(30030): {
                 self.key: 'queue_add',
                 'name': item['playlist']
             },
             __str__(30031): {
                 self.key: 'queue_repl',
                 'name': item['playlist']
             }
         }
         title = item['playlist']
         util.add_dir(title, {
             self.key: 'playlist',
             'name': item['playlist']
         },
                      infoLabels={},
                      menuItems=menu,
                      replace=True)
     xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                              sortMethod=xbmcplugin.SORT_METHOD_LABEL,
                              label2Mask="%X")