Beispiel #1
0
    def show_videos_init(self):
        
        ok = True
        cpt = 0

        file = xbmc.makeLegalFilename(os.path.join(self.CACHEDIR,self.FILENAME))
        f = open(file,'w')
        
        pDialog = xbmcgui.DialogProgress()
        ret = pDialog.create( 'XBMC', __language__ ( 30200 ) )        
        pDialog.update(0, __language__ ( 30202 ) )
        
        catalog = Catalog()
        self.NB_VIDEO = catalog.videos.__len__();
                 
        for video in catalog.videos:                 
            f.write('\n'.join(['%s;%s;%s;%s' % (video[Catalog.TITLE_TAG].encode('utf-8'),video[Catalog.DATE_TAG].encode('utf-8'), video[Catalog.URL_TAG].encode('utf-8'), video[Catalog.IMAGE_TAG].encode('utf-8'))]))
          
            cpt=cpt+1

            paramsAddons = {}
            paramsAddons[self.PARAM_PLAY_VIDEO]  = "true"
            paramsAddons[self.PARAM_VIDEO_ID]    = video[Catalog.URL_TAG]
            url = _create_param_url( paramsAddons )
                            
            infoLabels={ "Title": video[Catalog.DATE_TAG] + " - " + video[Catalog.TITLE_TAG],
                         "Date": video[Catalog.DATE_TAG]}            
            
            paramsAddonsContextMenu = {}
            paramsAddonsContextMenu[self.PARAM_DOWNLOAD_VIDEO]  = "true"
            paramsAddonsContextMenu[self.PARAM_VIDEO_ID]    = video[Catalog.URL_TAG]
            paramsAddonsContextMenu[self.PARAM_VIDEO_NAME]    = video[Catalog.TITLE_TAG]
            
            urlContextMenu = _create_param_url( paramsAddonsContextMenu )
            
            cm = _addContextMenuItems(name=video[Catalog.TITLE_TAG], url=urlContextMenu, msg= __language__(30102))
            
            _addLink( name=video[Catalog.TITLE_TAG], url=url, iconimage=video[Catalog.IMAGE_TAG], itemInfoLabels=infoLabels, c_items=cm )

            pDialog.update(int(99*float(cpt)/(self.NB_VIDEO)), __language__ ( 30202 ) )            
       
        pDialog.close()
        
        f.close()
                
        xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_NONE)
        xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="referer" )
        xbmcplugin.setContent(int(sys.argv[1]), 'movies')
        _end_of_directory( True )

        return ok
Beispiel #2
0
    def show_videos(self):
        """
        rempli la liste avec la liste des videos
        """
        ok = True
        cpt = 0
        file = xbmc.makeLegalFilename(os.path.join(self.CACHEDIR,self.FILENAME))
        f = open(file,"r")

        pDialog = xbmcgui.DialogProgress()
        ret = pDialog.create( 'XBMC', __language__ ( 30200 ) )        
        pDialog.update(0, __language__ ( 30202 ) )

        for line in f:        
            video = line.split(";")
            cpt=cpt+1

            paramsAddons = {}
            paramsAddons[self.PARAM_PLAY_VIDEO]  = "true"
            paramsAddons[self.PARAM_VIDEO_ID]    = video[2]
            url = _create_param_url( paramsAddons )
            
            infoLabels={ "Title": video[1] + " - " + video[0],
                         "Date": video[1]}            
            
            _addLink( name=video[0], url=url, iconimage=video[3], itemInfoLabels=infoLabels )

            paramsAddons = {}
            paramsAddons[self.PARAM_DOWNLOAD_VIDEO]  = "true"
            paramsAddons[self.PARAM_VIDEO_ID]    = video[2]
            url = _create_param_url( paramsAddons )
            _addContextMenuItems(video[1],url, __language__(30102))
            
            pDialog.update(int(99*float(cpt)/(self.NB_VIDEO)), __language__ ( 30202 ) )

        pDialog.close()
        
        f.close()
                
        xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_NONE)
        xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="referer" )
        xbmcplugin.setContent(int(sys.argv[1]), 'movies')
        _end_of_directory( True )

        return ok
Beispiel #3
0
    def select( self ):
        try:
            if len(self.parameters) < 1:
                #on liste les videos
                self.show_videos_init()

            elif self.PARAM_LIST_VIDEOS in self.parameters.keys():
                #on liste les videos
                self.show_videos()
                   
            elif self.PARAM_PLAY_VIDEO in self.parameters.keys():
                # On lance la video               
                url_page = self.parameters[self.PARAM_VIDEO_ID]
                url = self.get_rtmp_url( url_page, quality = "hd"  )

                # Play  video
                item = xbmcgui.ListItem(path=url)

                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item)
                _end_of_directory( True )
                
            elif self.PARAM_DOWNLOAD_VIDEO in self.parameters.keys(): 
                video = {}
                
                name = self.parameters[self.PARAM_VIDEO_NAME]
                
                url_page = self.parameters[self.PARAM_VIDEO_ID]
                url = self.get_rtmp_url( url_page, quality = "hd"  )             

                video[self.PARAM_VIDEO_ID] = url
                video[self.PARAM_VIDEO_NAME] = name

                self.downloadVideo(video)     

        except Exception,msg:
            xbmc.executebuiltin("XBMC.Notification(%s,%s)"%("ERROR select",msg)) 
            print ("Error select")
            print_exc()
            
            _end_of_directory( False )
Beispiel #4
0
    def select(self):
        try:
            if len(self.parameters) < 1:
                #initialisation
                self.show_menu()

            elif self.PARAM_ARTE_PLUS in self.parameters.keys():
                #on liste les videos arte+7, une page contenant au max 200 vidéos
                self.ARTE_CATEGORIE = self.PARAM_ARTE_PLUS
                self.PARSER = PlusParser(self.lang, self.VIDEOS)
                self.PARSER.parse(1, 200)
                self.show_videos(self.VIDEOS)

            elif self.PARAM_ARTE_LIVE in self.parameters.keys():
                #on liste les categories arte live
                self.ARTE_CATEGORIE = self.PARAM_ARTE_LIVE
                self.show_categories()

            elif self.PARAM_ARTE_EVENT in self.parameters.keys():
                #on liste les categories arte event
                self.ARTE_CATEGORIE = self.PARAM_ARTE_EVENT
                self.show_categories()

            elif self.PARAM_ARTE_BONUS in self.parameters.keys():
                #on liste les categories arte bonus
                self.ARTE_CATEGORIE = self.PARAM_ARTE_BONUS
                self.show_categories()

            elif self.PARAM_ARTE_PROGRAMMES in self.parameters.keys():
                #on liste les categories arte programmes
                self.ARTE_CATEGORIE = self.PARAM_ARTE_PROGRAMMES
                self.show_categories()

            elif self.PARAM_ARTE_SEARCH in self.parameters.keys():
                keyboard = xbmc.Keyboard('', __language__(30001))
                keyboard.doModal()
                if keyboard.isConfirmed() and keyboard.getText():
                    search = keyboard.getText().replace(" ", "+")
                    self.ARTE_CATEGORIE = self.PARAM_ARTE_SEARCH
                    self.PARSER = SearchParser(self.lang, self.VIDEOS)
                    self.PARSER.parse(1, 200, search)
                    self.show_videos(self.VIDEOS)

            elif self.PARAM_SHOW_CATEGORIE in self.parameters.keys(
            ) and self.PARSER is not None:
                #on liste les videos arte event
                key = self.parameters[self.PARAM_ARTE_CATEGORIE_KEY].replace(
                    'brinbrin', '&')
                value = self.parameters[self.PARAM_ARTE_CATEGORIE_VALUE]

                if isinstance(self.PARSER, LiveParser):
                    self.PARSER.get_videos_list(key, self.VIDEOS)
                else:
                    self.NEXT_PAGE_NUMBER = self.PARSER.parse(
                        value, self.PAGE_NUMBER, self.NB_VIDEOS_PER_PAGE)

                self.show_videos(self.VIDEOS)

            elif self.PARAM_NEXT_PAGE in self.parameters.keys(
            ) and self.PARSER is not None:
                #en cas de passage a la page suivante
                self.PAGE_NUMBER = self.parameters[self.PARAM_NEXT_PAGE_NUMBER]

                value = self.parameters[self.PARAM_ARTE_CATEGORIE_VALUE]
                self.NEXT_PAGE_NUMBER = self.PARSER.parse(
                    value, self.PAGE_NUMBER, self.NB_VIDEOS_PER_PAGE)

                self.show_videos(self.VIDEOS)

            elif self.PARAM_PLAY_VIDEO in self.parameters.keys(
            ) and self.PARSER is not None:
                # On lance la video
                hd = self.retrieveVideoLink(
                    link=self.parameters[self.PARAM_VIDEO_ID])

                if hd is None:
                    xbmc.executebuiltin(
                        "XBMC.Notification(%s,%s)" %
                        (__language__(30300), __language__(30301)))

                else:

                    if isinstance(self.PARSER, LiveParser):
                        hd, downloadParams = self.PARSER.decode_link(hd)

                    item = xbmcgui.ListItem(path=hd)
                    xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]),
                                              succeeded=True,
                                              listitem=item)

            elif self.PARAM_DOWNLOAD_VIDEO in self.parameters.keys(
            ) and self.PARSER is not None:
                # On telecharge la video
                video = {}
                name = self.parameters[self.PARAM_VIDEO_NAME]
                hd = self.retrieveVideoLink(
                    link=self.parameters[self.PARAM_VIDEO_ID])

                if hd is None:
                    xbmc.executebuiltin(
                        "XBMC.Notification(%s,%s)" %
                        (__language__(30300), __language__(30301)))

                else:
                    video[self.PARAM_VIDEO_ID] = hd
                    video[self.PARAM_VIDEO_NAME] = name
                    self.downloadVideo(video)

            else:
                #Probleme, pas de bon parametre detecte donc on initialise
                self.show_menu()

            _end_of_directory(True)

        except Exception, msg:
            xbmc.executebuiltin("XBMC.Notification(%s,%s)" %
                                ("ERROR select", msg))
            print("Error select")
            print_exc()
            _end_of_directory(False)
Beispiel #5
0
    def select( self ):
        try:
            if len( self.parameters ) < 1:
                #initialisation
                self.show_menu()

            elif self.PARAM_ARTE_PLUS in self.parameters.keys():
                #on liste les videos arte+7, une page contenant au max 200 vidéos
                self.ARTE_CATEGORIE = self.PARAM_ARTE_PLUS
                self.PARSER = PlusParser( self.lang, self.VIDEOS )
                self.PARSER.parse( 1, 200 )
                self.show_videos( self.VIDEOS )

            elif self.PARAM_ARTE_LIVE in self.parameters.keys():
                #on liste les categories arte live
                self.ARTE_CATEGORIE = self.PARAM_ARTE_LIVE
                self.show_categories()

            elif self.PARAM_ARTE_EVENT in self.parameters.keys():
                #on liste les categories arte event
                self.ARTE_CATEGORIE = self.PARAM_ARTE_EVENT
                self.show_categories()

            elif self.PARAM_ARTE_BONUS in self.parameters.keys():
                #on liste les categories arte bonus
                self.ARTE_CATEGORIE = self.PARAM_ARTE_BONUS
                self.show_categories()

            elif self.PARAM_ARTE_PROGRAMMES in self.parameters.keys():
                #on liste les categories arte programmes
                self.ARTE_CATEGORIE = self.PARAM_ARTE_PROGRAMMES
                self.show_categories()

            elif self.PARAM_ARTE_SEARCH in self.parameters.keys():
                keyboard = xbmc.Keyboard('', __language__( 30001 ))
                keyboard.doModal()
                if keyboard.isConfirmed() and keyboard.getText():
                    search = keyboard.getText().replace(" ","+")
                    self.ARTE_CATEGORIE = self.PARAM_ARTE_SEARCH
                    self.PARSER = SearchParser( self.lang, self.VIDEOS )
                    self.PARSER.parse( 1, 200, search )
                    self.show_videos( self.VIDEOS )

            elif self.PARAM_SHOW_CATEGORIE in self.parameters.keys() and self.PARSER is not None:
                #on liste les videos arte event
                key = self.parameters[ self.PARAM_ARTE_CATEGORIE_KEY ].replace( 'brinbrin','&' )
                value = self.parameters[ self.PARAM_ARTE_CATEGORIE_VALUE ]

                if isinstance( self.PARSER, LiveParser ) :
                    self.PARSER.get_videos_list( key, self.VIDEOS )
                else:
                    self.NEXT_PAGE_NUMBER = self.PARSER.parse( value, self.PAGE_NUMBER, self.NB_VIDEOS_PER_PAGE )

                self.show_videos( self.VIDEOS )

            elif self.PARAM_NEXT_PAGE in self.parameters.keys() and self.PARSER is not None:
                #en cas de passage a la page suivante
                self.PAGE_NUMBER = self.parameters[ self.PARAM_NEXT_PAGE_NUMBER ]

                value = self.parameters[ self.PARAM_ARTE_CATEGORIE_VALUE ]
                self.NEXT_PAGE_NUMBER = self.PARSER.parse( value, self.PAGE_NUMBER, self.NB_VIDEOS_PER_PAGE )

                self.show_videos( self.VIDEOS )

            elif self.PARAM_PLAY_VIDEO in self.parameters.keys() and self.PARSER is not None:
                # On lance la video               
                hd = self.retrieveVideoLink( link = self.parameters[ self.PARAM_VIDEO_ID ] )

                if hd is None:
                    xbmc.executebuiltin( "XBMC.Notification(%s,%s)"%( __language__( 30300 ) , __language__( 30301 ) ) )

                else:

                    if isinstance(self.PARSER, LiveParser) :
                        hd, downloadParams = self.PARSER.decode_link( hd ) 

                    item = xbmcgui.ListItem( path = hd )
                    xbmcplugin.setResolvedUrl( handle = int( sys.argv[ 1 ] ), succeeded=True, listitem=item )
                
            elif self.PARAM_DOWNLOAD_VIDEO in self.parameters.keys() and self.PARSER is not None:
                # On telecharge la video
                video = {}
                name = self.parameters[ self.PARAM_VIDEO_NAME ]
                hd = self.retrieveVideoLink( link = self.parameters[ self.PARAM_VIDEO_ID ] )

                if hd is None:
                    xbmc.executebuiltin( "XBMC.Notification(%s,%s)"%( __language__( 30300 ), __language__( 30301 ) ) )

                else:
                    video[self.PARAM_VIDEO_ID] = hd
                    video[self.PARAM_VIDEO_NAME] = name
                    self.downloadVideo(video)

            else :
                #Probleme, pas de bon parametre detecte donc on initialise
                self.show_menu()

            _end_of_directory( True )

        except Exception,msg:
            xbmc.executebuiltin( "XBMC.Notification(%s,%s)"%( "ERROR select", msg ) ) 
            print ( "Error select" )
            print_exc()
            _end_of_directory( False )