Esempio n. 1
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'Referer': web_url}
        stream_url = ''
        vid_sel = web_url
        if ('picasaweb.' in host) or ('plus.' in host):
            vid_sel = ''
            videos = []
            vid_id = re.search('(?:.*?#|.+/)(.+?)(?:\?|$)', web_url)
            if vid_id:
                vid_id = vid_id.group(1)
                resp = self.net.http_GET(web_url, headers=headers)
                if 'picasaweb.' in host:
                    html = re.search(
                        '\["shared_group_' + re.escape(vid_id) +
                        '"\](.+?),"ccOverride":"false"}', resp.content,
                        re.DOTALL)
                    if html:
                        videos = re.compile(
                            ',{"url":"(https://.+?\.google(?:video|usercontent)\.com/.+?)","height":([0-9]+?),"width":([0-9]+?),"type":"video/.+?"}'
                        ).findall(html.group(1))
                elif 'plus.' in host:
                    html = re.search(
                        '"' + re.escape(vid_id) +
                        '",\[\](.+?),"https://video.googleusercontent.com/.*?"',
                        resp.content, re.DOTALL)
                    if html:
                        temp = re.compile(
                            '\[(\d+),(\d+),(\d+),"(.+?)"\]').findall(
                                html.group(1))
                        if temp:
                            for i, w, h, v in temp:
                                videos.append(
                                    [str(v).replace('\\u003d', '='),
                                     int(h)])
                vid_list = []
                url_list = []
                best = 0
                quality = 0
                if videos:
                    if len(videos) > 1:
                        for index, video in enumerate(videos):
                            if int(video[1]) > quality:
                                best = index
                            quality = int(video[1])
                            vid_list.extend(['GoogleVideo - %sp' % quality])
                            url_list.extend([video[0]])
                    if len(videos) == 1:
                        vid_sel = videos[0][0]
                    else:
                        if self.get_setting('auto_pick') == 'true':
                            vid_sel = url_list[best]
                        else:
                            result = xbmcgui.Dialog().select(
                                'Choose a link', vid_list)
                            if result != -1:
                                vid_sel = url_list[result]
                            else:
                                raise UrlResolver.ResolverError(
                                    'No link selected')
        if vid_sel:
            if ('redirector.' in vid_sel) or ('googleusercontent' in vid_sel):
                stream_url = urllib2.urlopen(vid_sel).geturl()
            elif 'google' in vid_sel:
                stream_url = vid_sel
            if stream_url:
                return stream_url

        raise UrlResolver.ResolverError('File not found')
Esempio n. 2
0
    def __decode_O(self, html):
        try:
            packed_data = re.search('>\s*(eval\s*\(function.*?)\s*</script>',
                                    html, re.DOTALL).group(1)
            new_str = re.search("decodeURIComponent\('(.*?)'\)",
                                packed_data).group(1)
            new_str = urllib.unquote(new_str)
            packed_data = re.sub('decodeURIComponent\(.*?\)',
                                 "'%s'" % (new_str), packed_data)
            match = re.search(',\s*\((.*?)\)\.split\([\'"](.*?)[\'"]\)',
                              packed_data)
            if match:
                split_str, delim = match.groups()
                new_split_str = eval(split_str)
                new_split_str = new_split_str.replace(delim, '|')
                packed_data = re.sub(
                    ',\s*\(.*?\)\.split\(.*?\)',
                    ", '%s'.split('%s')" % (new_split_str, '|'), packed_data)
            html = jsunpack.unpack(packed_data)
            html = html.replace('\\\\', '\\')

            O = {
                '___': 0,
                '$$$$': "f",
                '__$': 1,
                '$_$_': "a",
                '_$_': 2,
                '$_$$': "b",
                '$$_$': "d",
                '_$$': 3,
                '$$$_': "e",
                '$__': 4,
                '$_$': 5,
                '$$__': "c",
                '$$_': 6,
                '$$$': 7,
                '$___': 8,
                '$__$': 9,
                '$_': "constructor",
                '$$': "return",
                '_$': "o",
                '_': "u",
                '__': "t",
            }
            s1 = re.search('o\.\$\(o\.\$\((.*?)\)\(\)\)\(\);', html).group(1)
            s1 = s1.replace(' ', '')
            s1 = s1.replace('(![]+"")', 'false')
            s3 = ''
            for s2 in s1.split('+'):
                if s2.startswith('o.'):
                    s3 += str(O[s2[2:]])
                elif '[' in s2 and ']' in s2:
                    key = s2[s2.find('[') + 3:-1]
                    s3 += s2[O[key]]
                else:
                    s3 += s2[1:-1]

            s3 = s3.replace('\\\\', '\\')
            s3 = s3.decode('unicode_escape')
            s3 = s3.replace('\\/', '/')
            s3 = s3.replace('\\\\"', '"')
            s3 = s3.replace('\\"', '"')
            match = re.search('<source.+?src="([^"]+)', s3)
            return match.group(1)
        except Exception as e:
            raise UrlResolver.ResolverError('Decode-O Parsing Failure: %s' %
                                            (e))
Esempio n. 3
0
 def get_media_url(self, host, media_id):
     web_url = self.get_url(host, media_id)
     stream_url = None
     self.headers['Referer'] = web_url
     html = self.net.http_GET(web_url, headers=self.headers).content
     if isinstance(html, unicode):
         html = html.encode('utf-8', 'ignore')
     if 'This file is not available to stream yet' in html:
         web_url = 'http://uptobox.com/%s' % media_id
         self.headers['Referer'] = web_url
         html = self.net.http_GET(web_url, headers=self.headers).content
         if isinstance(html, unicode):
             html = html.encode('utf-8', 'ignore')
         if 'Uptobox.com is not available in your country' in html:
             raise UrlResolver.ResolverError(
                 'Uptobox.com is not available in your country')
         else:
             r = re.search(
                 '(You have to wait (?:[0-9]+ minute[s]*, )*[0-9]+ second[s]*)',
                 html)
             if r:
                 raise UrlResolver.ResolverError(r.group(1))
         r = re.search('<form\sname\s*=[\'"]F1[\'"].+?>(.+?)<br\s*/*>',
                       html, re.DOTALL)
         if r:
             r = r.group(1)
             form_data = {}
             form_inputs = re.compile(
                 'input\stype\s*=\s*[\'"]hidden[\'"]\sname\s*=\s*[\'"](.+?)[\'"]\svalue\s*=\s*[\'"](.+?)[\'"]\s*>'
             ).findall(r)
             if form_inputs:
                 for key, value in form_inputs:
                     form_data[key] = value
             html = self.net.http_POST(web_url,
                                       form_data=form_data,
                                       headers=self.headers).content
             if isinstance(html, unicode):
                 html = html.encode('utf-8', 'ignore')
             r = re.search(
                 '<a\shref\s*=[\'"](.+?)[\'"]\s*>\s*<span\sclass\s*=\s*[\'"]button_upload green[\'"]\s*>',
                 html)
             if r:
                 stream_url = r.group(1)
     else:
         r = re.search('<video\sid.+?>(.+?)</video>', html, re.DOTALL)
         if r:
             r = r.group(1)
             sources = re.compile(
                 '<source.+?src\s*=\s*[\'"](.+?)[\'"].+?data-res\s*=\s*[\'"](.+?)[\'"].*?/>'
             ).findall(r)
             if sources:
                 if len(sources) == 1:
                     stream_url = sources[0][0]
                 elif len(sources) > 1:
                     vid_list = []
                     for source, quality in sources:
                         vid_list.extend(['Uptobox - %s' % quality])
                     if self.get_setting('auto_pick') == 'true':
                         stream_url = sources[-1][0]
                     else:
                         result = xbmcgui.Dialog().select(
                             'Choose Quality', vid_list)
                         if result != -1:
                             stream_url = sources[result][0]
                         else:
                             raise UrlResolver.ResolverError(
                                 'No quality selected')
     if stream_url:
         return stream_url
     else:
         raise UrlResolver.ResolverError('File not found')
Esempio n. 4
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        link = self.net.http_GET(web_url).content
        if link.find('"error":') >= 0:
            err_title = re.compile('"title":"(.+?)"').findall(link)[0]
            if not err_title:
                err_title = 'Content not available.'

            err_message = re.compile('"message":"(.+?)"').findall(link)[0]
            if not err_message:
                err_message = 'No such video or the video has been removed due to copyright infringement issues.'

            raise UrlResolver.ResolverError(err_message)

        imgSrc = re.compile('"thumbnail_url":"(.+?)"').findall(link)[0]
        common.addon.log('img:' + imgSrc)

        dm_live = re.compile('live_rtsp_url":"(.+?)"', re.DOTALL).findall(link)
        dm_1080p = re.compile('"1080":.+?"url":"(.+?)"',
                              re.DOTALL).findall(link)
        dm_720p = re.compile('"720":.+?"url":"(.+?)"', re.DOTALL).findall(link)
        dm_high = re.compile('"480":.+?"url":"(.+?)"', re.DOTALL).findall(link)
        dm_low = re.compile('"380":.+?"url":"(.+?)"', re.DOTALL).findall(link)
        dm_low2 = re.compile('"240":.+?"url":"(.+?)"', re.DOTALL).findall(link)

        videoUrl = []

        if dm_live:
            liveVideoUrl = urllib.unquote_plus(dm_live[0]).replace("\\/", "/")
            liveVideoUrl = liveVideoUrl.replace("protocol=rtsp",
                                                "protocol=rtmp")
            liveVideoUrl = self.net.http_GET(liveVideoUrl).content
            videoUrl.append(liveVideoUrl)
        else:
            if dm_1080p:
                videoUrl.append(
                    urllib.unquote_plus(dm_1080p[0]).replace("\\/", "/"))
            if dm_720p:
                videoUrl.append(
                    urllib.unquote_plus(dm_720p[0]).replace("\\/", "/"))
            if dm_high:
                videoUrl.append(
                    urllib.unquote_plus(dm_high[0]).replace("\\/", "/"))
            if dm_low:
                videoUrl.append(
                    urllib.unquote_plus(dm_low[0]).replace("\\/", "/"))
            if dm_low2:
                videoUrl.append(
                    urllib.unquote_plus(dm_low2[0]).replace("\\/", "/"))

        vUrl = ''
        vUrlsCount = len(videoUrl)
        if vUrlsCount > 0:
            q = self.get_setting('quality')
            if q == '0':
                # Highest Quality
                vUrl = videoUrl[0]
            elif q == '1':
                # Medium Quality
                vUrl = videoUrl[(int)(vUrlsCount / 2)]
            elif q == '2':
                # Lowest Quality
                vUrl = videoUrl[vUrlsCount - 1]

        common.addon.log('url:' + vUrl)
        return vUrl
Esempio n. 5
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content

        html = re.search('({"context".+?)\);\n', html, re.DOTALL)
        if html:
            html = json.loads(html.group(1))
            if 'metadata' in html: html = html['metadata']
            else: return

        if 'error' in html:
            err_title = html['error']
            if 'title' in err_title:
                err_title = err_title['title']
            else:
                err_title = 'Content not available.'
            raise UrlResolver.ResolverError(err_title)

        if 'qualities' in html:
            html = html['qualities']

        videoUrl = []
        try:
            videoUrl.append(html['1080'][0]['url'])
        except:
            pass
        try:
            videoUrl.append(html['720'][0]['url'])
        except:
            pass
        try:
            videoUrl.append(html['480'][0]['url'])
        except:
            pass
        try:
            videoUrl.append(html['380'][0]['url'])
        except:
            pass
        try:
            videoUrl.append(html['240'][0]['url'])
        except:
            pass
        try:
            videoUrl.append(html['auto'][0]['url'])
        except:
            pass

        vUrl = ''
        vUrlsCount = len(videoUrl)
        if vUrlsCount > 0:
            q = self.get_setting('quality')
            if q == '0':
                # Highest Quality
                vUrl = videoUrl[0]
            elif q == '1':
                # Medium Quality
                vUrl = videoUrl[(int)(vUrlsCount / 2)]
            elif q == '2':
                # Lowest Quality
                vUrl = videoUrl[vUrlsCount - 1]

        vUrl = urllib2.urlopen(urllib2.Request(vUrl)).geturl()
        return vUrl