コード例 #1
0
 def __get_ajax_sources(self, html, page_url):
     stream_url = ''
     match = re.search('''\$\.getJSON\('([^']+)'\s*,\s*(\{.*?\})''', html)
     if match:
         ajax_url, params = match.groups()
         params = scraper_utils.parse_params(params)
         ajax_url = scraper_utils.urljoin(self.base_url, ajax_url)
         headers = {'Referer': page_url}
         headers.update(XHR)
         html = self._http_get(ajax_url, params=params, headers=headers, cache_limit=.5)
         js_data = scraper_utils.parse_json(html, ajax_url)
         stream_url = js_data.get('file', '')
     return stream_url
コード例 #2
0
 def __get_ajax_sources(self, html, page_url):
     stream_url = ''
     match = re.search('''\$\.getJSON\('([^']+)'\s*,\s*(\{.*?\})''', html)
     if match:
         ajax_url, params = match.groups()
         ajax_url = ajax_url + '?' + urllib.urlencode(scraper_utils.parse_params(params))
         ajax_url = urlparse.urljoin(self.base_url, ajax_url)
         headers = {'Referer': page_url}
         headers.update(XHR)
         html = self._http_get(ajax_url, headers=headers, cache_limit=.5)
         js_data = scraper_utils.parse_json(html, ajax_url)
         stream_url = js_data.get('file', '')
     return stream_url
コード例 #3
0
    def get_sources(self, video):
        source_url = self.get_url(video)
        hosters = []
        if source_url and source_url != FORCE_NO_MATCH:
            page_url = urlparse.urljoin(self.base_url, source_url)
            html = self._http_get(page_url, cache_limit=.5)
            hosters += self.__add_sources(dom_parser.parse_dom(html, 'a', {'rel': 'nofollow'}, ret='href'), video)
            
            sources = []
            for match in re.finditer('''\$\.get\('([^']+)'\s*,\s*(\{.*?\})''', html):
                ajax_url, params = match.groups()
                ajax_url = urlparse.urljoin(self.base_url, ajax_url)
                headers = {'Referer': page_url}
                headers.update(XHR)
                params = scraper_utils.parse_params(params)
                html = self._http_get(ajax_url, params=params, headers=headers, auth=False, cache_limit=.5)
                sources += dom_parser.parse_dom(html, 'source', {'type': '''video[^'"]*'''}, ret='src')
                sources += dom_parser.parse_dom(html, 'iframe', ret='src')

            base_quality = QUALITIES.HD720 if video.video_type == VIDEO_TYPES.MOVIE else QUALITIES.HIGH
            hosters += self.__add_sources(sources, video, base_quality)
        return hosters