def parse_main_directory(self):
     if self.verbose:
         print 'list main feed directory'
     
     ok = True; index = 0
     
     for lbl, id in FeedInfo():
     
         prefix, type, id = ('nrkbeta', 'feed', index)
         url = Key.build_url( prefix, type=type, id=id )
         
         li = self.entry( 
                 lbl, 
                 iconImage = self.RSSICO, 
                 thumbnailImage = self.RSSICO 
             )
                     
         ok = self.add( 
                 self.hndl,
                 url = url, 
                 listitem = li, 
                 isFolder = True 
             )               
         index += 1                       
     
     if self.verbose:
         print 'added %d entries. success: %s' % ( index, repr(ok) )
     
     if ok: #tell end of directory
         self.eod( self.hndl )
Exemplo n.º 2
0
 def add(self, label, url=None, image='', ident=None, isdir=True):
     if ident and not url:
         url = Key.build_url('webradio', id=ident, image=image)
     li = ListItem(label, thumbnailImage=image)
     ok = addDirectoryItem(self.handle,
                           url=url,
                           listitem=li,
                           isFolder=isdir)
     return ok
Exemplo n.º 3
0
 def __init__(self):
 
     self.hndl = int(sys.argv[1])
  
  
     self.add(lang(30250),  nrk.PROGRAM,  nrk.PROGRAM,  img='program-icon.png')
     self.add(lang(30251),  nrk.PROGRAM,  nrk.LIVE,     img='live-icon.png')
     self.add(lang(30252),  nrk.CHANNELS, nrk.CHANNELS, img='channels-icon.png')
         
     self.add(lang(30253),   nrk.PROGRAM,  nrk.PLAYLIST, 'sport',    'sports-icon.png')
     self.add(lang(30254),  nrk.PROGRAM,  nrk.PLAYLIST, 'nyheter',  'news-icon.png')
     self.add(lang(30255),  nrk.PROGRAM,  nrk.PLAYLIST, 'distrikt', 'regions-icon.png')
     #self.add('Barn',       nrk.PROGRAM,     nrk.PLAYLIST, 'super',    'children-icon.png')
     self.add(lang(30256),  nrk.PROGRAM,  nrk.PLAYLIST, 'natur',    'nature-icon.png')
   
     self.add(lang(30257),  'nrkbeta',    'feed',     img='nrkbeta.png')
     self.add(lang(30258),  'webradio',   'webradio', img='speaker-icon.png')
     self.add(lang(30260),  'podcast',    'video',    img='video-podcast.png')
     self.add(lang(30259),  'podcast',    'sound',    img='audio-podcast.png')
     
     commands = []
     commands.append(( lang(30800), 
                     'XBMC.RunPlugin(%s)' % ( Key.build_url('teletext', page=101)), 
                     ))
     commands.append(( lang(30801), 
                     'XBMC.RunPlugin(%s)' % ( Key.build_url('teletext', page=131)), 
                     ))
     commands.append(( lang(30802), 
                     'XBMC.RunPlugin(%s)' % ( Key.build_url('teletext', page=200)), 
                     ))
     commands.append(( lang(30803), 
                     'XBMC.RunPlugin(%s)' % ( Key.build_url('teletext', page=300)), 
                     ))
     commands.append(( lang(30804), 
                     'XBMC.RunPlugin(%s)' % ( Key.build_url('teletext', page=590)), 
                     ))
     self.add( lang(30261),      'teletext', 'teletext', img='ttv-icon.png', isdir=False, commands=commands)
     
     # Only add the entry for Favourites if the xml file containing favourites exists already.
     if os.path.isfile(FAV_PATH):
       self.add(lang(30262), 'favorites', 'favorites', img='favorites.png')
       
     endOfDirectory(self.hndl)
Exemplo n.º 4
0
 def add(self,
         label,
         id,
         type='channel',
         prefix='kanalene',
         img='',
         icon='',
         isdir=False):
     url = Key.build_url(prefix, type=type, id=id)
     li = ListItem(label, iconImage=icon, thumbnailImage=img)
     li.setProperty('IsPlayable', 'true')
     ok = addDirectoryItem(self.hndl, url=url, listitem=li, isFolder=isdir)
     return ok
Exemplo n.º 5
0
 def add(self, label, prefix, type, id=None, img='', icon='', isdir=True, commands=None):
 
     # Make full path for where to look for specified image
     if img != '':
         img = os.path.join(self.rpath, img)
         
     url = Key.build_url(prefix, type=type, id=id)
     li  = ListItem(label, iconImage=icon, thumbnailImage=img)
     if commands:
         li.addContextMenuItems( commands, True )
     ok  = addDirectoryItem(self.hndl, url=url, listitem=li, isFolder=isdir)
     
     return ok
Exemplo n.º 6
0
    def get_casts(self, xml_filename):
        
        if self.verbose:
            print 'listing podcasts from xml file: %s' % xml_filename
            
        ok = True
        castcount = 0
        
        catalog = os.path.join( self.resrspath, xml_filename )
        parser  = xml.sax.make_parser( )
        folder  = Podcasts( )
        
        parser.setContentHandler( folder )
        parser.parse( catalog )

        
        for cast in folder.entries:
            #iterate and add to directory
            
            pfx = 'podcast';  type = self.FEED
            img = cast.image; link = cast.link
            lbl = cast.title.encode('utf-8', 'replace')
            
            if not img: 
                #set default thumbnail if no image
                img = self.default_image
            
            #generate key for item
            url = Key.build_url( pfx, type=type, feed=link, image=img )
            listitem = self.entry( lbl, thumbnailImage=img, path=url )
            
            #add listitem to directory
            ok = self.add(
                    self.hndl, 
                    url = url, 
                    listitem = listitem, 
                    isFolder = True
                )
                
            castcount += 1
        
        if self.verbose:
            print 'added %d feed entries' % castcount,
            print 'success: %s' % repr( ok )
        
        #Tell end of directory listing
        self.eod( self.hndl, ok, False, False )   
Exemplo n.º 7
0
 def __init__(self):
     Plugin.__init__(self)
     
     if self.state.refresh == True:
         self.state.refresh = False
         key = Key.build_url('program', words=self.state.__dict__)
         xbmc.executebuiltin("ReplaceWindow(Programs,%s)" % key)
         return
         
     self.stack = []
     self.__set_settings()
     self.__map_functions()
     
     self.open()
     self.close()
     
     Session().close()
Exemplo n.º 8
0
    def __init__(self):
        Plugin.__init__(self)

        if self.state.refresh == True:
            self.state.refresh = False
            key = Key.build_url('program', words=self.state.__dict__)
            xbmc.executebuiltin("ReplaceWindow(Programs,%s)" % key)
            return

        self.stack = []
        self.__set_settings()
        self.__map_functions()

        self.open()
        self.close()

        Session().close()
Exemplo n.º 9
0
    def get_casts(self, xml_filename):

        if self.verbose:
            print 'listing podcasts from xml file: %s' % xml_filename

        ok = True
        castcount = 0

        catalog = os.path.join(self.resrspath, xml_filename)
        parser = xml.sax.make_parser()
        folder = Podcasts()

        parser.setContentHandler(folder)
        parser.parse(catalog)

        for cast in folder.entries:
            #iterate and add to directory

            pfx = 'podcast'
            type = self.FEED
            img = cast.image
            link = cast.link
            lbl = cast.title.encode('utf-8', 'replace')

            if not img:
                #set default thumbnail if no image
                img = self.default_image

            #generate key for item
            url = Key.build_url(pfx, type=type, feed=link, image=img)
            listitem = self.entry(lbl, thumbnailImage=img, path=url)

            #add listitem to directory
            ok = self.add(self.hndl, url=url, listitem=listitem, isFolder=True)

            castcount += 1

        if self.verbose:
            print 'added %d feed entries' % castcount,
            print 'success: %s' % repr(ok)

        #Tell end of directory listing
        self.eod(self.hndl, ok, False, False)
Exemplo n.º 10
0
    def parse_main_directory(self):
        if self.verbose:
            print 'list main feed directory'

        ok = True
        index = 0

        for lbl, id in FeedInfo():

            prefix, type, id = ('nrkbeta', 'feed', index)
            url = Key.build_url(prefix, type=type, id=id)

            li = self.entry(lbl,
                            iconImage=self.RSSICO,
                            thumbnailImage=self.RSSICO)

            ok = self.add(self.hndl, url=url, listitem=li, isFolder=True)
            index += 1

        if self.verbose:
            print 'added %d entries. success: %s' % (index, repr(ok))

        if ok:  #tell end of directory
            self.eod(self.hndl)
Exemplo n.º 11
0
 def add(self, label, url, type="channel", prefix="kanalene", img="", icon="", isdir=False):
     url = Key.build_url(prefix, type=type, url=url)
     li = ListItem(label, iconImage=icon, thumbnailImage=img)
     li.setProperty("IsPlayable", "true")
     ok = addDirectoryItem(self.hndl, url=url, listitem=li, isFolder=isdir)
     return ok
Exemplo n.º 12
0
    def create_directory(self):

        if self.state.type == nrk.PLAYLIST:
            self.player = utils.PluginPlayer()
        
        Log.notice('PLUGIN::SPAM -> Set plugin dir content "%s"' % self.content)
        self.dir.set_content(self.content)
        
        if self.settings['fetch_path']:
            if (self.state.type == nrk.SHOW 
            or self.state.type == nrk.SHOW_FOLDER):
                self.category = self.api.get_path(self.state.id, self.state.type)
                self.set_category()
        else:
            self.set_category()
        
        
        for i in self:
            li = ListItem(i.title, thumbnailImage=i.thumbnail)
            
            overlay = (
                    xbmcgui.ICON_OVERLAY_UNWATCHED,
                    xbmcgui.ICON_OVERLAY_WATCHED,)[
                        self.session.data_objects['watched'].has_key(i.key.id)]

                
            if i.isPlayable is True:
                li.setProperty('IsPlayable', 'true')

            li.setInfo( 'video', {
                            'plot':    i.plot, 
                            'title':   i.title, 
                            'overlay': overlay
                        }
                    )
            
            try:    
              li.setLabel2(self.type_dict[i.key.type])
            except:
              pass
              
            if self.state.type == nrk.PLAYLIST and self.state.view:
                self.player.queue(i.url, li)
            
            
            commands = []
            commands.append(( lang(30300), 
                                  'XBMC.RunPlugin(%s)' % (
                                        Key.build_url(
                                              'program',
                                              words = self.state.__dict__,
                                              refresh = True
                                        )), 
                                ))
                                
            if i.key.type == nrk.SHOW:                
                commands.append(( lang(30301), 
                                  'XBMC.RunPlugin(%s)' % (
                                        Key.build_url(
                                              'favorites',
                                              action = 'add', 
                                              name  = i.title, 
                                              thumb = i.thumbnail, 
                                              id    = i.key.id
                                        )), 
                                ))
                
            
            elif i.defntion == 'video/mp4':
                commands.append(( lang(30302), 
                                  'XBMC.RunPlugin(%s)' % (
                                        Key.build_url(
                                              'nogui',
                                              action = 'download', 
                                              name  = i.title, 
                                              thumb = i.thumbnail, 
                                              url   = i.url
                                        )), 
                                ))
                
            
            li.addContextMenuItems( commands )  
            
    
            if i.key.type != nrk.VIGNETE:
                ok = self.dir.add(i.url, li, i.isFolder, int(sys.argv[1]))
                if ok == False:
                    break
                
        if self.state.type == nrk.PLAYLIST and self.state.view:
            if self.settings.autoplay_playlist == True:
                self.player.playQueue()
Exemplo n.º 13
0
    def create_directory(self):

        if self.state.type == nrk.PLAYLIST:
            self.player = utils.PluginPlayer()

        Log.notice('PLUGIN::SPAM -> Set plugin dir content "%s"' %
                   self.content)
        self.dir.set_content(self.content)

        if self.settings['fetch_path']:
            if (self.state.type == nrk.SHOW
                    or self.state.type == nrk.SHOW_FOLDER):
                self.category = self.api.get_path(self.state.id,
                                                  self.state.type)
                self.set_category()
        else:
            self.set_category()

        for i in self:
            li = ListItem(i.title, thumbnailImage=i.thumbnail)

            overlay = (
                xbmcgui.ICON_OVERLAY_UNWATCHED,
                xbmcgui.ICON_OVERLAY_WATCHED,
            )[self.session.data_objects['watched'].has_key(i.key.id)]

            if i.isPlayable is True:
                li.setProperty('IsPlayable', 'true')

            li.setInfo('video', {
                'plot': i.plot,
                'title': i.title,
                'overlay': overlay
            })

            try:
                li.setLabel2(self.type_dict[i.key.type])
            except:
                pass

            if self.state.type == nrk.PLAYLIST and self.state.view:
                self.player.queue(i.url, li)

            commands = []
            commands.append((
                lang(30300),
                'XBMC.RunPlugin(%s)' % (Key.build_url(
                    'program', words=self.state.__dict__, refresh=True)),
            ))

            if i.key.type == nrk.SHOW:
                commands.append((
                    lang(30301),
                    'XBMC.RunPlugin(%s)' % (Key.build_url('favorites',
                                                          action='add',
                                                          name=i.title,
                                                          thumb=i.thumbnail,
                                                          id=i.key.id)),
                ))

            elif i.defntion == 'video/mp4':
                commands.append((
                    lang(30302),
                    'XBMC.RunPlugin(%s)' % (Key.build_url('nogui',
                                                          action='download',
                                                          name=i.title,
                                                          thumb=i.thumbnail,
                                                          url=i.url)),
                ))

            li.addContextMenuItems(commands)

            if i.key.type != nrk.VIGNETE:
                ok = self.dir.add(i.url, li, i.isFolder, int(sys.argv[1]))
                if ok == False:
                    break

        if self.state.type == nrk.PLAYLIST and self.state.view:
            if self.settings.autoplay_playlist == True:
                self.player.playQueue()
Exemplo n.º 14
0
 def add(self, label, url=None, image='', ident=None, isdir=True):
     if ident and not url:
         url = Key.build_url('webradio', id=ident, image=image)
     li = ListItem(label, thumbnailImage=image)
     ok = addDirectoryItem(self.handle, url=url, listitem=li, isFolder=isdir)
     return ok
Exemplo n.º 15
0
 def add(self, label, id, type='channel', prefix='kanalene', img='', icon='', isdir=False):
     url = Key.build_url(prefix, type=type, id=id)
     li = ListItem(label, iconImage=icon, thumbnailImage=img)
     li.setProperty('IsPlayable', 'true')
     ok = addDirectoryItem(self.hndl, url=url, listitem=li, isFolder=isdir)
     return ok