[問題] pytube RegexMatchError

作者: wavek (狗貓貓 m(OvO)m)   2018-11-12 20:33:10
參照網路上的教學試試用pytube庫下載影片
不過開頭就出問題惹QQ
使用的系統為win7 64位元
IDE為PyCharm 並且連接到Anaconda 3 (python 3.7)
Pytube為9.3.51版本
我的Code如下
===
from pytube import YouTube
link = "https://www.youtube.com/watch?v=Ik-RsDGPI5Y"
yt = YouTube(link)
print(yt.get_videos())
print(yt.filename)
yt.set_filename('Dancing')
print(yt.filter('flv'))
print(yt.filter('mp4')[-1])
print(yt.filter(resolution='480p'))
video = yt.get('mp4','720p')
video.download('E:\\_sublime\\scrapy\\hey\\')
===
https://imgur.com/g6E1LwR
錯誤如下
===
Traceback (most recent call last):
File "E:/_sublime/scrapy/hey/venv/ytvideo.py", line 5, in <module>
yt = YouTube(link)
File
"C:\Users\Administrator\Anaconda3\lib\site-packages\pytube\__main__.py", line
88, in __init__
self.prefetch_init()
File
"C:\Users\Administrator\Anaconda3\lib\site-packages\pytube\__main__.py", line
97, in prefetch_init
self.init()
File
"C:\Users\Administrator\Anaconda3\lib\site-packages\pytube\__main__.py", line
133, in init
mixins.apply_signature(self.player_config_args, fmt, self.js)
File "C:\Users\Administrator\Anaconda3\lib\site-packages\pytube\mixins.py",
line 49, in apply_signature
signature = cipher.get_signature(js, stream['s'])
File "C:\Users\Administrator\Anaconda3\lib\site-packages\pytube\cipher.py",
line 250, in get_signature
tplan = get_transform_plan(js)
File "C:\Users\Administrator\Anaconda3\lib\site-packages\pytube\cipher.py",
line 69, in get_transform_plan
name = re.escape(get_initial_function_name(js))
File "C:\Users\Administrator\Anaconda3\lib\site-packages\pytube\cipher.py",
line 45, in get_initial_function_name
return regex_search(pattern, js, group=1)
File
"C:\Users\Administrator\Anaconda3\lib\site-packages\pytube\helpers.py", line
41, in regex_search
.format(pattern=p),
pytube.exceptions.RegexMatchError: regex pattern
(yt\.akamaized\.net/\)\s*\|\|\s*.*?\s*c\s*&&\s*d\.set\([^,]+\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\()
had zero matches
===
https://imgur.com/HcRIpye
有在GitHub跟STACK OVERFLOW看到幾個人有類似問題
不過都沒有解答
所以來這邊求助熱心的高手!
作者: s860134 (s860134)   2018-11-13 00:32:00
把你的 pattern 貼101檢查吧 https://regex101.com/看了一下那是他寫的 pattern
作者: dpes10087 (悠哉度日)   2018-11-14 10:53:00
pytube ->cipher.py ->get_initial_function_name(js)pattern= r'\bc\s*&&\s*d\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\('再對cipher.py重新編譯一次你的Code範例是舊的,很多function都改掉了。

Links booklink

Contact Us: admin [ a t ] ucptt.com