def get_url_with_headers(url, headers):
    if 'Accept-Encoding' in headers:
        del headers['Accept-Encoding']
    if 'Host' in headers:
        del headers['Host']
    parts = url.split('|')
    url = parts[0]
    url_headers = {}
    if len(parts) > 1:
        for i in re.finditer('(?:&|^)([^=]+)=(.+?)(?:&|$)', parts[-1]):
            if (i.group(1) == 'Cookie') and ('Cookie' in headers):
                headers['Cookie'] += urllib.unquote_plus(i.group(2))
            else:
                url_headers.update(
                    {i.group(1): urllib.unquote_plus(i.group(2))})
    url_headers.update(headers)
    cookie_string = ''
    if 'Cookie' in url_headers:
        cookie_string = ''.join(
            c.group(1)
            for c in re.finditer('(?:^|\s)(.+?=.+?;)', url_headers['Cookie']))
        del url_headers['Cookie']
    net = common.Net()
    cookie_jar_result = net.set_cookies(COOKIE_FILE)
    for c in net._cj:
        if c.domain and (c.domain.lstrip('.') in url):
            if c.value not in cookie_string:
                cookie_string += '%s=%s;' % (c.name, c.value)
    if cookie_string:
        return url + append_headers(
            url_headers) + '&Cookie=' + urllib.quote_plus(cookie_string)

    return url + append_headers(url_headers)
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {
            'User-Agent': common.FF_USER_AGENT,
            'Referer': 'https://vidembed.cc/'
        }

        key = '25746538592938496764662879833288'.encode('utf8')
        iv = self.f_random(16)
        encryptor = pyaes.Encrypter(
            pyaes.AESModeOfOperationCBC(key, iv.encode('utf8')))
        eid = encryptor.feed(media_id)
        eid += encryptor.feed()
        url = 'https://vidembed.cc' + '/encrypt-ajax.php?id=' + base64.b64encode(eid).decode('utf8') \
            + '&refer=none&time=' + self.f_random(2) + iv + self.f_random(2)
        headers.update({"X-Requested-With": "XMLHttpRequest"})
        js_data = json.loads(self.net.http_GET(url, headers=headers).content)
        sources = js_data.get('source', None)
        if sources:
            sources = [(source.get('label'), source.get('file'))
                       for source in sources]
            headers.pop('X-Requested-With')
            source = helpers.pick_source(helpers.sort_sources_list(sources))
            return source + helpers.append_headers(headers)

        # Try Beta Server if no sources found with earlier method
        headers.pop("X-Requested-With")
        html = self.net.http_GET(web_url, headers=headers).content
        sources = helpers.scrape_sources(html)
        if sources:
            headers.update({'Origin': 'https://vidembed.cc'})
            return helpers.pick_source(sources) + helpers.append_headers(
                headers)

        raise ResolverError('Video not found')
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.FF_USER_AGENT}
        html = self.net.http_GET(web_url, headers=headers).content
        headers.update({'Referer': web_url})

        match = re.search(r'Video is processing now\.', html)
        if match:
            raise ResolverError('Video is still processing. Try later')

        match = re.search(r'&hash=([^&]+)', html)
        if match:
            web_url = 'https://wolfstream.tv/dl?op=download_orig&id={0}&mode=o&hash={1}'.format(
                media_id, match.group(1))
            html2 = self.net.http_GET(web_url, headers=headers).content
            r = re.search(r'<a\s*href="([^"]+)[^>]+>Direct', html2)
            if r:
                return r.group(1) + helpers.append_headers(headers)

        match = re.search(r'(?:src|file):\s*"([^"]+)', html)
        if match:
            html2 = self.net.http_GET(match.group(1), headers=headers).content
            sources = re.findall(
                r'RESOLUTION=\d+x(?P<label>[\d]+).+\n(?!#)(?P<url>[^\n]+)',
                html2, re.IGNORECASE)
            if sources:
                return helpers.pick_source(helpers.sort_sources_list(
                    sources)) + helpers.append_headers(headers)

        raise ResolverError('Video Link Not Found')
Exemple #4
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        response, video_urls = self._parse_google(web_url)
        if video_urls:
            video = helpers.pick_source(video_urls)
        else:
            video = None

        headers = {'User-Agent': common.FF_USER_AGENT}
        if response is not None:
            res_headers = response.get_headers(as_dict=True)
            if 'Set-Cookie' in res_headers:
                headers['Cookie'] = res_headers['Set-Cookie']

        if not video:
            if ('redirector.' in web_url) or ('googleusercontent' in web_url):
                video = urllib2.urlopen(web_url).geturl()
            elif 'googlevideo.' in web_url:
                video = web_url + helpers.append_headers(headers)
        else:
            if ('redirector.' in video) or ('googleusercontent' in video):
                video = urllib2.urlopen(video).geturl()

        if video:
            if 'plugin://' in video:  # google plus embedded videos may result in this
                return video
            else:
                return video + helpers.append_headers(headers)

        raise ResolverError('File not found')
Exemple #5
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.CHROME_USER_AGENT}
        html = self.net.http_GET(web_url, headers=headers).content
        headers.update({'Referer': web_url})

        if 'sorry' in html:
            raise ResolverError("Video Deleted")

        r = re.search(r"redirect_vid\('([^']+)','([^']+)','([^']+)'", html)
        if r:
            surl = 'https://{0}/dl?op=download_orig&id={1}&mode={2}&hash={3}'.format(
                host, r.group(1), r.group(2), r.group(3)
            )
            dhtml = self.net.http_GET(surl, headers=headers).content
            s = re.search('href="([^"]+)">Direct', dhtml)
            if s:
                return s.group(1) + helpers.append_headers(headers)

        html += helpers.get_packed_data(html)
        sources = helpers.scrape_sources(html,
                                         patterns=[r'''sources:\s*\[(?:{file:)?\s*"(?P<url>[^"]+)'''],
                                         generic_patterns=False)
        if sources:
            return helpers.pick_source(sources) + helpers.append_headers(headers)

        raise ResolverError("Video not found")
    def get_media_url(self, host, media_id):
        video = None
        web_url = self.get_url(host, media_id)

        if xbmc.getCondVisibility(
                'System.HasAddon(plugin.googledrive)') and self.get_setting(
                    'use_gdrive') == "true":
            addon = xbmcaddon.Addon('plugin.googledrive')
            if six.PY3:
                db = xbmcvfs.translatePath(
                    addon.getAddonInfo('profile')) + 'accounts.db'
            else:
                db = xbmc.translatePath(
                    addon.getAddonInfo('profile')) + 'accounts.db'
            conn = sqlite3.connect(db)
            c = conn.cursor()
            c.execute("SELECT key FROM store;")
            driveid = c.fetchone()[0]
            conn.close()

            doc_id = re.search(r'[-\w]{25,}', web_url)
            if doc_id:
                common.kodi.notify(header=None,
                                   msg='Resolving with Google Drive',
                                   duration=3000)
                video = 'plugin://plugin.googledrive/?action=play&content_type=video&driveid={0}&item_id={1}'.format(
                    driveid, doc_id.group(0))

        if not video:
            response, video_urls = self._parse_google(web_url)
            if video_urls:
                video_urls.sort(key=self.__key, reverse=True)
                video = helpers.pick_source(video_urls)

            if response is not None:
                res_headers = response.get_headers(as_dict=True)
                if 'Set-Cookie' in res_headers:
                    self.headers['Cookie'] = res_headers['Set-Cookie']

        if not video:
            if any(url_match in web_url for url_match in self.url_matches):
                video = self._parse_redirect(web_url, hdrs=self.headers)
            elif 'googlevideo.' in web_url:
                video = web_url + helpers.append_headers(self.headers)
        elif 'plugin://' not in video:
            if any(url_match in video for url_match in self.url_matches):
                video = self._parse_redirect(video, hdrs=self.headers)

        if video:
            if 'plugin://' in video:  # google plus embedded videos may result in this
                return video
            else:
                return video + helpers.append_headers(self.headers)

        raise ResolverError('File not found')
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {
            'User-Agent': common.RAND_UA,
            'Referer': 'https://{0}/'.format(host)
        }

        r = self.net.http_GET(web_url, headers=headers)
        if r.get_url() != web_url:
            host = re.findall(r'(?://|\.)([^/]+)', r.get_url())[0]
            web_url = self.get_url(host, media_id)
        headers.update({'Referer': web_url})

        html = r.content
        match = re.search(
            r'''dsplayer\.hotkeys[^']+'([^']+).+?function\s*makePlay.+?return[^?]+([^"]+)''',
            html, re.DOTALL)
        if match:
            token = match.group(2)
            url = 'https://{0}{1}'.format(host, match.group(1))
            html = self.net.http_GET(url, headers=headers).content
            return self.dood_decode(html) + token + str(int(
                time.time() * 1000)) + helpers.append_headers(headers)

        raise ResolverError('Video Link Not Found')
Exemple #8
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)

        response = self.net.http_GET(web_url)
        html = response.content

        if html:
            try:
                js_data = json.loads(html)
                sources = [(video['key'], video['url'])
                           for video in js_data['videos']]
                sorted(sources)
                source = helpers.pick_source(sources)
                source = source.encode('utf-8') if helpers.PY2 else source
                if source.startswith("//"):
                    source = 'http:%s' % source
                return source + helpers.append_headers({
                    'Cookie':
                    response.get_headers(as_dict=True).get('Set-Cookie', '')
                })
            except:
                raise ResolverError('No playable video found.')

        else:
            raise ResolverError('No playable video found.')
Exemple #9
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.RAND_UA}
        r = self.net.http_GET(web_url, headers=headers)
        if r.get_url() != web_url:
            host = re.findall(r'(?://|\.)([^/]+)', r.get_url())[0]
            web_url = self.get_url(host, media_id)
        headers.update({'Referer': web_url})
        api_url = 'https://{0}/api/source/{1}'.format(host, media_id)
        r = self.net.http_POST(api_url, form_data={'r': '', 'd': host}, headers=headers)
        if r.get_url() != api_url:
            api_url = 'https://www.{0}/api/source/{1}'.format(host, media_id)
            r = self.net.http_POST(api_url, form_data={'r': '', 'd': host}, headers=headers)
        js_result = r.content

        if js_result:
            js_data = json.loads(js_result)
            if js_data.get('success'):
                sources = [(i.get('label'), i.get('file')) for i in js_data.get('data') if i.get('type') == 'mp4']
                common.logger.log(sources)
                sources = helpers.sort_sources_list(sources)
                rurl = helpers.pick_source(sources)
                str_url = self.net.http_HEAD(rurl, headers=headers).get_url()
                return str_url + helpers.append_headers(headers)

        raise ResolverError('Video not found')
Exemple #10
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.RAND_UA}
        html = self.net.http_GET(web_url, headers=headers).content

        if html:
            sources = []

            pattern = '''src:\s*canPlayDash\s*\?\s*['"]\s*(?P<dash>[^'"]+)\s*['"]\s*:\s*['"]\s*(?P<hls>[^'"]+)\s*['"]'''
            match = re.search(pattern=pattern, string=html)
            if not match:
                pattern = '''data-hls-url\s*=\s*['"]\s*(?P<hls>[^'"]+).+?data-mpd-url\s*=\s*['"]\s*(?P<dash>[^'"]+)'''
                match = re.search(pattern=pattern, string=html)

            if match:
                if self.dash_supported:
                    sources += [('Reddit', match.group('dash'))]
                else:
                    sources += [('Reddit', match.group('hls'))]

                if sources:
                    return helpers.pick_source(
                        sources) + helpers.append_headers(headers)

        raise ResolverError('File not found')
    def get_media_url(self, host, media_id):
        surl = 'https://evoload.io/SecurePlayer'
        web_url = self.get_url(host, media_id)
        rurl = 'https://{0}/'.format(host)
        headers = {'User-Agent': common.FF_USER_AGENT, 'Referer': rurl}
        html = self.net.http_GET(web_url, headers).content
        passe = re.search('<div id="captcha_pass" value="(.+?)"></div>',
                          html).group(1)
        headers.update({'Origin': rurl[:-1]})
        crsv = self.net.http_GET('https://csrv.evosrv.com/captcha?m412548',
                                 headers).content
        post = {
            "code": media_id,
            "csrv_token": crsv,
            "pass": passe,
            "token": "ok"
        }
        shtml = self.net.http_POST(surl,
                                   form_data=post,
                                   headers=headers,
                                   jdata=True).content
        r = json.loads(shtml).get('stream')
        if r:
            surl = r.get('backup') if r.get('backup') else r.get('src')
            if surl:
                return surl + helpers.append_headers(headers)

        raise ResolverError('File Not Found or removed')
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.CHROME_USER_AGENT}
        html = self.net.http_GET(web_url, headers=headers).content
        headers.update({'Referer': web_url})

        if 'sorry' in html:
            raise ResolverError("Video Deleted")

        if jsunhunt.detect(html):
            html = re.findall('<head>(.+?)</head>', html, re.DOTALL)[0]
            html = jsunhunt.unhunt(html)

        aurl = 'https://{0}/assets/js/tabber.js'.format(host)
        ahtml = self.net.http_GET(aurl, headers=headers).content
        if jsunhunt.detect(ahtml):
            pass
        else:
            aurl = 'https://{0}/assets/js/master.js'.format(host)
            ahtml = self.net.http_GET(aurl, headers=headers).content

        if jsunhunt.detect(ahtml):
            ahtml = jsunhunt.unhunt(ahtml)
            var, rep1, rep2 = re.findall(
                r'''var\s*res\s*=\s*([^.]+)\.replace\("([^"]+).+?replace\("([^"]+)''',
                ahtml, re.DOTALL)[0]
            r = re.search(r'var\s*{0}\s*=\s*"([^"]+)'.format(var), html)
            if r:
                surl = r.group(1).replace(rep1, '')
                surl = surl.replace(rep2, '')
                surl = base64.b64decode(surl).decode('utf-8')
                return surl.replace(' ',
                                    '%20') + helpers.append_headers(headers)

        raise ResolverError("Video not found")
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.RAND_UA}
        html = self.net.http_GET(web_url, headers=headers).content

        if html:
            if 'sucuri_cloudproxy_js' in html:
                cookie = self.sucuri(html)
                headers.update({'Referer': web_url, 'Cookie': cookie})
                html = self.net.http_GET(web_url, headers=headers).content

            sources = re.findall(
                '''<source\s*.+?label=['"](\w+)['"]\s*src=['"]([^'"]+)''',
                html)
            sources = [(i[0], i[1]) for i in sources
                       if not i[1] == "dead_link"]
            if sources:
                try:
                    sources.sort(key=lambda x: int(re.sub("\D", "", x[0])),
                                 reverse=True)
                except:
                    pass
                return helpers.pick_source(sources) + helpers.append_headers(
                    headers)

        raise ResolverError('File not found')
Exemple #14
0
 def get_media_url(self, host, media_id):
     web_url = self.get_url(host, media_id)
     headers = {'User-Agent': common.RAND_UA}
     html = self.net.http_GET(web_url, headers=headers).content
     
     if html:
         try:
             pattern = r"""{\s*vid:\s*'([^']+)',\s*hash\s*:\s*["\']([\da-f]{32})"""
             id, hash = re.findall(pattern, html)[0]
             hash_code = ''.join((self.encode_base_n(int(hash[lb:lb + 8], 16), 36) for lb in range(0, 32, 8)))
             load_url = 'https://www.eporner.com/xhr/video/%s?hash=%s&device=generic&domain=www.eporner.com&fallback=false&embed=false&supportedFormats=mp4' % (id, hash_code)
             headers.update({'Referer': web_url})
             r = self.net.http_GET(load_url, headers=headers).content
             r = r.replace("\/", "/")
             r = json.loads(r).get("sources", {}).get('mp4', {})
             sources = [(i, r[i].get("src")) for i in r]
             if len(sources) > 1:
                 try: sources.sort(key=lambda x: int(re.sub("\D", "", x[0])), reverse=True)
                 except: common.logger.log_debug('Scrape sources sort failed |int(re.sub("\D", "", x[0])|')
             
             return helpers.pick_source(sources) + helpers.append_headers(headers)
             
         except: 
             raise ResolverError('File not found')
     
     raise ResolverError('File not found')
    def get_media_url(self, host, media_id):
        if '$$' in media_id:
            media_id, referer = media_id.split('$$')
            referer = urllib_parse.urljoin(referer, '/')
        else:
            referer = False
        web_url = self.get_url(host, media_id)
        rurl = urllib_parse.urljoin(web_url, '/')
        if not referer:
            referer = rurl
        domain = 'aHR0cHM6Ly9zdHJlYW1yYXBpZC5ydTo0NDM.'
        headers = {'User-Agent': common.FF_USER_AGENT, 'Referer': referer}
        html = self.net.http_GET(web_url, headers).content
        token = helpers.girc(html, rurl, domain)
        number = re.findall(r"recaptchaNumber\s*=\s*'(\d+)", html)
        if token and number:
            eid, media_id = media_id.split('/')
            surl = 'https://streamrapid.ru/ajax/embed-{0}/getSources'.format(
                eid)
            if '?' in media_id:
                media_id = media_id.split('?')[0]
            data = {'_number': number[0], 'id': media_id, '_token': token}
            headers.update({'X-Requested-With': 'XMLHttpRequest'})
            shtml = self.net.http_GET('{0}?{1}'.format(
                surl, urllib_parse.urlencode(data)),
                                      headers=headers).content
            sources = json.loads(shtml).get('sources')
            if sources:
                source = sources[0].get('file')
                headers.pop('X-Requested-With')
                return source + helpers.append_headers(headers)

        raise ResolverError('File Not Found or removed')
    def get_media_url(self, host, media_id):
        surl = 'https://abcvideo.cc/dl'
        domain = 'aHR0cHM6Ly9hYmN2aWRlby5jYzo0NDM.'
        web_url = self.get_url(host, media_id)
        rurl = 'https://{0}/'.format(host)
        headers = {'User-Agent': common.FF_USER_AGENT, 'Referer': rurl}
        html = self.net.http_GET(web_url, headers).content
        token = helpers.girc(html, rurl, domain)
        if token:
            data = {
                'op': 'video_src',
                'file_code': media_id,
                'g-recaptcha-response': token
            }
            headers.update({'X-Requested-With': 'XMLHttpRequest'})
            shtml = self.net.http_GET('{0}?{1}'.format(
                surl, urllib_parse.urlencode(data)),
                                      headers=headers).content
            sources = helpers.scrape_sources(shtml)
            if sources:
                headers.pop('X-Requested-With')
                return helpers.pick_source(sources) + helpers.append_headers(
                    headers)

        raise ResolverError('File Not Found or removed')
Exemple #17
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.FF_USER_AGENT}
        html = self.net.http_GET(web_url, headers=headers).content
        stream_url = None
        try:
            stream_url = re.search(r'url\s*:\s*"(http.+?)"', html).group(1)
        except:
            pass

        if not stream_url:
            try:
                stream_url = re.search(r'unescape\(\'(http.+?)\'',
                                       html).group(1)
            except:
                pass

        if not stream_url:
            try:
                stream_url = base64.b64decode(
                    re.search(r'atob\(\'(.+?)\'', html).group(1))
            except:
                pass

        if not stream_url:
            raise ResolverError('File not found')

        return urllib_parse.unquote_plus(stream_url) + helpers.append_headers(
            headers)
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.RAND_UA}
        html = self.net.http_GET(web_url, headers=headers).content

        if html:
            try:
                params = "".join([
                    x.replace("' + '", "")
                    for x in self.between(html, "params += '", "';")
                ])
                vkey = params.split('=')[-1]
                m = hashlib.md5()
                m.update(vkey + 'PT6l13umqV8K827')
                params += '&pkey=%s' % m.hexdigest()
                params = urllib.unquote(params)
                url = 'http://www.drtuber.com/player_config/?' + params
                sources_html = self.net.http_GET(url, headers=headers).content
                if sources_html:
                    sources = helpers.scrape_sources(
                        sources_html,
                        patterns=[
                            """video_file>\<\!\[CDATA\[(?P<url>[^\]]+)"""
                        ])
                    if sources:
                        return helpers.pick_source(
                            sources) + helpers.append_headers(headers)
            except:
                raise ResolverError('File not found')

        raise ResolverError('File not found')
    def get_media_url(self, host, media_id, cached_only=False):
        torrent = False
        cached = self.__check_cache(media_id)
        media_id_lc = media_id.lower()
        if cached:
            logger.log_debug(
                'Premiumize.me: %s is readily available to stream' % media_id)
            if media_id_lc.endswith('.torrent') or media_id_lc.startswith(
                    'magnet:'):
                torrent = True
        elif media_id_lc.endswith('.torrent') or media_id_lc.startswith(
                'magnet:'):
            if self.get_setting('cached_only') == 'true' or cached_only:
                raise ResolverError(
                    'Premiumize.me: Cached torrents only allowed to be initiated'
                )
            torrent = True
            logger.log_debug(
                'Premiumize.me: initiating transfer to cloud for %s' %
                media_id)
            self.__initiate_transfer(media_id)
            self.__clear_finished()
            # self.__delete_folder()

        link = self.__direct_dl(media_id, torrent=torrent)
        if link is not None:
            logger.log_debug('Premiumize.me: Resolved to %s' % link)
            return link + helpers.append_headers(self.headers)

        raise ResolverError('Link Not Found')
Exemple #20
0
    def _parse_google(self, link):
        sources = []
        response = None
        if re.match('https?://get[.]', link):
            if link.endswith('/'): link = link[:-1]
            vid_id = link.split('/')[-1]
            response = self.net.http_GET(link)
            sources = self.__parse_gget(vid_id, response.content)
        elif re.match('https?://plus[.]', link):
            response = self.net.http_GET(link)
            sources = self.__parse_gplus(response.content)
        elif 'drive.google' in link or 'docs.google' in link:
            response = self.net.http_GET(link)
            sources = self._parse_gdocs(response.content)
##############################
        headers = {'User-Agent': common.FF_USER_AGENT}
        if response is not None:
            res_headers = response.get_headers(as_dict=True)
            if 'Set-Cookie' in res_headers:
                headers['Cookie'] = res_headers['Set-Cookie']
        sources_final = []
        for i in sources:
            if 'plugin://' in i[1]:  # google plus embedded videos may result in this
                break
            else:
                sources_final.append((i[0],i[1] + helpers.append_headers(headers)))
###################################            
##        print '_parse_google------------------------'
####        print response
##        print sources
##        print sources_final
        return response, sources_final#sources
Exemple #21
0
    def get_media_url(self, host, media_id):
        if '$$' in media_id:
            media_id, referer = media_id.split('$$')
            referer = urllib_parse.urljoin(referer, '/')
        else:
            referer = False

        web_url = self.get_url(host, media_id)
        if not referer:
            referer = urllib_parse.urljoin(web_url, '/')

        headers = {'User-Agent': common.FF_USER_AGENT, 'Referer': referer}

        html = self.net.http_GET(web_url, headers=headers).content
        if 'Please Wait' in html:
            raise ResolverError('Please Wait Video Uploading.')

        html = helpers.get_packed_data(html)
        sources = re.findall(
            r"label':\s*'(?P<label>[^']+).+?file':\s*'(?P<url>[^']+)", html)
        if sources:
            source = helpers.pick_source(sorted(sources, reverse=True))
            if source.startswith('/'):
                source = urllib_parse.urljoin(web_url, source)
            return source + helpers.append_headers(headers)

        raise ResolverError('No playable video found.')
Exemple #22
0
    def get_media_url(self, host, media_id):
        if '|' in media_id:
            media_id, referer = media_id.split('|')
        else:
            referer = False
        web_url = self.get_url(host, media_id)
        if not referer:
            referer = web_url
        headers = {'User-Agent': common.FF_USER_AGENT,
                   'Referer': referer}
        response = self.net.http_GET(web_url, headers=headers)
        html = response.content
        params = re.search(r'video:\s*([^;]+)', html)
        if params:
            params = params.group(1)
            id = re.findall(r'cdn_id:\s*"([^"]+)', params)[0]
            id1, id2 = id.split('_')
            server = re.findall(r'server:\s*"([^"]+)', params)[0][::-1]
            server = base64.b64decode(server.encode('ascii')).decode('ascii')
            sources = json.loads(re.findall(r'cdn_files:\s*([^}]+})', params)[0])
            sources = [(key[4:], 'https://{0}/videos/{1}/{2}/{3}'.format(server, id1, id2, sources[key].replace('.', '.mp4?extra=')))
                       for key in list(sources.keys())]
            return helpers.pick_source(sorted(sources, reverse=True)) + helpers.append_headers(headers)

        raise ResolverError('No playable video found.')
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        blurl = 'https://{0}/api/assets/userload/js/form.framework.js'.format(
            host)
        headers = {'User-Agent': common.RAND_UA}
        html = self.net.http_GET(web_url, headers=headers).content
        html = helpers.get_packed_data(html)
        headers.update({'Referer': web_url})
        bl = self.net.http_GET(blurl, headers=headers).content
        if jsunhunt.detect(bl):
            bl = jsunhunt.unhunt(bl)
        b1 = re.search(r'url:\s*"([^"]+)', bl)
        b2 = re.search(r'data:\s*{([^}]+)', bl)
        if b1 and b2:
            bd = re.findall(r'"([^"]+)":\s*([^,\s]+)', b2.group(1))
            data = {}
            for key, var in bd:
                r = re.search(r'{0}\s*=\s*"([^"]+)'.format(var), html)
                if r:
                    data.update({key: r.group(1)})

            if data:
                api_url = 'https://{0}{1}'.format(host, b1.group(1))
                headers.update({
                    'X-Requested-With': 'XMLHttpRequest',
                    'Origin': 'https://{0}'.format(host)
                })
                stream_url = self.net.http_POST(api_url, data,
                                                headers=headers).content
                headers.pop('X-Requested-With')
                stream_url = helpers.get_redirect_url(stream_url, headers)
                return stream_url + helpers.append_headers(headers)

        raise ResolverError('File not found')
Exemple #24
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.RAND_UA}
        html = self.net.http_GET(web_url, headers=headers).content

        if html:
            try:
                pattern = r"""ajax\(url,opts\);}}\)\(([\d]+),[\d]+,\[([\d,]+)\]\);"""
                url_id, quals = re.findall(pattern, html)[0]
                quals = quals.replace(',', '+')
                headers.update({'Referer': web_url, 'Origin': host})
                post_url = 'https://tkn.kodicdn.com/0000000%s/desktop/%s' % (
                    url_id, quals)
                html = self.net.http_POST(post_url,
                                          headers=headers,
                                          form_data='').content
                if html:
                    sources = helpers.scrape_sources(
                        html,
                        patterns=[
                            """['"](?P<label>\d+)['"]:{[\w":,]+token['"]:['"](?P<url>[^'"]+)"""
                        ])
                    if sources:
                        return helpers.pick_source(
                            sources) + helpers.append_headers(headers)
            except:
                raise ResolverError('File not found')

        raise ResolverError('File not found')
Exemple #25
0
 def get_media_url(self, host, media_id):
     url = self.get_url(host, media_id)
     api_base = 'https://api.k2s.cc/v1'
     headers = {
         'User-Agent': common.RAND_UA,
         'Referer': url,
         'Origin': 'https://k2s.cc'
     }
     data = {
         "grant_type": "client_credentials",
         "client_id": "k2s_web_app",
         "client_secret": "pjc8pyZv7vhscexepFNzmu4P"
     }
     t = self.net.http_POST(api_base + '/auth/token',
                            form_data=data,
                            headers=headers,
                            jdata=True).content
     access_token = json.loads(t).get('access_token')
     headers.update({'Authorization': 'Bearer {0}'.format(access_token)})
     s = self.net.http_GET('{0}/files/{1}?embed=permanentAbuse'.format(
         api_base, media_id),
                           headers=headers).content
     videourl = json.loads(s).get('videoPreview').get('video')
     if videourl:
         headers.pop('Authorization')
         return videourl + helpers.append_headers(headers)
     raise ResolverError(
         'The requested video was not found or may have been removed.')
Exemple #26
0
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.RAND_UA}
        html = self.net.http_GET(web_url, headers=headers).content

        if html:
            video_id = re.search("""playvideo\.php\?id=(\d+)""", html)
            if video_id:
                video_url = 'http://%s/jwplayer/playvideo.php?id=%s' % (
                    host, video_id.group(1))
                headers.update({'Referer': web_url})
                _html = self.net.http_GET(video_url, headers=headers).content
                if _html:
                    try:
                        _html = jsunpack.unpack(_html)
                    except Exception as e:
                        raise ResolverError(e)
                    sources = helpers.scrape_sources(
                        _html,
                        patterns=['''file:\s*["'](?P<url>http[^"']+)'''])
                    if sources:
                        return helpers.pick_source(
                            sources) + helpers.append_headers(headers)

        raise ResolverError('File not found')
 def get_media_url(self, host, media_id):
     web_url = self.get_url(host, media_id)
     headers = {
         'User-Agent': common.FF_USER_AGENT,
         'Referer': 'https://{0}/'.format(host)
     }
     try:
         r = self.net.http_GET(web_url, headers=headers).content
     except urllib_error.HTTPError:
         raise ResolverError('Video deleted or removed.')
         return
     src = re.findall(r'''ById\('.+?=\s*(["']//[^;<]+)''', r)
     if src:
         src_url = ''
         parts = src[-1].replace("'", '"').split('+')
         for part in parts:
             p1 = re.findall(r'"([^"]*)', part)[0]
             p2 = 0
             if 'substring' in part:
                 subs = re.findall(r'substring\((\d+)', part)
                 for sub in subs:
                     p2 += int(sub)
             src_url += p1[p2:]
         src_url += '&stream=1'
         src_url = 'https:' + src_url if src_url.startswith(
             '//') else src_url
         return helpers.get_redirect_url(
             src_url, headers) + helpers.append_headers(headers)
     raise ResolverError('Video cannot be located.')
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.FF_USER_AGENT}
        html = self.net.http_GET(web_url, headers=headers).content

        if 'Not Found' in html:
            raise ResolverError('File Removed')

        if 'Video is processing' in html:
            raise ResolverError('File still being processed')

        packed = re.search(r"JuicyCodes\.Run\((.+?)\)", html, re.I)
        if packed:
            from base64 import b64decode
            packed = packed.group(1).replace('"', '').replace('+', '')
            packed = b64decode(packed.encode('ascii'))
            html += '%s</script>' % packed.decode('latin-1').strip()

        source = helpers.scrape_sources(html)
        if source:
            headers.update({'Referer': web_url, 'Accept': '*/*'})
            vsrv = re.findall(r'//(\d+)/', source[0][1])[0]
            source = re.sub(r"//\d+/", "//{0}/".format(host),
                            source[0][1]) + '?s={0}&d='.format(vsrv)
            html = self.net.http_GET(source, headers=headers).content
            sources = re.findall(r'RESOLUTION=\d+x(\d+)\n([^\n]+)', html)
            return helpers.pick_source(helpers.sort_sources_list(
                sources)) + helpers.append_headers(headers)

        raise ResolverError('Video not found')
    def get_media_url(self, host, media_id):
        print ":::mid2", media_id

        try:
            headers = {'User-Agent': common.RAND_UA}
            if not media_id.isdigit():
                web_url = self.get_url(host, media_id)
                html = self.net.http_GET(web_url, headers=headers).content

                if html:
                    web_url = re.search(
                        """<iframe\s*width=['"]\d+['"]\s*height=['"]\d+['"]\s*src=['"](https:\/\/www\.watchmygf\.me\/embed\/(\d+))""",
                        html).groups()[0]
                else:
                    raise ResolverError('File not found')

            else:
                web_url = self.get_url(host, media_id)

            html2 = self.net.http_GET(web_url, headers=headers).content

            if html2:
                try:
                    file = re.search('''video_url:\s*['"]([^"']+)''', html2,
                                     re.DOTALL).groups()[0]

                    return file + helpers.append_headers(headers)

                except:
                    raise ResolverError('File not found')
            raise ResolverError('File not found')
        except:
            raise ResolverError('File not found')
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.RAND_UA}
        html = self.net.http_GET(web_url, headers=headers).content
        html = helpers.get_packed_data(html)
        r = re.search(r"op:\s*'([^']+)',\s*file_code:\s*'([^']+)',\s*hash:\s*'([^']+)'", html)
        if r:
            url = 'https://playtube.ws/dl'
            data = {'op': r.group(1),
                    'file_code': r.group(2),
                    'hash': r.group(3)}
            headers.update({'Referer': url[:-2],
                            'Origin': url[:-3]})

            vfile = seed = None
            tries = 0
            while tries < 3 and vfile is None and seed is None:
                resp = self.net.http_POST(url, form_data=data, headers=headers).content
                resp = json.loads(resp)[0]
                vfile = resp.get('file')
                seed = resp.get('seed')
                tries += 1
            source = helpers.tear_decode(vfile, seed)
            if source:
                return source + helpers.append_headers(headers)
        raise ResolverError('File not found')
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'User-Agent': common.RAND_UA}

        html = self.net.http_GET(web_url, headers=headers).content

        a = re.compile('''link: "([^'"]*mp4)''').findall(html)[0]
        b = re.compile('''aboutlink: '([^'"]*mp4)''').findall(html)[0]
        c = re.compile('''file: "([^'"]*mp4)''').findall(html)[0]

        stream_url = a or b or c #[:int(c)] + a[(int(c) + 10):]
        #stream_url = base64.b64decode(stream_url)

        return stream_url + helpers.append_headers(headers)