本文整理汇总了Python中core.decoder.Decoder.downloadY方法的典型用法代码示例。如果您正苦于以下问题:Python Decoder.downloadY方法的具体用法?Python Decoder.downloadY怎么用?Python Decoder.downloadY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.decoder.Decoder
的用法示例。
在下文中一共展示了Decoder.downloadY方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extractTargetVideo
# 需要导入模块: from core.decoder import Decoder [as 别名]
# 或者: from core.decoder.Decoder import downloadY [as 别名]
def extractTargetVideo(link):
logger.debug("trying to decode with youtube link decrypter: " + link)
code = link[link.find("v=") + 2:]
logger.debug("trying with code: " + code)
try:
link = Decoder.downloadY(code)
except:
# trying second way, external page
html = Downloader.getContentFromUrl(link, referer=Youtube.MAIN_URL)
oldLink = link
if 'ytplayer.config = {' in html:
logger.debug("trying new way for .m3u8 links...")
link = Decoder.extract(',"hlsvp":"', '"', html).replace('\\', '')
link = urllib.unquote(link)
logger.debug("new youtube extracted link from json is: " + link)
# link += "|" + Downloader.getHeaders(oldLink)
if "http" not in link:
logger.debug("trying old second way: external resource...")
link = Youtube.decodeKeepVid(oldLink)
pass
if ".m3u8" in link:
bruteM3u8 = Youtube.getContentFromUrl(link);
if 'https://' in bruteM3u8:
m3u8 = bruteM3u8[bruteM3u8.rfind('https://'):]
link = urllib.unquote_plus(m3u8).strip()
logger.debug("using the last one inside: "+m3u8)
else:
logger.debug("no last one link selected :'(")
else:
logger.debug("nothing is transformed for youtube links.")
logger.debug("final youtube decoded url is: " + link)
if ";" in link:
link = link.replace("=", "%3D").replace(";", "%3B")
else:
link = link.replace("%3D","=")
return link