本文整理汇总了Python中util.request函数的典型用法代码示例。如果您正苦于以下问题:Python request函数的具体用法?Python request怎么用?Python request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了request函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: resolve
def resolve(self,item,captcha_cb=None,wait_cb=None):
item = item.copy()
url = self._url(item['url'])
item['surl'] = url
data = util.request(url)
link = re.search('<a class="stahnoutSoubor.+?href=\"([^\"]+)',data)
if link:
url = self._url(link.group(1))
data = util.request(url)
m = re.search('<img src=\"(?P<img>[^\"]+)\" alt=\"Captcha\"',data)
cap_id = re.search('<input type=\"hidden\" name=\"_uid_captcha.+?value=\"(?P<cid>[^\"]+)',data)
if m and cap_id:
cid = cap_id.group('cid')
img_data = m.group('img')[m.group('img').find('base64,')+7:]
if not os.path.exists(self.tmp_dir):
os.makedirs(self.tmp_dir)
tmp_image = os.path.join(self.tmp_dir,'captcha.png')
util.save_data_to_file(base64.b64decode(img_data),tmp_image)
code = captcha_cb({'id':cid,'img': tmp_image})
if not code:
return
data = util.post(url+'?do=stahnoutFreeForm-submit',{'_uid_captcha':cid,'captcha':code,'stahnoutSoubor':'Stáhnout'})
countdown = re.search('shortly\.getSeconds\(\) \+ (\d+)',data)
last_url = re.search('<a class=\"stahnoutSoubor2.+?href=\"([^\"]+)',data)
if countdown and last_url:
wait = int(countdown.group(1))
url = self._url(last_url.group(1))
wait_cb(wait)
req = urllib2.Request(url)
req.add_header('User-Agent',util.UA)
resp = urllib2.urlopen(req)
item['url'] = resp.geturl()
return item
开发者ID:vrockai,项目名称:xbmc-doplnky,代码行数:33,代码来源:bezvadata.py
示例2: _resolve_vod
def _resolve_vod(self, item):
resolved = []
data = util.request(self._url(item['url']))
video_id = re.search("LiveboxPlayer.archiv\(.+?videoId:\s*'([^']+)'", data, re.DOTALL).group(1)
#print "video_id", video_id
player_data = util.request("http://embed.livebox.cz/ta3_v2/vod-source.js", {'Referer':self._url(item['url'])})
#print "player_data", player_data
url_format = re.search(r'my.embedurl = \[\{"src" : "([^"]+)"', player_data).group(1)
#print "url_format", url_format
manifest_url = "https:" + url_format.format(video_id)
#print "manifest_url", manifest_url
manifest = util.request(manifest_url)
print "manifest", manifest
for m in re.finditer('#EXT-X-STREAM-INF:PROGRAM-ID=\d+,BANDWIDTH=(?P<bandwidth>\d+).*?(,RESOLUTION=(?P<resolution>\d+x\d+))?\s(?P<chunklist>[^\s]+)', manifest, re.DOTALL):
item = self.video_item()
item['surl'] = item['title']
item['quality'] = m.group('bandwidth')
item['url'] = manifest_url[:manifest_url.rfind('/')+1] + m.group('chunklist')
resolved.append(item)
resolved = sorted(resolved, key=lambda x:int(x['quality']), reverse=True)
if len(resolved) == 3:
qualities = ['720p', '480p', '360p']
for idx, item in enumerate(resolved):
item['quality'] = qualities[idx]
else:
for idx, item in enumerate(resolved):
item['quality'] += 'b/s'
return resolved
开发者ID:kodi-czsk,项目名称:plugin.video.ta3.com,代码行数:28,代码来源:ta3.py
示例3: resolve
def resolve(self,item,captcha_cb=None):
item = item.copy()
url = item['url']
if url.startswith('http://www.ulozto.sk'):
url = 'http://www.ulozto.cz' + url[20:]
if url.startswith('#'):
ret = json.loads(util.request(url[1:]))
if not ret['result'] == 'null':
url = b64decode(ret['result'])
url = self._url(url)
if url.startswith('#'):
util.error('[uloz.to] - url was not correctly decoded')
return
self.init_urllib()
self.info('Resolving %s'% url)
logged_in = self.login()
if logged_in:
page = util.request(url)
else:
try:
request = urllib2.Request(url)
response = urllib2.urlopen(request)
page = response.read()
response.close()
except urllib2.HTTPError, e:
traceback.print_exc()
return
开发者ID:vrockai,项目名称:xbmc-doplnky,代码行数:27,代码来源:ulozto.py
示例4: resolve
def resolve(self, item, captcha_cb=None, select_cb=None):
result = []
item = item.copy()
url = item['url']
if url.endswith('live.html'):
for quality in ['360','540','720']:
item = self.video_item()
item['quality'] = quality + 'p'
item['url'] = self.rtmp_url(fix_path(re.search('http://(\w+).joj.sk', url).group(1)) + '-' + quality, url)
result.append(item)
else:
data = util.request(url)
playerdata = re.search(r'<div\ class=\"jn-player\"(.+?)>',data).group(1)
pageid = re.search(r'data-pageid=[\'\"]([^\'\"]+)',playerdata).group(1)
basepath = re.search(r'data-basepath=[\'\"]([^\'\"]+)',playerdata).group(1)
videoid = re.search(r'data-id=[\'\"]([^\'\"]+)',playerdata).group(1)
playlisturl = basepath + 'services/Video.php?clip=' + videoid + 'pageId=' + pageid
playlist = fromstring(util.request(playlisturl))
balanceurl = basepath + 'balance.xml?nc=%d' % random.randint(1000, 9999)
balance = fromstring(util.request(balanceurl))
for video in playlist.find('files').findall('file'):
item = self.video_item()
item['img'] = playlist.attrib.get('large_image')
item['length'] = playlist.attrib.get('duration')
item['quality'] = video.attrib.get('quality')
item['url'] = self.rtmp_url(video.attrib.get('path'), playlist.attrib.get('url'), video.attrib.get('type'), balance)
result.append(item)
result.reverse()
return select_cb(result)
开发者ID:izderadicka,项目名称:xbmc-doplnky,代码行数:29,代码来源:joj.py
示例5: list
def list(self, url):
if url.find('zebricky/') == 0:
return self.list_top10(util.request(self.base_url+url))
if url.find("#related#") == 0:
return self.list_related(util.request(url[9:]))
else:
return self.list_content(util.request(self._url(url)), self._url(url))
开发者ID:mx3L,项目名称:archivczsk-doplnky,代码行数:7,代码来源:videacesky.py
示例6: resolve
def resolve(url):
data = util.extract_jwplayer_setup(util.request(url))
if data and 'sources' in data:
result = []
for source in data['sources']:
items = []
if source['file'].endswith('.smil'):
tree = ElementTree.fromstring(util.request(source['file']))
base_path = tree.find('./head/meta').get('base')
for video in tree.findall('./body/switch/video'):
items.append({
'url': '%s playpath=%s pageUrl=%s swfUrl=%s swfVfy=true' %
(base_path, video.get('src'), url,
'http://static.flashx.tv/player6/jwplayer.flash.swf'),
'quality': video.get('height') + 'p'
})
else:
items.append({'url': source['file']})
if len(data['tracks']) > 0:
for item in items:
for track in data['tracks']:
new_item = deepcopy(item)
new_item['subs'] = track['file']
new_item['lang'] = ' %s subtitles' % track['label']
result.append(new_item)
else:
result += items
return result
return None
开发者ID:bbaronSVK,项目名称:script.module.stream.resolver,代码行数:29,代码来源:flashxresolver.py
示例7: resolve
def resolve(self,item,captcha_cb=None,select_cb=None):
item = item.copy()
url = self._url(item['url'])
data = util.request(self._url(item['url']))
data = util.substr(data,'<div class=\"video','</div')
sosac = re.search('\"(http\://[\w]+\.sosac\.ph[^\"]+)',data,re.DOTALL)
if sosac:
data = util.request(sosac.group(1))
resolved = resolver.findstreams(data,[
'<embed( )*flashvars=\"file=(?P<url>[^\"]+)',
'<embed( )src=\"(?P<url>[^\"]+)',
'<object(.+?)data=\"(?P<url>[^\"]+)',
'<iframe(.+?)src=[\"\' ](?P<url>.+?)[\'\" ]',
])
result = []
if not resolved:
self.error('Nothing resolved')
for i in resolved:
item = self.video_item()
item['title'] = i['name']
item['url'] = i['url']
item['quality'] = i['quality']
item['surl'] = i['surl']
item['subs'] = i['subs']
result.append(item)
if len(result)==1:
return result[0]
elif len(result) > 1 and select_cb:
return select_cb(result)
开发者ID:vrockai,项目名称:xbmc-doplnky,代码行数:29,代码来源:befun.py
示例8: resolve
def resolve(self, item, captcha_cb=None, select_cb=None):
item = item.copy()
url = self._url(item["url"])
data = util.request(self._url(item["url"]))
data = util.substr(data, '<div class="video', "</div")
sosac = re.search('"(http\://[\w]+\.sosac\.ph[^"]+)', data, re.DOTALL)
if sosac:
data = util.request(sosac.group(1))
resolved = resolver.findstreams(
data,
[
'<embed( )*flashvars="file=(?P<url>[^"]+)',
'<embed( )src="(?P<url>[^"]+)',
'<object(.+?)data="(?P<url>[^"]+)',
"<iframe(.+?)src=[\"' ](?P<url>.+?)['\" ]",
"<object.*?data=(?P<url>.+?)</object>",
],
)
result = []
if not resolved:
self.error("Nothing resolved")
for i in resolved:
item = self.video_item()
item["title"] = i["name"]
item["url"] = i["url"]
item["quality"] = i["quality"]
item["surl"] = i["surl"]
item["subs"] = i["subs"]
item["headers"] = i["headers"]
result.append(item)
if len(result) == 1:
return result[0]
elif len(result) > 1 and select_cb:
return select_cb(result)
开发者ID:skata890,项目名称:xbmc-doplnky,代码行数:34,代码来源:befun.py
示例9: list_episodes
def list_episodes(self, url, page=0):
result = []
if url.find('ajax.json') != -1:
headers = {'X-Requested-With':'XMLHttpRequest',
'Referer':util.substr(url, url, url.split('/')[-1])
}
httpdata = util.request(url, headers)
httpdata = util.json.loads(httpdata)['content']
else:
httpdata = util.request(url)
httpdata = util.substr(httpdata, EPISODE_START, EPISODE_END)
entries = 0
skip_entries = MAX_PAGE_ENTRIES * page
for m in re.finditer(EPISODE_ITER_RE, httpdata, re.DOTALL | re.IGNORECASE):
entries += 1
if entries < skip_entries:
continue
item = self.video_item()
item['title'] = "%s. %s (%s)" % (m.group('episode'), m.group('title'), m.group('date'))
item['url'] = m.group('url')
self._filter(result, item)
if entries >= (skip_entries + MAX_PAGE_ENTRIES):
page += 1
item = self.dir_item()
item['type'] = 'next'
item['url'] = "#episodes##%d#" % (page) + url
result.append(item)
break
return result
开发者ID:mx3L,项目名称:xbmc-doplnky,代码行数:31,代码来源:joj.py
示例10: resolve
def resolve(self, item, captcha_cb=None, select_cb=None):
item = item.copy()
url = self._url(item["url"])
data = util.request(url)
video_id = re.search(VIDEO_ID_RE, data, re.IGNORECASE | re.DOTALL).group(1)
headers = {"Referer": url}
keydata = util.request("http://embed.stv.livebox.sk/v1/tv-arch.js", headers)
rtmp_url_regex = "'(rtmp:\/\/[^']+)'\+videoID\+'([^']+)'"
m3u8_url_regex = "'(http:\/\/[^']+)'\+videoID\+'([^']+)'"
rtmp = re.search(rtmp_url_regex, keydata, re.DOTALL)
m3u8 = re.search(m3u8_url_regex, keydata, re.DOTALL)
m3u8_url = m3u8.group(1) + video_id + m3u8.group(2)
# rtmp[t][e|s]://hostname[:port][/app[/playpath]]
# tcUrl=url URL of the target stream. Defaults to rtmp[t][e|s]://host[:port]/app.
# rtmp url- fix podla mponline2 projektu
rtmp_url = rtmp.group(1) + video_id + rtmp.group(2)
stream_part = "mp4:" + video_id
playpath = rtmp_url[rtmp_url.find(stream_part) :]
tcUrl = rtmp_url[: rtmp_url.find(stream_part) - 1] + rtmp_url[rtmp_url.find(stream_part) + len(stream_part) :]
app = tcUrl[tcUrl.find("/", tcUrl.find("/") + 2) + 1 :]
# rtmp_url = rtmp_url+ ' playpath=' + playpath + ' tcUrl=' + tcUrl + ' app=' + app
rtmp_url = rtmp_url + " tcUrl=" + tcUrl + " app=" + app
item["url"] = rtmp_url
return item
开发者ID:lzoubek,项目名称:xbmc-doplnky-old,代码行数:27,代码来源:rtvs.py
示例11: resolve
def resolve(self, item, captcha_cb=None, select_cb=None):
result = []
item = item.copy()
url = item['url']
if url.endswith('live.html'):
channel = re.search(r'http://(\w+)\.joj\.sk', url).group(1)
for original, replacement in {'www': 'joj', 'plus': 'jojplus'}.items():
if channel == original:
channel = replacement
break
for quality, resolution in {'lq': '180p', 'mq': '360p', 'hq': '540p'}.items():
item = self.video_item()
item['quality'] = resolution
item['url'] = 'http://http-stream.joj.sk/joj/' + channel + '/index-' + quality + '.m3u8'
result.append(item)
else:
data = util.request(url)
playerdata = re.search(r'<div\ class=\"jn-player\"(.+?)>', data).group(1)
pageid = re.search(r'data-pageid=[\'\"]([^\'\"]+)', playerdata).group(1)
basepath = re.search(r'data-basepath=[\'\"]([^\'\"]+)', playerdata).group(1)
videoid = re.search(r'data-id=[\'\"]([^\'\"]+)', playerdata).group(1)
playlisturl = basepath + 'services/Video.php?clip=' + videoid + 'pageId=' + pageid
playlist = fromstring(util.request(playlisturl))
balanceurl = basepath + 'balance.xml?nc=%d' % random.randint(1000, 9999)
balance = fromstring(util.request(balanceurl))
for video in playlist.find('files').findall('file'):
item = self.video_item()
item['img'] = playlist.attrib.get('large_image')
item['length'] = playlist.attrib.get('duration')
item['quality'] = video.attrib.get('quality')
item['url'] = self.rtmp_url(video.attrib.get('path'), playlist.attrib.get('url'),
video.attrib.get('type'), balance)
result.append(item)
result.reverse()
return select_cb(result)
开发者ID:Jakub2013,项目名称:plugin.video.joj.sk,代码行数:35,代码来源:joj.py
示例12: __init__
def __init__(self, username=None, password=None, filter=None, reverse_eps=False):
ContentProvider.__init__(self, name='sosac.ph', base_url=MOVIES_BASE_URL, username=username,
password=password, filter=filter)
util.init_urllib(self.cache)
cookies = self.cache.get(util.CACHE_COOKIES)
if not cookies or len(cookies) == 0:
util.request(self.base_url)
self.reverse_eps = reverse_eps
开发者ID:bbaronSVK,项目名称:plugin.video.sosac.ph,代码行数:8,代码来源:sosac.py
示例13: list
def list(self, url):
if url.find('subcat') == 0:
category_id = url.split("#")[1]
return self.list_subcategories(util.request(self.base_url), category_id)
elif url.find('calendar') == 0:
year, month = url.split("#")[1].split("|")
return self.calendar(int(year), int(month))
return self.list_content(util.request(self._url(url)))
开发者ID:slavkodemeter,项目名称:archivczsk-doplnky,代码行数:8,代码来源:markiza.py
示例14: resolve
def resolve(url):
refererurl = re.search(r'<iframe src="([^"]+)".*', util.request(url), re.I | re.S).group(1)
try:
data=[x for x in util.request(refererurl).splitlines() if 'file:' in x and '.mp4' in x][0]
except:
return None
streamurl = re.search(r'.*file:"([^"]+?)".*', data).group(1)
headers={'Referer': refererurl}
return [{'url': streamurl, 'headers': headers}]
开发者ID:bbaronSVK,项目名称:script.module.stream.resolver,代码行数:9,代码来源:youwatch.py
示例15: list
def list(self,url):
if url.find('#film#') == 0:
return self.film(util.request(self._url(url[6:])))
if url.find('#rand#') == 0:
return self.film(util.request(self._url(url[6:])+'index.php?id=2236'))
if url.find('#last#') == 0:
return self.film(util.request(self._url(url[6:])))
else:
raise Expception("Invalid url, I do not know how to list it :"+url)
开发者ID:cplaiasu,项目名称:xbmc-doplnky,代码行数:9,代码来源:playmovie.py
示例16: list
def list(self, url):
if url.find('#subcat#') == 0:
url = url[8:]
return self.list_subcategories(util.request(self._url(url)), url)
elif url.find("#date#") == 0:
year = int(url.split("#")[2])
month = int(url.split("#")[3])
return self.date(year, month)
return self.list_content(util.request(self._url(url)))
开发者ID:Pepo48,项目名称:plugin.video.markiza.sk,代码行数:9,代码来源:markiza.py
示例17: __init__
def __init__(self, username=None, password=None, filter=None, quickparser=False):
ContentProvider.__init__(self, 'sledujufilmy.cz', self.urls['Filmy'],
username, password, filter)
# Work around April Fools' Day page
util.init_urllib(self.cache)
self.quickparser=quickparser
cookies = self.cache.get('cookies')
if not cookies or len(cookies) == 0:
util.request(self.base_url)
开发者ID:jose1711,项目名称:plugin.video.sledujufilmy.cz,代码行数:9,代码来源:sledujufilmy.py
示例18: resolve
def resolve(url):
if supports(url):
data = util.request(url)
m = re.search('flashvars.file=\"([^\"]+)',data,re.IGNORECASE | re.DOTALL)
n = re.search('flashvars.filekey=\"([^\"]+)',data,re.IGNORECASE | re.DOTALL)
if not m == None and not n == None:
data = util.request('http://www.novamov.com/api/player.api.php?key=%s&file=%s&user=undefined&pass=undefined&codes=1' % (n.group(1),m.group(1)))
stream = re.search('url=([^\&]+)',data).group(1)
return [{'url':stream}]
开发者ID:bbaronSVK,项目名称:script.module.stream.resolver,代码行数:9,代码来源:novamovresovler.py
示例19: list
def list(self,url):
if url.find('#film#') == 0:
return self.film(util.request(self._url(url[6:])))
if url.find('#cat#') == 0:
return self.cat(util.request(self._url(url[5:])))
if url.find('#last#') == 0:
return self.film(util.request(self._url(url[6:])))
else:
raise Expception("Invalid url, I do not know how to list it :"+url)
开发者ID:mx3L,项目名称:xbmc-doplnky,代码行数:9,代码来源:playmovie.py
示例20: resolve
def resolve(self,item,captcha_cb=None,select_cb=None):
item = item.copy()
url = self._url(item['url']).replace('×', '%c3%97')
data = util.substr(util.request(url), '<div id=\"content\"', '#content')
visionone_resolved, onevision_resolved, scz_resolved = [],[],[]
onevision = re.search('(?P<url>http://onevision\.ucoz\.ua/[^<]+)', data, re.IGNORECASE)
if onevision:
onevision_data = util.substr(util.request(onevision.group('url')),'<td class=\"eText\"','<td class=\"rightColumn\"')
onevision_resolved=resolver.findstreams(onevision_data, ['<embed( )src=\"(?P<url>[^\"]+)',
'<object(.+?)data=\"(?P<url>[^\"]+)',
'<iframe(.+?)src=[\"\'](?P<url>.+?)[\'\"]',
'<object.*?data=(?P<url>.+?)</object>'])
visionone = re.search('(?P<url>http://visionone\.ucoz\.ru/[^<]+)', data, re.IGNORECASE)
if visionone:
visionone_data = util.substr(util.request(visionone.group('url')),'<td class=\"eText\"','<td class=\"rightColumn\"')
visionone_resolved = resolver.findstreams(visionone_data, ['<embed( )src=\"(?P<url>[^\"]+)',
'<object(.+?)data=\"(?P<url>[^\"]+)',
'<iframe(.+?)src=[\"\'](?P<url>.+?)[\'\"]',
'<object.*?data=(?P<url>.+?)</object>'])
scz = re.search('(?P<url>http://scz\.uvadi\.cz/\?p=[\d]+)', data, re.IGNORECASE)
if scz:
scz_data = util.substr(util.request(scz.group('url')),'<div id=\"content\"', '#content')
scz_resolved = resolver.findstreams(scz_data, ['<embed( )src=\"(?P<url>[^\"]+)',
'<object(.+?)data=\"(?P<url>[^\"]+)',
'<iframe(.+?)src=[\"\'](?P<url>.+?)[\'\"]',
'<object.*?data=(?P<url>.+?)</object>'])
serialy_resolved = resolver.findstreams(data, ['<embed( )src=\"(?P<url>[^\"]+)',
'<object(.+?)data=\"(?P<url>[^\"]+)',
'<iframe(.+?)src=[\"\'](?P<url>.+?)[\'\"]',
'<object.*?data=(?P<url>.+?)</object>',
'<p><code><strong>(?P<url>http.+?)</strong></code></p>',
'<p><code><strong><big>(?P<url>.+?)</big></strong></code></p>'])
resolved = []
resolved+= serialy_resolved or []
resolved+= visionone_resolved or []
resolved+= onevision_resolved or []
resolved+= scz_resolved or []
resolved = len(resolved) > 0 and resolved or None
result = []
for i in resolved:
item = self.video_item()
item['title'] = i['name']
item['url'] = i['url']
item['quality'] = i['quality']
item['surl'] = i['surl']
item['headers'] = i['headers']
result.append(item)
if len(result) == 1:
return result[0]
elif len(result) > 1 and select_cb:
return select_cb(result)
开发者ID:skata890,项目名称:xbmc-doplnky,代码行数:56,代码来源:serialy.py
注:本文中的util.request函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论