參照網路上的教學試試用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看到幾個人有類似問題
不過都沒有解答
所以來這邊求助熱心的高手!