本文整理汇总了Python中urlresolver.resolve函数的典型用法代码示例。如果您正苦于以下问题:Python resolve函数的具体用法?Python resolve怎么用?Python resolve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resolve函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: download
def download(self, siteResult = False):
#oGui = cGui()
oInputParameterHandler = cInputParameterHandler()
sMediaUrl = oInputParameterHandler.getValue('sMediaUrl')
sFileName = oInputParameterHandler.getValue('sFileName')
sFileName = oInputParameterHandler.getValue('sMovieTitle')
if siteResult:
sMediaUrl = siteResult['streamUrl']
if siteResult['resolved']:
sLink = sMediaUrl
else:
sLink = urlresolver.resolve(sMediaUrl)
else:
sLink = urlresolver.resolve(sMediaUrl)
logger.info('call download: ' + sMediaUrl)
logger.info('file link: ' + str(sLink))
if self.dialog:
self.dialog.close()
if (sLink != False):
oDownload = cDownload()
oDownload.download(sLink, 'Stream')
else:
cGui().showError('Download', 'File deleted or Link could not be resolved', 5);
return False
return True
示例2: sendToPyLoad
def sendToPyLoad(self, siteResult = False):
from resources.lib.handler.pyLoadHandler import cPyLoadHandler
import urlresolver
params = ParameterHandler()
sMediaUrl = params.getValue('sMediaUrl')
sFileName = params.getValue('MovieTitle')
if not sFileName:
sFileName = params.getValue('Title')
if not sFileName: #nur vorrübergehend
sFileName = params.getValue('sMovieTitle')
if not sFileName:
sFileName = params.getValue('title')
if siteResult:
sMediaUrl = siteResult['streamUrl']
if siteResult['resolved']:
sLink = sMediaUrl
else:
sLink = urlresolver.resolve(sMediaUrl)
else:
sLink = urlresolver.resolve(sMediaUrl)
try:
msg = sLink.msg
except:
msg = False
if sLink != False and not msg:
logger.info('download with pyLoad: ' + sMediaUrl)
cPyLoadHandler().sendToPyLoad(sFileName,sLink)
return True
else:
cGui().showError('xStream', str(msg), 5)
return False
示例3: download
def download(self, siteResult=False):
from resources.lib.download import cDownload
import urlresolver
# oGui = cGui()
params = ParameterHandler()
sMediaUrl = params.getValue("sMediaUrl")
sFileName = params.getValue("sFileName")
sFileName = params.getValue("sMovieTitle")
if siteResult:
sMediaUrl = siteResult["streamUrl"]
if siteResult["resolved"]:
sLink = sMediaUrl
else:
sLink = urlresolver.resolve(sMediaUrl)
else:
sLink = urlresolver.resolve(sMediaUrl)
logger.info("call download: " + sMediaUrl)
logger.info("file link: " + str(sLink))
if self.dialog:
self.dialog.close()
if sLink != False:
oDownload = cDownload()
oDownload.download(sLink, "Stream")
else:
# cGui().showError('Download', 'File deleted or Link could not be resolved', 5);
return False
return True
示例4: _getInfoAndResolve
def _getInfoAndResolve(self, siteResult):
import urlresolver
oGui = cGui()
params = ParameterHandler()
# get data
data = {}
mediaUrl = params.getValue('sMediaUrl')
fileName = params.getValue('MovieTitle')
if not fileName:
fileName = params.getValue('Title')
if not fileName: #only temporary
fileName = params.getValue('sMovieTitle')
if not fileName:
fileName = params.getValue('title')
data['title'] = fileName
data['season'] = params.getValue('season')
data['episode'] = params.getValue('episode')
data['showTitle'] = params.getValue('TVShowTitle')
data['thumb'] = params.getValue('thumb')
# resolve
if siteResult:
mediaUrl = siteResult['streamUrl']
logger.info('resolve: ' + mediaUrl)
if siteResult['resolved']:
link = mediaUrl
else:
link = urlresolver.resolve(mediaUrl)
elif mediaUrl:
logger.info('resolve: ' + mediaUrl)
link = urlresolver.resolve(mediaUrl)
else:
oGui.showError('xStream', 'kein Hosterlink übergeben', 5)
return False
#resolver response
if hasattr(link, 'msg'):
msg = link.msg
else: msg = False
if link != False and not msg:
data['link'] = link
return data
# error during resolving
if not msg:
msg = 'Stream nicht mehr verfügbar oder Link fehlerhaft'
oGui.showError('xStream',str(msg),7)
if hasattr(link, 'code'):
logger.info(str(msg) +' UnresolveableCode: '+ str(link.code))
else:
logger.info(str(msg) +' UnresolveableCode: - ')
'''
UnresolveableCode
0: Unknown Error
1: The url was resolved, but the file has been permanantly
removed
2: The file is temporarily unavailable for example due to
planned site maintenance
3. There was an error contacting the site for example a
connection attempt timed out
'''
return False
示例5: resolve
def resolve(url):
html = client.request(url)
links = re.findall('id=[\"\']([^\"\']+)[\"\']><a href=[\"\']#\d+[\"\']><div.+?>([^<]+)<',html)
if len(links)<2:
urls = re.findall('<iframe.+?src=[\'"](.+?)[\'"]',html)
import urlresolver
for url in urls:
resolved = urlresolver.resolve(url)
if resolved:
return resolved
break
else:
import requests
choices = [x[1] for x in links]
i = control.selectDialog(choices,heading='Choose a link:')
ref = url
headers = {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8','X-Requested-With':'XMLHttpRequest','Referer':ref, 'Origin':'http://fullmatchtv.com', 'Host':'fullmatchtv.com'}
s = requests.Session()
acp_pid = re.findall("id=[\"\']acp_post[\"\'].+?value=[\"\'](\d+)[\"\']",html)[0]
post_data = {'acp_currpage' : int(i)+1,
'acp_pid' : acp_pid,
'acp_shortcode' : 'acp_shortcode',
'action' : 'pp_with_ajax'
}
result = s.post('http://fullmatchtv.com/wp-admin/admin-ajax.php', data=post_data, headers=headers).content
url = re.findall('<iframe.+?src=[\'"](.+?)[\'"]',result)[0]
import urlresolver
return urlresolver.resolve(url)
示例6: play
def play(url):
if url.find('linkOut') != -1:
urlout = url.split('?id=')[-1]
url = base64.b64decode(urlout)
plugin.notify(msg=urlout, title=url)
resolved = ''
stream_url = ''
item = None
try:
import urlresolver
resolved = urlresolver.HostedMediaFile(url).resolve()
if not resolved or resolved == False or len(resolved) < 1:
resolved = urlresolver.resolve(url)
if resolved is None or len(resolved) < 1:
resolved = urlresolver.resolve(urllib.unquote(url))
if len(resolved) > 1:
plugin.notify(msg="PLAY {0}".format(resolved.partition('.')[-1]), title="URLRESOLVER", delay=1000)
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
item.add_stream_info('video', stream_values={})
item.set_is_playable(True)
plugin.play_video(item)
return None
except:
resolved = ''
plugin.notify(msg="FAILED {0}".format(url.partition('.')[-1]), title="URLRESOLVER", delay=1000)
try:
import YDStreamExtractor
info = YDStreamExtractor.getVideoInfo(url, resolve_redirects=True)
resolved = info.streamURL()
for s in info.streams():
try:
stream_url = s['xbmc_url'].encode('utf-8', 'ignore')
xbmc.log(msg="**YOUTUBE-DL Stream found: {0}".format(stream_url))
except:
pass
if len(stream_url) > 1:
resolved = stream_url
if len(resolved) > 1:
plugin.notify(msg="Playing: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
item.add_stream_info('video', stream_values={})
item.set_is_playable(True)
plugin.play_video(item)
return None
except:
plugin.notify(msg="Failed: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
if len(resolved) > 1:
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
plugin.play_video(item)
return None
else:
plugin.set_resolved_url(url)
plugin.play_video(url)
return None
示例7: VIDEOLINKS
def VIDEOLINKS(url,name):
name = name.replace('[COLOR green]Lektor','')
name = name.replace('[COLOR orange]Napisy','')
name = name.replace('[/COLOR]','')
link = getHtml (url)
soup = BeautifulSoup(link, 'html.parser')
divTag = soup.find_all("a" ,{"class":"watch"})
print divTag
for tag in divTag:
#match=re.compile('<a class="watch" data-iframe="(.+?)" data-short="(.+?)" data-size="width: (.+?)px; height: (.+?)px;" data-urlhost="(.+?)" data-version="(.+?)" href="#!">Og').findall(str(tag))
match=re.compile('<a class="watch" data-iframe="(.+?)" data-short="(.+?)" data-size="width: (.+?)px; height: (.+?)px;" data-urlhost="(.+?)" data-version="(.+?)"').findall(str(tag))
for cos,lang_short,x,y,url,lang in match:
print url + " linki"
match= re.compile('(http|https):\/\/(.+?)\/').findall(url)
for cos ,host in match:
host = host.replace('embed.','')
host = host.replace('www.','')
if "openload" in host:
#print "cosco " + host
ref = url.replace('video/','f/')
ref = ref.replace('http://','https://')
media_url = url.replace("http://openload.co/video/","https://openload.co/f/")
img_source = utils.getHtml(media_url, '', utils.openloadhdr)
match = re.compile('<meta name="og:image" content="(.+?)">').findall(img_source)
try:
poster_url = match[0]
except Exception:
pass
media_url = utils.playvideo(media_url, 'name', '', '')
media_url = media_url+'|User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0&Referer='+ref
print media_url + ' referer'
#media_url = urlresolver.resolve(media_url)
#poster_url = 'http://alltube.tv/static/host/play.png'
print media_url
elif "cda" in host:
media_url, poster_url = CDA(url)
if media_url:
#media_url = media_url+'|referer=http://static.cda.pl/flowplayer/flash/flowplayer.commercial-3.2.18.swf'
media_url = media_url+'|Cookie=PHPSESSID=1&Referer=http://static.cda.pl/flowplayer/flash/flowplayer.commercial-3.2.18.swf'
print media_url
elif "streamin" in host:
media_url = url.replace("video/","")
media_url = urlresolver.resolve(media_url)
poster_url = 'http://alltube.tv/static/host/play.png'
elif "vidto" in host:
media_url = url.replace("/v/","/")
media_url = urlresolver.resolve(media_url)
poster_url = 'http://alltube.tv/static/host/play.png'
else:
media_url = urlresolver.resolve(url)
poster_url = 'http://alltube.tv/static/host/play.png'
if media_url:
print media_url + " xxx"
#print lang
if media_url:
addLink(name+'[COLOR blue] '+lang+'[/COLOR]( '+host+' )',media_url,poster_url)
示例8: PLAYEP
def PLAYEP(name,url,iconimage):
if urlresolver.HostedMediaFile(url).valid_url():
stream_url = urlresolver.resolve(url)
else:
link = open_url(url)
match=re.compile('src="(.+?)"></iframe>').findall(link)[0]
stream_url = urlresolver.resolve(match)
liz = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=iconimage)
liz.setPath(stream_url)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
示例9: play
def play(url):
resolved = ''
stream_url = ''
item = None
try:
import urlresolver
resolved = urlresolver.HostedMediaFile(url).resolve()
if not resolved or resolved == False or len(resolved) < 1:
resolved = urlresolver.resolve(url)
if resolved is None or len(resolved) < 1:
resolved = urlresolver.resolve(urllib.unquote(url))
if len(resolved) > 1:
plugin.notify(msg="PLAY {0}".format(resolved.partition('.')[-1]), title="URLRESOLVER", delay=1000)
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
item.add_stream_info('video', stream_values={})
item.set_is_playable(True)
return item
except:
resolved = ''
plugin.notify(msg="FAILED {0}".format(url.partition('.')[-1]), title="URLRESOLVER", delay=1000)
try:
import YDStreamExtractor
info = YDStreamExtractor.getVideoInfo(url, resolve_redirects=True)
resolved = info.streamURL()
for s in info.streams():
try:
stream_url = s['xbmc_url'].encode('utf-8', 'ignore')
xbmc.log(msg="**YOUTUBE-DL Stream found: {0}".format(stream_url))
except:
pass
if len(stream_url) > 1:
resolved = stream_url
if len(resolved) > 1:
plugin.notify(msg="Playing: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
item.add_stream_info('video', stream_values={})
item.set_is_playable(True)
return item
except:
plugin.notify(msg="Failed: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
if len(resolved) > 1:
plugin.set_resolved_url(resolved)
item = ListItem.from_dict(path=resolved)
return item
else:
plugin.set_resolved_url(url) #url)
#plugurl = 'plugin://plugin.video.live.streamspro/?url={0}'.format(urllib.quote_plus(url))
#item = ListItem.from_dict(path=plugurl)
#item.add_stream_info('video', stream_values={})
#item.set_is_playable(True)
#plugin.notify(msg="RESOLVE FAIL: {0}".format(url.split('.', 1)[-1]),title="Trying {0}".format(item.path.split('.', 1)[-1]), delay=2000)
return None
示例10: addToPlaylist
def addToPlaylist(self, siteResult=False):
import urlresolver
oGui = cGui()
params = ParameterHandler()
sMediaUrl = params.getValue("sMediaUrl")
sFileName = params.getValue("MovieTitle")
if not sFileName:
sFileName = params.getValue("title")
if not sFileName:
sFileName = params.getValue("Title")
if not sFileName: # nur vorrübergehend
sFileName = params.getValue("sMovieTitle")
if not sFileName:
sFileName = params.getValue("title")
sSeason = params.getValue("season")
sEpisode = params.getValue("episode")
sShowTitle = params.getValue("TvShowTitle")
sThumbnail = params.getValue("thumb")
if siteResult:
sMediaUrl = siteResult["streamUrl"]
if siteResult["resolved"]:
sLink = sMediaUrl
else:
sLink = urlresolver.resolve(sMediaUrl)
else:
sLink = urlresolver.resolve(sMediaUrl)
logger.info("call addToPlaylist: " + sMediaUrl)
logger.info("file link: " + str(sLink))
if sLink != False:
oGuiElement = cGuiElement()
oGuiElement.setSiteName(self.SITE_NAME)
oGuiElement.setMediaUrl(sLink)
oGuiElement.setTitle(sFileName)
if sThumbnail:
oGuiElement.setThumbnail(sThumbnail)
if sShowTitle:
oGuiElement.addItemProperties("Episode", sEpisode)
oGuiElement.addItemProperties("Season", sSeason)
oGuiElement.addItemProperties("TvShowTitle", sShowTitle)
if self.dialog:
self.dialog.close()
oPlayer = cPlayer()
oPlayer.addItemToPlaylist(oGuiElement)
oGui.showInfo("Playlist", "Stream wurde hinzugefügt", 5)
else:
# oGui.showError('Playlist', 'File deleted or Link could not be resolved', 5);
return False
return True
示例11: PLAY
def PLAY(url,name):
html = net().http_GET(url).content
link=re.compile('<iframe width=.+?src="(.+?)".+?<',re.DOTALL).findall(html)
if not link: link = re.compile('<a target="_blank" href="(.+?)"><img border=0').findall(html)
if not link: link = re.compile("src='(.+?)'").findall(html)
if not link: link = re.compile('<div id="emptydiv"><iframe src="(.+?)"',re.DOTALL).findall(html)
if not link: link = re.compile('scrolling="no" src="(.+?)">').findall(html)
print link[0]
if name.strip() == 'VIDEOWEED': stream=urlresolver.resolve(link[0].replace('file','video'))
else: stream=urlresolver.resolve(link[0])
liz=xbmcgui.ListItem(label = name,label2 = name, iconImage="%s/art/video.png"%local.getAddonInfo("path"), thumbnailImage = "%s/art/video.png"%local.getAddonInfo("path") )
liz.setInfo( type="Video", infoLabels = {'title' : name}); liz.setProperty('fanart_image', fanart)
liz.setProperty('IsPlayable', 'true'); addon.resolve_url(stream)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=stream,listitem=liz)
示例12: addToPlaylist
def addToPlaylist(self, siteResult = False):
import urlresolver
oGui = cGui()
params = ParameterHandler()
sMediaUrl = params.getValue('sMediaUrl')
sFileName = params.getValue('MovieTitle')
if not sFileName:
sFileName = params.getValue('title')
if not sFileName:
sFileName = params.getValue('Title')
if not sFileName: #nur vorrübergehend
sFileName = params.getValue('sMovieTitle')
if not sFileName:
sFileName = params.getValue('title')
sSeason = params.getValue('season')
sEpisode = params.getValue('episode')
sShowTitle = params.getValue('TvShowTitle')
sThumbnail = params.getValue('thumb')
if siteResult:
sMediaUrl = siteResult['streamUrl']
if siteResult['resolved']:
sLink = sMediaUrl
else:
sLink = urlresolver.resolve(sMediaUrl)
else:
sLink = urlresolver.resolve(sMediaUrl)
logger.info('call addToPlaylist: ' + sMediaUrl)
logger.info('file link: ' + str(sLink))
if (sLink != False):
oGuiElement = cGuiElement()
oGuiElement.setSiteName(self.SITE_NAME)
oGuiElement.setMediaUrl(sLink)
oGuiElement.setTitle(sFileName)
if sThumbnail:
oGuiElement.setThumbnail(sThumbnail)
if sShowTitle:
oGuiElement.addItemProperties('Episode',sEpisode)
oGuiElement.addItemProperties('Season',sSeason)
oGuiElement.addItemProperties('TvShowTitle',sShowTitle)
if self.dialog:
self.dialog.close()
oPlayer = cPlayer()
oPlayer.addItemToPlaylist(oGuiElement)
oGui.showInfo('Playlist', 'Stream wurde hinzugefügt', 5);
else:
#oGui.showError('Playlist', 'File deleted or Link could not be resolved', 5);
return False
return True
示例13: request
def request(url):
try:
if '</regex>' in url:
import regex ; url = regex.resolve(url)
rd = realdebrid.resolve(url)
if not rd == None: return rd
pz = premiumize.resolve(url)
if not pz == None: return pz
if url.startswith('rtmp'):
if len(re.compile('\s*timeout=(\d*)').findall(url)) == 0: url += ' timeout=10'
return url
u = urlparse.urlparse(url).netloc
u = u.replace('www.', '').replace('embed.', '').replace('config.','')
u = u.lower()
r = [i['class'] for i in info() if u in i['netloc']][0]
r = __import__(r, globals(), locals(), [], -1)
r = r.resolve(url)
if r == None:
import urlresolver
r = urlresolver.resolve(url)
if not r:
r = None
if r == None: return r
elif type(r) == list: return r
elif not r.startswith('http'): return r
try: h = dict(urlparse.parse_qsl(r.rsplit('|', 1)[1]))
except: h = dict('')
if not 'User-Agent' in h: h['User-Agent'] = client.agent()
if not 'Referer' in h: h['Referer'] = url
r = '%s|%s' % (r.split('|')[0], urllib.urlencode(h))
return r
except:
try :
import urlresolver
r = urlresolver.resolve(url)
if not r :
url = r
except:
pass
return url
示例14: playURLRVideo
def playURLRVideo(url, name, type_):
dialog_progress_title='URL Resolver'
dialog_progress_YTDL = xbmcgui.DialogProgressBG()
dialog_progress_YTDL.create(dialog_progress_title )
dialog_progress_YTDL.update(10,dialog_progress_title,translation(32014) )
from urlparse import urlparse
parsed_uri = urlparse( url )
domain = '{uri.netloc}'.format(uri=parsed_uri)
try:
import urlresolver
#hmf = urlresolver.HostedMediaFile(url)
dialog_progress_YTDL.update(20,dialog_progress_title,translation(32012) )
media_url = urlresolver.resolve(url)
dialog_progress_YTDL.update(80,dialog_progress_title,translation(32013) )
if media_url:
log( ' URLResolver stream url=' + repr(media_url ))
pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
pl.clear()
pl.add(media_url, xbmcgui.ListItem(name))
xbmc.Player().play(pl, windowed=False) #scripts play video like this.
else:
log( " Can't URL Resolve:" + repr(url))
xbmc_notify('URLresolver', translation(32192),icon="type_urlr.png" ) #Failed to get playable url
except Exception as e:
xbmc_notify('URLresolver:'+domain, str(e),icon="type_urlr.png" )
dialog_progress_YTDL.close()
示例15: RESOLVETVDL
def RESOLVETVDL(name, url, thumb):
data = 0
try:
data = GRABMETA(movie_name, year)
except:
data = 0
hmf = urlresolver.HostedMediaFile(url)
host = ""
if hmf:
url = urlresolver.resolve(url)
host = hmf.get_host()
if ".mp4" in url:
ext = ".mp4"
elif ".flv" in url:
ext = ".flv"
elif ".avi" in url:
ext = ".avi"
if not ext == "":
console = "Downloads/TV Shows/" + dlfoldername
params = {"url": url, "name": name, "thumb": thumb, "dlfoldername": dlfoldername}
xbmc.sleep(1000)
addToQueue(name, url, thumb, ext, console)