Ejemplo n.º 1
0
    def _cleanstr(self, str):
        str = str.strip()
        if str.find("function") == 0:
            pattern = (r"=\"([^\"]+).*}\s*\((\d+)\)")
            args = re.search(pattern, str, re.DOTALL)
            if args:
                a = args.groups()

                def openload_re(match):
                    c = match.group(0)
                    b = ord(c) + int(a[1])
                    return chr(b if (90 if c <= "Z" else 122) >= b else b - 26)

                str = re.sub(r"[a-zA-Z]", openload_re, a[0])
                str = Unquote(str)

        elif str.find("decodeURIComponent") == 0:
            str = re.sub(r"(^decodeURIComponent\s*\(\s*('|\"))|(('|\")\s*\)$)",
                         "", str)
            str = Unquote(str)
        elif str.find("\"") == 0:
            str = re.sub(r"(^\")|(\"$)|(\".*?\")", "", str)
        elif str.find("'") == 0:
            str = re.sub(r"(^')|('$)|('.*?')", "", str)

        return str
Ejemplo n.º 2
0
    def __getMediaLinkForGuest(self):
        api_call = ''

        oParser = cParser()
        oRequestHandler = cRequestHandler(URL_MAIN + self.__sUrl)
        sHtml = Unquote(oRequestHandler.request())
        sHtmlContent = sHtml[7 + sHtml.find('formats'):sHtml.
                             rfind('adaptiveFormats')]
        sPattern = '"url":"([^"]+)".+?"qualityLabel":"([^"]+)"'
        aResult = oParser.parse(sHtmlContent, sPattern)

        if (aResult[0] == True):
            url = []
            qua = []
            for aEntry in aResult[1]:
                #Py3 a besoin de la deuxieme version, je laisse le 1er replace au cas où pour Py2
                url.append(aEntry[0].replace("\u0026",
                                             "&").replace("\\u0026", "&"))
                qua.append(aEntry[1])

            if url:
                if self.__res:
                    for i in range(len(qua)):
                        if qua[i] == self.__res:
                            api_call = url[i]
                if not api_call:
                    api_call = dialog().VSselectqual(qua, url)

        if api_call:
            return True, api_call
        else:
            return False
Ejemplo n.º 3
0
    def __getMediaLinkForGuest(self):
        api_call = ''

        oParser = cParser()

        oRequestHandler = cRequestHandler(self.__sUrl)
        oRequestHandler.addHeaderEntry(
            'User-Agent',
            'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
        )
        oRequestHandler.addHeaderEntry('Cookie',
                                       GestionCookie().Readcookie("youtube"))
        sHtml = Unquote(str(oRequestHandler.request()))

        sHtmlContent = sHtml[7 + sHtml.find('formats'):sHtml.
                             rfind('adaptiveFormats')]

        sPattern = '"url":"([^"]+)".+?"qualityLabel":"([^"]+)"'
        aResult = oParser.parse(sHtmlContent, sPattern)

        if (aResult[0] == True):
            url = []
            qua = []
            for aEntry in aResult[1]:
                #Py3 a besoin de la deuxieme version, je laisse le 1er replace au cas où pour Py2
                url.append(aEntry[0].replace('/&', '&').replace(
                    "\u0026", "&").replace("\\\\u0026", "&"))
                qua.append(aEntry[1])

            if url:
                if self.__res:
                    for i in range(len(qua)):
                        if qua[i] == self.__res:
                            api_call = url[i]
                if not api_call:
                    api_call = dialog().VSselectqual(qua, url)

        if api_call:
            return True, api_call
        else:
            return False
Ejemplo n.º 4
0
    def __getMediaLinkForGuest(self):
        api_call = ''
        UA = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'

        oParser = cParser()

        headers = {'User-Agent': UA}
        sHtml = Unquote(
            requests.get(self.__sUrl,
                         cookies={
                             'CONSENT': GestionCookie().Readcookie("youtube")
                         },
                         headers=headers).text)

        sHtmlContent = self.deescape(
            sHtml[7 + sHtml.find('formats'):sHtml.rfind('adaptiveFormats')])
        sPattern = '"url":"([^"]+)".+?"qualityLabel":"([^"]+)"'
        aResult = oParser.parse(sHtmlContent, sPattern)

        if (aResult[0] == True):
            url = []
            qua = []
            for aEntry in aResult[1]:
                # Py3 a besoin de la deuxieme version, je laisse le 1er replace au cas où pour Py2
                url.append(aEntry[0].replace('/&', '&').replace(
                    "\\\\u0026", "&").replace("\u0026", "&"))
                qua.append(aEntry[1])

            if url:
                if self.__res:
                    for i in range(len(qua)):
                        if qua[i] == self.__res:
                            api_call = url[i]
                if not api_call:
                    api_call = dialog().VSselectqual(qua, url)

        if api_call:
            return True, api_call
        else:
            return False