Exemple #1
0
class Arte7Plugin:

    ADDON_DATA = xbmc.translatePath("special://profile/addon_data/%s/" %
                                    __addonID__)
    DOWNLOADDIR = os.path.join(ADDON_DATA, "downloads")

    # define param key names
    PARAM_DOWNLOAD_VIDEO = "dlvideo"
    PARAM_PLAY_VIDEO = "playvideo"
    PARAM_SHOW_CATEGORIE = "show_categorie"
    PARAM_VIDEO_ID = "video_id"
    PARAM_VIDEO_NAME = "video_name"

    PARAM_ARTE_PLUS = "arte_plus"
    PARAM_ARTE_LIVE = "arte_live"
    PARAM_ARTE_EVENT = "arte_event"
    PARAM_ARTE_BONUS = "arte_bonus"
    PARAM_ARTE_PROGRAMMES = "arte_programmes"
    PARAM_ARTE_SEARCH = "arte_search"

    PARAM_NEXT_PAGE = "arte_next_page"
    PARAM_NEXT_PAGE_NUMBER = "arte_next_page_number"

    PARAM_ARTE_CATEGORIE = "arte_categorie"
    PARAM_ARTE_CATEGORIE_KEY = "arte_categorie_key"
    PARAM_ARTE_CATEGORIE_VALUE = "arte_categorie_value"

    #verification du dossier de téléchargement
    dl_dir = __settings__.getSetting('downloadPath')
    if dl_dir != "":
        DOWNLOADDIR = dl_dir
    dirCheckList = (DOWNLOADDIR)

    #récupération des données pour pagination
    pluginhandle = int(sys.argv[1])
    numbers = ["10", "25", "50", "100"]
    NB_VIDEOS_PER_PAGE = numbers[int(
        __settings__.getSetting("nbVideoPerPage"))]
    PAGE_NUMBER = 1
    NEXT_PAGE_NUMBER = None

    #recupération de la langue
    lang_id = int(__settings__.getSetting('vid_language'))
    lang = ["fr", "de"][lang_id]

    quality = int(__settings__.getSetting('vid_quality'))

    if quality == 0:
        is_HD = True
    else:
        is_HD = False

    #Initialisation des principales variables
    ARTE_CATEGORIE = None
    PASER = None
    VIDEOS = []
    CATEGORIES = {}

    def __init__(self, *args, **kwargs):
        print "================================"
        print "Arte7 - DEMARRAGE"

        self.parameters = _parse_params()

        #on recupere le bon parser
        if self.PARAM_ARTE_CATEGORIE in self.parameters.keys():
            self.ARTE_CATEGORIE = self.parameters[self.PARAM_ARTE_CATEGORIE]
            self.PARSER = self.retrieveParser(self.lang)

        self.select()

    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)
from parsers import SearchParser

print "SEARCH ARTE PLUS"

videos = []
link = ""

#Init
searchParser = SearchParser("fr", videos)

#List videos
searchParser.parse(1, 200, "Le+grand+soir")
for video in videos:
    print "%s" % (video.title)
    link = video.link

#Get video rtmp link
searchParser.lang = "fr"
hd, sd = searchParser.fetch_stream_links(link)
print "%s" % (hd)
Exemple #3
0
class Arte7Plugin: 
    
    ADDON_DATA         = xbmc.translatePath( "special://profile/addon_data/%s/" % __addonID__ )
    DOWNLOADDIR        = os.path.join( ADDON_DATA, "downloads")
    
    # define param key names
    PARAM_DOWNLOAD_VIDEO              = "dlvideo"
    PARAM_PLAY_VIDEO                  = "playvideo"
    PARAM_SHOW_CATEGORIE              = "show_categorie"
    PARAM_VIDEO_ID                    = "video_id"
    PARAM_VIDEO_NAME                  = "video_name"

    PARAM_ARTE_PLUS                   = "arte_plus"
    PARAM_ARTE_LIVE                   = "arte_live"
    PARAM_ARTE_EVENT                  = "arte_event"
    PARAM_ARTE_BONUS                  = "arte_bonus"
    PARAM_ARTE_PROGRAMMES             = "arte_programmes"
    PARAM_ARTE_SEARCH                 = "arte_search"

    PARAM_NEXT_PAGE                   = "arte_next_page"
    PARAM_NEXT_PAGE_NUMBER            = "arte_next_page_number"

    PARAM_ARTE_CATEGORIE              = "arte_categorie"
    PARAM_ARTE_CATEGORIE_KEY          = "arte_categorie_key"
    PARAM_ARTE_CATEGORIE_VALUE        = "arte_categorie_value"

    #verification du dossier de téléchargement
    dl_dir = __settings__.getSetting( 'downloadPath' )
    if dl_dir != "":
        DOWNLOADDIR = dl_dir
    dirCheckList = ( DOWNLOADDIR )

    #récupération des données pour pagination
    pluginhandle = int( sys.argv[1] )
    numbers=[ "10","25","50","100" ]
    NB_VIDEOS_PER_PAGE=numbers[ int( __settings__.getSetting( "nbVideoPerPage" ) ) ]
    PAGE_NUMBER = 1
    NEXT_PAGE_NUMBER = None

    #recupération de la langue
    lang_id = int( __settings__.getSetting( 'vid_language' ) )
    lang    = [ "fr","de" ][ lang_id ]

    quality = int( __settings__.getSetting( 'vid_quality' ) )

    if quality == 0:
        is_HD = True
    else:
        is_HD = False

    #Initialisation des principales variables
    ARTE_CATEGORIE = None
    PASER          = None
    VIDEOS         = []
    CATEGORIES     = {}

    def __init__( self, *args, **kwargs ):
        print "================================"
        print "Arte7 - DEMARRAGE"

        self.parameters = _parse_params()

        #on recupere le bon parser
        if self.PARAM_ARTE_CATEGORIE in self.parameters.keys():
            self.ARTE_CATEGORIE = self.parameters[ self.PARAM_ARTE_CATEGORIE ]
            self.PARSER = self.retrieveParser( self.lang )

        self.select()

    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 )
from parsers import SearchParser

print "SEARCH ARTE PLUS"

videos = []
link = ""

#Init
searchParser = SearchParser("fr",videos)

#List videos
searchParser.parse(1, 200, "Le+grand+soir")
for video in videos :
	print "%s" %(video.title)
	link = video.link

#Get video rtmp link
searchParser.lang="fr"
hd, sd = searchParser.fetch_stream_links( link )
print "%s" %(hd)