Ejemplo n.º 1
0
    def viewSimil(self):
        sPluginPath = cPluginHandler().getPluginPath()

        oInputParameterHandler = cInputParameterHandler()
        sCleanTitle = oInputParameterHandler.getValue(
            'sFileName') if oInputParameterHandler.exist(
                'sFileName') else xbmc.getInfoLabel(
                    'ListItem.Property(sCleanTitle)')
        sCat = oInputParameterHandler.getValue(
            'sCat') if oInputParameterHandler.exist(
                'sCat') else xbmc.getInfoLabel('ListItem.Property(sCat)')

        oOutputParameterHandler = cOutputParameterHandler()
        oOutputParameterHandler.addParameter('searchtext', sCleanTitle)
        oOutputParameterHandler.addParameter('sCat', sCat)
        oOutputParameterHandler.addParameter('readdb', 'False')

        sParams = oOutputParameterHandler.getParameterAsUri()
        sTest = '%s?site=%s&function=%s&%s' % (sPluginPath, 'globalSearch',
                                               'globalSearch', sParams)

        # Si lancé depuis la page Home de Kodi, il faut d'abord en sortir pour lancer la recherche
        if xbmc.getCondVisibility('Window.IsVisible(home)'):
            xbmc.executebuiltin('ActivateWindow(%d)' % (10028))

        xbmc.executebuiltin('Container.Update(%s)' % sTest)

        return False
Ejemplo n.º 2
0
 def enable_addon(self,addon):
     #import json
     #sCheck = {'jsonrpc': '2.0','id': 1,'method': 'Addons.GetAddonDetails','params': {'addonid':'inputstream.adaptive','properties': ['enabled']}}
     #response = xbmc.executeJSONRPC(json.dumps(sCheck))
     #data = json.loads(response)
     #if not 'error' in data.keys():      
     #if data['result']['addon']['enabled'] == False:
     
     if xbmc.getCondVisibility('System.HasAddon(inputstream.adaptive)') == 0:
         do_json = '{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{"addonid":"inputstream.adaptive","enabled":true}}'
         query = xbmc.executeJSONRPC(do_json)
         VSlog("Activation d'inputstream.adaptive")
     else:
         VSlog('inputstream.adaptive déjà activé')
Ejemplo n.º 3
0
 def enable_addon(self,addon):
     #import json
     #sCheck = {'jsonrpc': '2.0','id': 1,'method': 'Addons.GetAddonDetails','params': {'addonid':'inputstream.adaptive','properties': ['enabled']}}
     #response = xbmc.executeJSONRPC(json.dumps(sCheck))
     #data = json.loads(response)
     #if not 'error' in data.keys():      
     #if data['result']['addon']['enabled'] == False:
     
     if xbmc.getCondVisibility('System.HasAddon(inputstream.adaptive)') == 0:
         do_json = '{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{"addonid":"inputstream.adaptive","enabled":true}}'
         query = xbmc.executeJSONRPC(do_json)
         VSlog("Activation d'inputstream.adaptive")
     else:
         VSlog('inputstream.adaptive déjà activé')
Ejemplo n.º 4
0
 def TextBoxes(self, anounce):
     # activate the text viewer window
     xbmc.executebuiltin("ActivateWindow(%d)" % (10147, ))
     # get window
     win = window(10147)
     #win.show()
     # give window time to initialize
     xbmc.sleep(100)
     # set heading
     win.getControl(1).setLabel("vStream mise à jour")
     win.getControl(5).setText(anounce)
     while xbmc.getCondVisibility("Window.IsActive(10147)"):
         xbmc.sleep(100)
     ret = dialog().VSok('Mise à jour terminée')
     return
Ejemplo n.º 5
0
 def TextBoxes(self, anounce):
     addons = addon()
     # activate the text viewer window
     xbmc.executebuiltin('ActivateWindow(%d)' % (10147))
     # get window
     win = window(10147)
     # win.show()
     # give window time to initialize
     xbmc.sleep(100)
     # set heading
     win.getControl(1).setLabel(addons.VSlang(30013))
     win.getControl(5).setText(anounce)
     while xbmc.getCondVisibility('Window.IsActive(10147)'):
         xbmc.sleep(100)
     ret = dialog().VSok(addons.VSlang(30014))
     return
Ejemplo n.º 6
0
    def getToken(self):

        result = self._call('authentication/token/new', '')

        total = len(result)

        if (total > 0):
            url = 'https://www.themoviedb.org/authenticate/'
            if not xbmc.getCondVisibility('system.platform.android'):
                #Si possible on ouvre la page automatiquement dans un navigateur internet.
                webbrowser.open(url + result['request_token'])
                sText = (self.ADDON.VSlang(30421)) % (url,
                                                      result['request_token'])
                DIALOG = dialog()
                if not DIALOG.VSyesno(sText):
                    return False
            else:
                from resources.lib import pyqrcode
                qr = pyqrcode.create(url + result['request_token'])
                qr.png(
                    'special://home/userdata/addon_data/plugin.video.vstream/qrcode.png',
                    scale=5)
                oSolver = cInputWindowYesNo(
                    captcha=
                    'special://home/userdata/addon_data/plugin.video.vstream/qrcode.png',
                    msg="Scanner le QRCode pour acceder au lien d'autorisation",
                    roundnum=1)
                retArg = oSolver.get()
                DIALOG = dialog()
                if retArg == "N":
                    return False

            result = self._call('authentication/session/new',
                                'request_token=' + result['request_token'])

            if 'success' in result and result['success']:
                self.ADDON.setSetting('tmdb_session',
                                      str(result['session_id']))
                DIALOG.VSinfo(self.ADDON.VSlang(30000))
                return
            else:
                DIALOG.VSerror('Erreur' + self.ADDON.VSlang(30000))
                return

            # xbmc.executebuiltin('Container.Refresh')
            return
        return
Ejemplo n.º 7
0
 def TextBoxes(self, anounce):
     # activate the text viewer window
     xbmc.executebuiltin( "ActivateWindow(%d)" % ( 10147, ) )
     # get window
     win = window(10147)
     #win.show()
     # give window time to initialize
     xbmc.sleep(100)
     # set heading
     win.getControl(1).setLabel("vStream mise à jour")
     win.getControl(5).setText(anounce)
     while xbmc.getCondVisibility("Window.IsActive(10147)"):
         xbmc.sleep(100)
     ret = dialog().VSok('Mise à jour terminée')
     if ret:
         xbmc.executebuiltin("Container.Refresh")
     return
Ejemplo n.º 8
0
    def run(self):

        try:
            #Recuperation url simple
            url = self.__sUrl.split('|')[0]
            #Recuperation des headers du lien
            headers = {}
            if len(self.__sUrl.split('|')) > 1:
                u = self.__sUrl.split('|')[1].split('&')
                for i in u:
                    headers[i.split('=')[0]] = i.replace(
                        i.split('=')[0] + '=', '')

            #Rajout du user-agent si abscent
            if not ('User-Agent' in headers):
                headers[
                    'User-Agent'] = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'

            req = urllib2.Request(url, None, headers)

            self.oUrlHandler = urllib2.urlopen(req, timeout=30)
            #self.__instance = repr(self)
            self.file = xbmcvfs.File(self.__fPath, 'w')
        except:
            VSlog('download error')
            VSlog(self.__sUrl)
            self.DIALOG.VSinfo('Erreur initialisation', 'Download error')
            return

        # if not Memorise.lock('VstreamDownloaderLock'):
        #     self.DIALOG.VSinfo('Téléchargements déjà démarrés', 'Download error')
        #     return

        if xbmc.getCondVisibility('Window.IsVisible(10151)'):
            self.DIALOG.VSinfo('Téléchargements déjà démarrés', 'Erreur')
            return

        self._StartDownload()
Ejemplo n.º 9
0
    def run(self):

        try:
            #Recuperation url simple
            url = self.__sUrl.split('|')[0]
            #Recuperation des headers du lien
            headers = {}
            if len (self.__sUrl.split('|')) > 1:
                u = self.__sUrl.split('|')[1].split('&')
                for i in u:
                    headers[i.split('=')[0]] = i.replace(i.split('=')[0] + '=','')

            #Rajout du user-agent si abscent
            if not ('User-Agent' in headers):
                headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'

            req = urllib2.Request(url, None, headers)

            self.oUrlHandler = urllib2.urlopen(req,timeout=30)
            #self.__instance = repr(self)
            self.file = xbmcvfs.File(self.__fPath, 'w')
        except:
            VSlog('download error')
            VSlog(self.__sUrl)
            self.DIALOG.VSinfo('Erreur initialisation', 'Download error')
            return

        # if not Memorise.lock("VstreamDownloaderLock"):
        #     self.DIALOG.VSinfo('Telechargements deja demarrés', 'Download error')
        #     return

        if xbmc.getCondVisibility("Window.IsVisible(10151)"):
            self.DIALOG.VSinfo('Telechargements deja demarrés', 'Erreur')
            return

        self._StartDownload()
Ejemplo n.º 10
0
    def isDownloading(self):

        if not xbmc.getCondVisibility('Window.IsVisible(10151)'):
            return False
        return True
Ejemplo n.º 11
0
    def getFav(self):
        oGui = cGui()
        oInputParameterHandler = cInputParameterHandler()

        row = cDb().get_bookmark()

        if (oInputParameterHandler.exist('sCat')):
            sCat = oInputParameterHandler.getValue('sCat')

            # Série, Animes, Saison et Episodes sont visibles dans les marques-page "Séries"
            catList = ('2', '3', '4', '8')
            if sCat in catList:
                sCat = 2
                cGui.CONTENT = 'tvshows'
            else:
                catList = ('1', '7')  # films, saga
                cGui.CONTENT = 'movies'
                if sCat in catList:
                    sCat = 1
                else:
                    catList = sCat
                    cGui.CONTENT = 'videos'
            gen = (x for x in row if x['cat'] in catList)
        else:
            oGui.setEndOfDirectory()
            return

        for data in gen:

            try:
                title = data['title'].encode('utf-8')
            except:
                title = data['title']

            try:
                thumbnail = data['icon'].encode('utf-8')
            except:
                thumbnail = data['icon']

            try:
                try:
                    siteurl = data['siteurl'].encode('utf-8')
                except:
                    siteurl = data['siteurl']

                if isMatrix():
                    siteurl = UnquotePlus(siteurl.decode('utf-8'))
                    title = str(title, 'utf-8')
                else:
                    siteurl = UnquotePlus(siteurl)

                site = data['site']
                function = data['fav']
                cat = data['cat']
                fanart = data['fanart']

                if thumbnail == '':
                    thumbnail = 'False'

                oOutputParameterHandler = cOutputParameterHandler()
                oOutputParameterHandler.addParameter('siteUrl', siteurl)
                oOutputParameterHandler.addParameter('sMovieTitle', title)
                oOutputParameterHandler.addParameter('searchtext', title)
                oOutputParameterHandler.addParameter('sThumbnail', thumbnail)
                # Dans ajouter source c'est bien sThumb donc...
                oOutputParameterHandler.addParameter('sThumb', thumbnail)

                if (function == 'play'):
                    oHoster = cHosterGui().checkHoster(siteurl)
                    oOutputParameterHandler.addParameter(
                        'sHosterIdentifier', oHoster.getPluginIdentifier())
                    oOutputParameterHandler.addParameter(
                        'sFileName', oHoster.getFileName())
                    oOutputParameterHandler.addParameter('sMediaUrl', siteurl)

                oGuiElement = cGuiElement()
                oGuiElement.setSiteName(site)
                oGuiElement.setFunction(function)
                oGuiElement.setTitle(title)
                oGuiElement.setFileName(title)
                oGuiElement.setIcon("mark.png")
                if (cat == '1'):  # Films
                    oGuiElement.setMeta(1)
                    oGuiElement.setCat(1)
                elif (cat == '2'):  # Séries
                    oGuiElement.setMeta(2)
                    oGuiElement.setCat(2)
                elif (cat == '3'):  # Anime
                    oGuiElement.setMeta(4)
                    oGuiElement.setCat(3)
                elif (cat == '4'):  # Saisons
                    oGuiElement.setMeta(5)
                    oGuiElement.setCat(4)
                elif (cat == '5'):  # Divers
                    oGuiElement.setMeta(0)
                    oGuiElement.setCat(5)
                elif (cat == '6'):  # TV (Officiel)
                    oGuiElement.setMeta(0)
                    oGuiElement.setCat(6)
                elif (cat == '7'):  # Saga
                    oGuiElement.setMeta(3)
                    oGuiElement.setCat(7)
                elif (cat == '8'):  # Episodes
                    oGuiElement.setMeta(6)
                    oGuiElement.setCat(8)
                else:
                    oGuiElement.setMeta(0)
                    oGuiElement.setCat(cat)
                oGuiElement.setThumbnail(thumbnail)
                oGuiElement.setFanart(fanart)
                oGuiElement.addItemProperties('isBookmark', True)

                oGui.CreateSimpleMenu(oGuiElement, oOutputParameterHandler,
                                      'cFav', 'cFav', 'delBookmark',
                                      self.ADDON.VSlang(30412))

                if (function == 'play'):
                    oGui.addHost(oGuiElement, oOutputParameterHandler)
                else:
                    oGui.addFolder(oGuiElement, oOutputParameterHandler)

            except:
                oOutputParameterHandler = cOutputParameterHandler()
                oGui.addDir(SITE_IDENTIFIER, 'DoNothing',
                            '[COLOR red]ERROR[/COLOR]', 'films.png',
                            oOutputParameterHandler)

        # La suppression n'est pas accessible lors de l'utilisation en Widget
        if not xbmc.getCondVisibility('Window.IsActive(home)'):
            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('sCat', sCat)
            oGui.addDir(SITE_IDENTIFIER, 'delBookmark',
                        self.ADDON.VSlang(30211), 'trash.png',
                        oOutputParameterHandler)

        oGui.setEndOfDirectory()

        return
Ejemplo n.º 12
0
        def onClick(self, controlId):


            if controlId == 11:














                from resources.lib.ba import cShowBA
                cBA = cShowBA()
                cBA.SetSearch(sFileName)


                cBA.SetYear(year)
                cBA.SetTrailerUrl(self.getProperty('trailer'))
                cBA.SearchBA(True)
                return

            elif controlId == 30:
                self.close()
                return

            elif controlId == 50 or controlId == 5200 :
                # print(self.getControl(50).ListItem.Property('id'))
                item = self.getControl(controlId).getSelectedItem()
                sid = item.getProperty('id')
                

                grab = cTMDb()
                sUrl = 'person/' + str(sid)
                
                
                try:
                    meta = grab.getUrl(sUrl, '', "append_to_response=movie_credits,tv_credits")
                    meta_credits = meta['movie_credits']['cast']
                    self.credit(meta_credits, 5215)
                    
         
                    try:
                        sTitle = unicodedata.normalize('NFKD', meta['name']).encode('ascii', 'ignore')
                    except:
                        sTitle = 'Aucune information'
                    
                    if not meta['deathday']:
                        today = date.today()
                        try:
                            birthday = datetime(*(time.strptime(meta['birthday'], '%Y-%m-%d')[0:6]))
                            age = today.year - birthday.year - ((today.month, today.day) < (birthday.month, birthday.day))
                            age = '%s Ans' % age
                        except:
                            age = ''
                    else:
                        age = meta['deathday']
                        
                  
                    self.setProperty('Person_name', sTitle)
                    self.setProperty('Person_birthday', meta['birthday'])
                    self.setProperty('Person_place_of_birth', meta['place_of_birth'])
                    self.setProperty('Person_deathday', str(age))
                    self.setProperty('Person_biography', meta['biography']) 
                    self.setFocusId(9000)                   
       
                except:
                    return
                # self.getControl(50).setVisible(True)
                self.setProperty('matrix_menu', 'Person')
            
            # click sur similaire
            elif controlId == 9:
                # print(self.getControl(9000).ListItem.tmdb_id)
                sid = self.getProperty('tmdb_id')

                grab = cTMDb()
                sUrl_simil = 'movie/%s/similar' % str(sid)
                sUrl_recom = 'movie/%s/recommendations' % str(sid)
                
                try:
                    meta = grab.getUrl(sUrl_simil)
                    meta = meta['results']

                    self.credit(meta, 5205)


                except:








                    pass
                try:
                    meta = grab.getUrl(sUrl_recom)
                    meta = meta['results']

                    self.credit(meta, 5210)



                except:
                    return

            # click pour recherche
            elif controlId == 5215 or controlId == 5205 or controlId == 5210:


                import sys
                from resources.lib.util import cUtil
                item = self.getControl(controlId).getSelectedItem()
                sTitle = item.getLabel()

                try:
                    sTitle = sTitle.encode('utf-8')
                    sTitle = cUtil().CleanName(sTitle)
                except:
                    return



                self.close()



                # Si lancé depuis la page Home de Kodi, il faut d'abord en sortir pour lancer la recherche
                if xbmc.getCondVisibility('Window.IsVisible(home)'):
                    xbmc.executebuiltin('ActivateWindow(%d)' % (10028))

                sTest = '%s?site=globalSearch&searchtext=%s&sCat=1' % (sys.argv[0], sTitle)
                xbmc.executebuiltin('Container.Update(%s)' % sTest)
                return
Ejemplo n.º 13
0
    def getViewing(self):
        oGui = cGui()
        DB = cDb()
        # oInputParameterHandler = cInputParameterHandler()

        row = DB.get_viewing()
        if not row:
            oGui.setEndOfDirectory()
            return

        for data in row:

            try:
                title = data['title'].encode('utf-8')
            except:
                title = data['title']

            try:
                try:
                    siteurl = data['siteurl'].encode('utf-8')
                except:
                    siteurl = data['siteurl']

                if isMatrix():
                    siteurl = UnquotePlus(siteurl.decode('utf-8'))
                    title = str(title, 'utf-8')
                else:
                    siteurl = UnquotePlus(siteurl)

                sTitleWatched = data['title_id']
                site = data['site']
                function = data['fav']
                cat = data['cat']
                sSeason = data['season']
                sTmdbId = data['tmdb_id']  # if 'tmdb_id' in data else None

                oOutputParameterHandler = cOutputParameterHandler()
                oOutputParameterHandler.addParameter('siteUrl', siteurl)
                oOutputParameterHandler.addParameter('sMovieTitle', title)
                oOutputParameterHandler.addParameter('sTmdbId', sTmdbId)
                oOutputParameterHandler.addParameter('sTitleWatched',
                                                     sTitleWatched)
                oOutputParameterHandler.addParameter('sSeason', sSeason)
                oOutputParameterHandler.addParameter('sCat', cat)
                oOutputParameterHandler.addParameter('isViewing', True)

                # pourcentage de lecture
                meta = {}
                meta['title'] = sTitleWatched
                resumetime, totaltime = DB.get_resume(meta)
                oOutputParameterHandler.addParameter('ResumeTime', resumetime)
                oOutputParameterHandler.addParameter('TotalTime', totaltime)

                if cat == '1':
                    oListItem = oGui.addMovie(site, function, title,
                                              'films.png', '', title,
                                              oOutputParameterHandler)
                elif cat == '5':
                    oListItem = oGui.addMisc(site, function, title,
                                             'films.png', '', title,
                                             oOutputParameterHandler)
                elif cat == '4':
                    oListItem = oGui.addSeason(site, function, title,
                                               'series.png', '', title,
                                               oOutputParameterHandler)
                else:
                    oListItem = oGui.addTV(site, function, title, 'series.png',
                                           '', title, oOutputParameterHandler)

                oOutputParameterHandler.addParameter('sTitleWatched',
                                                     sTitleWatched)
                oOutputParameterHandler.addParameter('sCat', cat)
                oListItem.addMenu(SITE_IDENTIFIER, 'delViewing',
                                  self.ADDON.VSlang(30412),
                                  oOutputParameterHandler)

            except Exception as e:
                pass

        # Vider toute la catégorie n'est pas accessible lors de l'utilisation en Widget
        if not xbmc.getCondVisibility('Window.IsActive(home)'):
            oOutputParameterHandler = cOutputParameterHandler()
            oGui.addDir(SITE_IDENTIFIER, 'delViewing',
                        self.ADDON.VSlang(30211), 'trash.png',
                        oOutputParameterHandler)

        oGui.setEndOfDirectory()

        return
Ejemplo n.º 14
0
    def getFav(self):
        oGui = cGui()
        oInputParameterHandler = cInputParameterHandler()

        row = cDb().get_bookmark()

        if (oInputParameterHandler.exist('sCat')):
            sCat = oInputParameterHandler.getValue('sCat')
            gen = (x for x in row if x[5] in sCat)
        else:
            sCat = '5'
            gen = (x for x in row if x[5] not in ('1', '2', '6'))

        for data in gen:

            try:
                title = data[1].encode('utf-8')
            except:
                title = data[1]

            try:
                thumbnail = data[6].encode('utf-8')
            except:
                thumbnail = data[6]

            try:
                try:
                    siteurl = data[2].encode('utf-8')
                except:
                    siteurl = data[2]

                if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
                    siteurl = UnquotePlus(siteurl.decode('utf-8'))
                    title = str(title, 'utf-8')
                else:
                    siteurl = UnquotePlus(siteurl)

                site = data[3]
                function = data[4]
                cat = data[5]
                fanart = data[7]

                if thumbnail == '':
                    thumbnail = 'False'

                oOutputParameterHandler = cOutputParameterHandler()
                oOutputParameterHandler.addParameter('siteUrl', siteurl)
                oOutputParameterHandler.addParameter('sMovieTitle', title)
                oOutputParameterHandler.addParameter('searchtext', title)
                oOutputParameterHandler.addParameter('sThumbnail', thumbnail)
                # Dans ajouter source c'est bien sThumb donc...
                oOutputParameterHandler.addParameter('sThumb', thumbnail)

                if (function == 'play'):
                    oHoster = cHosterGui().checkHoster(siteurl)
                    oOutputParameterHandler.addParameter(
                        'sHosterIdentifier', oHoster.getPluginIdentifier())
                    oOutputParameterHandler.addParameter(
                        'sFileName', oHoster.getFileName())
                    oOutputParameterHandler.addParameter('sMediaUrl', siteurl)

                oGuiElement = cGuiElement()
                oGuiElement.setSiteName(site)
                oGuiElement.setFunction(function)
                oGuiElement.setTitle(title)
                oGuiElement.setFileName(title)
                oGuiElement.setIcon("mark.png")
                if (cat == '1'):
                    cGui.CONTENT = 'movies'
                    oGuiElement.setMeta(1)
                    oGuiElement.setCat(1)
                elif (cat == '2'):
                    cGui.CONTENT = 'tvshows'
                    oGuiElement.setMeta(2)
                    oGuiElement.setCat(2)
                else:
                    oGuiElement.setMeta(0)
                    oGuiElement.setCat(cat)
                oGuiElement.setThumbnail(thumbnail)
                oGuiElement.setFanart(fanart)
                oGuiElement.addItemProperties('isBookmark', True)

                oGui.CreateSimpleMenu(oGuiElement, oOutputParameterHandler,
                                      'cFav', 'cFav', 'delBookmark',
                                      self.ADDON.VSlang(30412))

                if (function == 'play'):
                    oGui.addHost(oGuiElement, oOutputParameterHandler)
                else:
                    oGui.addFolder(oGuiElement, oOutputParameterHandler)

            except:
                oGui.addDir(SITE_IDENTIFIER, 'DoNothing',
                            '[COLOR red]ERROR[/COLOR]', 'films.png',
                            oOutputParameterHandler)

        # La suppression n'est pas accessible lors de l'utilisation en Widget
        if not xbmc.getCondVisibility('Window.IsActive(home)'):
            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('sCat', sCat)
            oGui.addDir(SITE_IDENTIFIER, 'delBookmark',
                        self.ADDON.VSlang(30211), 'trash.png',
                        oOutputParameterHandler)

        oGui.setEndOfDirectory()

        return
Ejemplo n.º 15
0
    def getMediaLink(self):
        self.oPremiumHandler = cPremiumHandler('uptobox')
        premium = self.oPremiumHandler.isPremiumModeAvailable()
        api_call = False
        SubTitle = ""

        if premium:
            self.oPremiumHandler.Authentificate()
        else:
            dialog().VSok('Ce hoster demande un login, meme gratuit.')
            return False, False

        cookies = GestionCookie().Readcookie("uptobox")

        s = requests.Session()
        s.headers.update({"Cookie": cookies})

        r = s.get('https://uptobox.com/api/streaming?file_code=' + self.__sUrl.split('/')[-1]).json()
        
        if r["statusCode"] != 0: # Erreur
            dialog().VSinfo(r["data"])
            return False, False

        r1 = s.get(r["data"]["user_url"]).text
        tok = re.search('token.+?;.+?;(.+?)&', r1).group(1)

        if not xbmc.getCondVisibility('system.platform.android'):
            # Si possible on ouvre la page automatiquement dans un navigateur internet.
            import webbrowser
            webbrowser.open(r['data']['user_url'])
            with CountdownDialog("Autorisation nécessaire", "Pour voir cette vidéo, veuillez vous connecter", "Allez sur ce lien : " + r['data']['user_url'], "Et valider le pin : " + r['data']['pin'], True, r["data"]['expired_in'], 10) as cd:
                js_result = cd.start(self.__check_auth, [r["data"]["check_url"]])["data"]
        else:
            from resources.lib import pyqrcode
            from resources.lib.librecaptcha.gui import cInputWindowYesNo
            qr = pyqrcode.create(r['data']['user_url'])
            qr.png('special://home/userdata/addon_data/plugin.video.vstream/qrcode.png', scale=5)
            oSolver = cInputWindowYesNo(captcha='special://home/userdata/addon_data/plugin.video.vstream/qrcode.png', msg="Scanner le QRCode pour acceder au lien d'autorisation", roundnum=1)
            retArg = oSolver.get()
            DIALOG = dialog()
            if retArg == "N":
                return False

            js_result = s.get(r["data"]["check_url"]).json()["data"]

        #Deux modes de fonctionnement different.
        if js_result.get("streamLinks").get('src'):
            api_call = js_result['streamLinks']['src'].replace(".m3u8",".mpd")
        else:
            sPattern = "'(.+?)': {(.+?)}"

            oParser = cParser()
            aResult = oParser.parse(js_result["streamLinks"], sPattern)

            url = []
            qua = []
            api_call = False

            for aEntry in aResult[1]:
                QUAL = aEntry[0]
                d = re.findall("'u*(.+?)': u*'(.+?)'",aEntry[1])
                for aEntry1 in d:
                    url.append(aEntry1[1])
                    qua.append(QUAL  + ' (' + aEntry1[0] + ')')

            # Affichage du tableau
            api_call = dialog().VSselectqual(qua, url)

        try:
            SubTitle = self.checkSubtitle(js_result["subs"])
        except:
            VSlog("Pas de sous-titre")

        if (api_call):
            if SubTitle:
                return True, api_call, SubTitle
            else:
                return True, api_call

        return False, False
Ejemplo n.º 16
0
    def isDownloading(self):

        if not xbmc.getCondVisibility("Window.IsVisible(10151)"):
            return False
        return True
Ejemplo n.º 17
0
    def __getMediaLinkForGuest(self):
        api_call = False

        headers = {'User-Agent': UA}
        if xbmc.getCondVisibility('system.platform.android'):
            oRequest = cRequestHandler(self.__sUrl)
            oRequest.addHeaderEntry('User-Agent', UA)
            sHtmlContent = oRequest.request()
            urlDonwload = oRequest.getRealUrl()
        else:
            if isMatrix():
                import urllib.request as urllib
            else:
                import urllib

            req = urllib.Request(self.__sUrl, None, headers)
            with urllib.urlopen(req) as response:
                sHtmlContent = response.read()
                urlDonwload = response.geturl()

        try:
            sHtmlContent = sHtmlContent.decode('utf8')
        except:
            pass

        oParser = cParser()

        possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
        fin_url = ''.join(random.choice(possible) for _ in range(10))

        sPattern = 'return a\+"(\?token=[^"]+)"'
        d = oParser.parse(sHtmlContent, sPattern)[1][0]

        fin_url = fin_url + d + str(int(1000 * time.time()))

        sPattern = "\$\.get\('(\/pass_md5[^']+)"
        aResult = oParser.parse(sHtmlContent, sPattern)
        url2 = 'https://' + urlDonwload.split('/')[2] + aResult[1][0]

        headers.update({'Referer': urlDonwload})
        if xbmc.getCondVisibility('system.platform.android'):
            oRequest = cRequestHandler(url2)
            oRequest.addHeaderEntry('User-Agent', UA)
            oRequest.addHeaderEntry('Referer', urlDonwload)
            sHtmlContent = oRequest.request()
        else:
            req = urllib.Request(url2, None, headers)
            with urllib.urlopen(req) as response:
                sHtmlContent = response.read()

        try:
            sHtmlContent = sHtmlContent.decode('utf8')
        except:
            pass

        api_call = sHtmlContent + fin_url

        #VSlog(api_call)

        if (api_call):
            api_call = api_call + '|Referer=' + urlDonwload
            return True, api_call

        return False, False