当前位置: 首页>>代码示例>>Python>>正文


Python scraper_utils.parse_json函数代码示例

本文整理汇总了Python中salts_lib.scraper_utils.parse_json函数的典型用法代码示例。如果您正苦于以下问题:Python parse_json函数的具体用法?Python parse_json怎么用?Python parse_json使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_json函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __get_gk_links

 def __get_gk_links(self, html, page_url):
     sources = {}
     for link in dom_parser.parse_dom(html, 'div', {'class': '[^"]*server_line[^"]*'}):
         film_id = dom_parser.parse_dom(link, 'a', ret='data-film')
         name_id = dom_parser.parse_dom(link, 'a', ret='data-name')
         server_id = dom_parser.parse_dom(link, 'a', ret='data-server')
         if film_id and name_id and server_id:
             data = {'ipplugins': 1, 'ip_film': film_id[0], 'ip_server': server_id[0], 'ip_name': name_id[0]}
             headers = XHR
             headers['Referer'] = page_url
             url = urlparse.urljoin(self.base_url, LINK_URL)
             html = self._http_get(url, data=data, headers=headers, cache_limit=.25)
             js_data = scraper_utils.parse_json(html, url)
             if 's' in js_data:
                 url = urlparse.urljoin(self.base_url, LINK_URL2)
                 params = {'u': js_data['s'], 'w': '100%', 'h': 420}
                 html = self._http_get(url, params=params, data=data, headers=headers, cache_limit=.25)
                 js_data = scraper_utils.parse_json(html, url)
                 if 'data' in js_data and js_data['data']:
                     if isinstance(js_data['data'], basestring):
                         sources[js_data['data']] = QUALITIES.HIGH
                     else:
                         for link in js_data['data']:
                             stream_url = link['files']
                             if self._get_direct_hostname(stream_url) == 'gvideo':
                                 quality = scraper_utils.gv_get_quality(stream_url)
                             elif 'quality' in link:
                                 quality = scraper_utils.height_get_quality(link['quality'])
                             else:
                                 quality = QUALITIES.HIGH
                             sources[stream_url] = quality
     return sources
开发者ID:EPiC-APOC,项目名称:repository.xvbmc,代码行数:32,代码来源:tunemovie_scraper.py

示例2: _get_episode_url

    def _get_episode_url(self, show_url, video):
        params = urlparse.parse_qs(show_url)
        cmd = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %s, "season": %s, "filter": {"field": "%s", "operator": "is", "value": "%s"}, \
        "limits": { "start" : 0, "end": 25 }, "properties" : ["title", "season", "episode", "file", "streamdetails"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true }}, "id": "libTvShows"}'
        base_url = 'video_type=%s&id=%s'
        episodes = []
        force_title = scraper_utils.force_title(video)
        if not force_title:
            run = cmd % (params['id'][0], video.season, 'episode', video.episode)
            meta = xbmc.executeJSONRPC(run)
            meta = scraper_utils.parse_json(meta)
            log_utils.log('Episode Meta: %s' % (meta), log_utils.LOGDEBUG)
            if 'result' in meta and 'episodes' in meta['result']:
                episodes = meta['result']['episodes']
        else:
            log_utils.log('Skipping S&E matching as title search is forced on: %s' % (video.trakt_id), log_utils.LOGDEBUG)

        if (force_title or kodi.get_setting('title-fallback') == 'true') and video.ep_title and not episodes:
            run = cmd % (params['id'][0], video.season, 'title', video.ep_title)
            meta = xbmc.executeJSONRPC(run)
            meta = scraper_utils.parse_json(meta)
            log_utils.log('Episode Title Meta: %s' % (meta), log_utils.LOGDEBUG)
            if 'result' in meta and 'episodes' in meta['result']:
                episodes = meta['result']['episodes']

        for episode in episodes:
            if episode['file'].endswith('.strm'):
                continue
            
            return base_url % (video.video_type, episode['episodeid'])
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:30,代码来源:local_scraper.py

示例3: _parse_google

    def _parse_google(self, link):
        sources = []
        html = self._http_get(link, cache_limit=.25)
        match = re.search('pid=([^&]+)', link)
        if match:
            vid_id = match.group(1)
            sources = self.__parse_gplus(vid_id, html, link)
        else:
            if 'drive.google' in link or 'docs.google' in link:
                sources = self._parse_gdocs(link)
            if 'picasaweb' in link:
                i = link.rfind('#')
                if i > -1:
                    link_id = link[i + 1:]
                else:
                    link_id = ''
                match = re.search('feedPreload:\s*(.*}]}})},', html, re.DOTALL)
                if match:
                    js = scraper_utils.parse_json(match.group(1), link)
                    for item in js['feed']['entry']:
                        if not link_id or item['gphoto$id'] == link_id:
                            for media in item['media']['content']:
                                if media['type'].startswith('video'):
                                    sources.append(media['url'].replace('%3D', '='))
                else:
                    match = re.search('preload\'?:\s*(.*}})},', html, re.DOTALL)
                    if match:
                        js = scraper_utils.parse_json(match.group(1), link)
                        for media in js['feed']['media']['content']:
                            if media['type'].startswith('video'):
                                sources.append(media['url'].replace('%3D', '='))

        sources = list(set(sources))
        return sources
开发者ID:EPiC-APOC,项目名称:repository.xvbmc,代码行数:34,代码来源:scraper.py

示例4: get_sources

 def get_sources(self, video):
     source_url = self.get_url(video)
     hosters = []
     sources = {}
     if source_url and source_url != FORCE_NO_MATCH:
         url = urlparse.urljoin(self.base_url, source_url)
         html = self._http_get(url, cache_limit=.5)
         for server_list in dom_parser.parse_dom(html, 'ul', {'class': 'episodes'}):
             for hash_id in dom_parser.parse_dom(server_list, 'a', ret='data-id'):
                 now = time.localtime()
                 url = urlparse.urljoin(self.base_url, HASH_URL)
                 url = url % (hash_id, now.tm_hour + now.tm_min)
                 html = self._http_get(url, headers=XHR, cache_limit=.5)
                 js_result = scraper_utils.parse_json(html, url)
                 if 'videoUrlHash' in js_result and 'grabber' in js_result:
                     query = {'flash': 1, 'json': 1, 's': now.tm_min, 'link': js_result['videoUrlHash'], '_': int(time.time())}
                     query['link'] = query['link'].replace('\/', '/')
                     grab_url = js_result['grabber'].replace('\/', '/')
                     grab_url += '?' + urllib.urlencode(query)
                     html = self._http_get(grab_url, headers=XHR, cache_limit=.5)
                     js_result = scraper_utils.parse_json(html, grab_url)
                     for result in js_result:
                         if 'label' in result:
                             quality = scraper_utils.height_get_quality(result['label'])
                         else:
                             quality = scraper_utils.gv_get_quality(result['file'])
                         sources[result['file']] = quality
             
         for source in sources:
             hoster = {'multi-part': False, 'host': self._get_direct_hostname(source), 'class': self, 'quality': sources[source], 'views': None, 'rating': None, 'url': source, 'direct': True}
             hosters.append(hoster)
     return hosters
开发者ID:assli100,项目名称:kodi-openelec,代码行数:32,代码来源:9movies_scraper.py

示例5: get_sources

    def get_sources(self, video):
        source_url = self.get_url(video)
        hosters = []
        sources = {}
        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)
            html = self.__get_players(html, page_url)
            players = list(set(re.findall("load_player\(\s*'([^']+)'\s*,\s*'?(\d+)\s*'?", html)))
            player_url = urlparse.urljoin(self.base_url, PLAYER_URL)
            for link_id, height in players:
                params = {'id': link_id, 'quality': height, '_': int(time.time() * 1000)}
                player_url2 = player_url + '?' + urllib.urlencode(params)
                headers = {'Referer': page_url, 'Accept-Encoding': 'gzip, deflate', 'Server': 'cloudflare-nginx', 'Accept-Formating': 'application/json, text/javascript'}
                headers.update(XHR)
                html = self._http_get(player_url2, headers=headers, cache_limit=0)
                js_data = scraper_utils.parse_json(html, player_url)
                if js_data.get('playlist', ''):
                    link_url = js_data['playlist']
                else:
                    link_url = js_data.get('link', '')
                    
                if link_url:
                    headers = {'Referer': page_url}
                    html = self._http_get(link_url, headers=headers, allow_redirect=False, method='HEAD', cache_limit=0)
                    if html.startswith('http'):
                        streams = [html]
                    else:
                        headers = {'Referer': page_url}
                        html = self._http_get(link_url, headers=headers, cache_limit=0)
                        js_data = scraper_utils.parse_json(html, link_url)
                        try: streams = [source['file'] for source in js_data[0]['sources']]
                        except: streams = []
                        
                    for stream in streams:
                        if self._get_direct_hostname(stream) == 'gvideo':
                            quality = scraper_utils.gv_get_quality(stream)
                            sources[stream] = {'quality': quality, 'direct': True}
                        else:
                            if height != '0':
                                quality = scraper_utils.height_get_quality(height)
                            else:
                                quality = QUALITIES.HIGH
                            sources[stream] = {'quality': quality, 'direct': False}
                    
            for source in sources:
                direct = sources[source]['direct']
                quality = sources[source]['quality']
                if direct:
                    host = self._get_direct_hostname(source)
                else:
                    host = urlparse.urlparse(source).hostname

                stream_url = source + '|User-Agent=%s' % (scraper_utils.get_ua())
                hoster = {'multi-part': False, 'host': host, 'class': self, 'quality': quality, 'views': None, 'rating': None, 'url': stream_url, 'direct': direct}
                hosters.append(hoster)
            
        return hosters
开发者ID:EPiC-APOC,项目名称:repository.xvbmc,代码行数:58,代码来源:xmovies8v2_scraper.py

示例6: _parse_google

    def _parse_google(self, link):
        sources = []
        html = self._http_get(link, cache_limit=0.5)
        match = re.search("pid=([^&]+)", link)
        if match:
            vid_id = match.group(1)
            match = re.search("return\s+(\[\[.*?)\s*}}", html, re.DOTALL)
            if match:
                try:
                    js = scraper_utils.parse_json(match.group(1), link)
                    for item in js[1]:
                        vid_match = False
                        for e in item:
                            if e == vid_id:
                                vid_match = True

                            if vid_match:
                                if isinstance(e, dict):
                                    for key in e:
                                        for item2 in e[key]:
                                            try:
                                                for item3 in item2:
                                                    for item4 in item3:
                                                        if isinstance(item4, basestring):
                                                            for match in re.finditer("url=([^&]+)", item4):
                                                                sources.append(urllib.unquote(match.group(1)))
                                            except Exception as e:
                                                log_utils.log(
                                                    "Exception during google plus parse: %s" % (e), log_utils.LOGDEBUG
                                                )
                except Exception as e:
                    log_utils.log("Google Plus Parse failure: %s - %s" % (link, e), log_utils.LOGWARNING)
        else:
            i = link.rfind("#")
            if i > -1:
                link_id = link[i + 1 :]
                match = re.search("feedPreload:\s*(.*}]}})},", html, re.DOTALL)
                if match:
                    js = scraper_utils.parse_json(match.group(1), link)
                    for item in js["feed"]["entry"]:
                        if item["gphoto$id"] == link_id:
                            for media in item["media"]["content"]:
                                if media["type"].startswith("video"):
                                    sources.append(media["url"].replace("%3D", "="))
            else:
                match = re.search("preload'?:\s*(.*}})},", html, re.DOTALL)
                if match:
                    js = scraper_utils.parse_json(match.group(1), link)
                    for media in js["feed"]["media"]["content"]:
                        if media["type"].startswith("video"):
                            sources.append(media["url"].replace("%3D", "="))

        return sources
开发者ID:dannythomas13,项目名称:tknorris-beta-repo,代码行数:53,代码来源:scraper.py

示例7: _parse_google

    def _parse_google(self, link):
        sources = []
        html = self._http_get(link, cache_limit=.5)
        match = re.search('pid=([^&]+)', link)
        if match:
            vid_id = match.group(1)
            match = re.search('return\s+(\[\[.*?)\s*}}', html, re.DOTALL)
            if match:
                try:
                    js = scraper_utils.parse_json(match.group(1), link)
                    for item in js[1]:
                        vid_match = False
                        for e in item:
                            if e == vid_id:
                                vid_match = True

                            if vid_match:
                                    if isinstance(e, dict):
                                        for key in e:
                                            for item2 in e[key]:
                                                try:
                                                    for item3 in item2:
                                                        for item4 in item3:
                                                            if isinstance(item4, basestring):
                                                                for match in re.finditer('url=([^&]+)', item4):
                                                                    sources.append(urllib.unquote(match.group(1)))
                                                except Exception as e:
                                                    log_utils.log('Exception during google plus parse: %s' % (e), log_utils.LOGDEBUG)
                except Exception as e:
                    log_utils.log('Google Plus Parse failure: %s - %s' % (link, e), log_utils.LOGWARNING)
        else:
            i = link.rfind('#')
            if i > -1:
                link_id = link[i + 1:]
                match = re.search('feedPreload:\s*(.*}]}})},', html, re.DOTALL)
                if match:
                    js = scraper_utils.parse_json(match.group(1), link)
                    for item in js['feed']['entry']:
                        if item['gphoto$id'] == link_id:
                            for media in item['media']['content']:
                                if media['type'].startswith('video'):
                                    sources.append(media['url'].replace('%3D', '='))
            else:
                match = re.search('preload\'?:\s*(.*}})},', html, re.DOTALL)
                if match:
                    js = scraper_utils.parse_json(match.group(1), link)
                    for media in js['feed']['media']['content']:
                        if media['type'].startswith('video'):
                            sources.append(media['url'].replace('%3D', '='))

        return sources
开发者ID:Stevie-Bs,项目名称:repository.xvbmc,代码行数:51,代码来源:scraper.py


注:本文中的salts_lib.scraper_utils.parse_json函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。