como posso baixar vídeos do youtube usando python
Nov 02 2020
eu escrevo um programa simples de download do youtube
este é o código:
YouTube("https://youtu.be/7nXt6oggOlE").streams.first().download()
quando executo este código, recebo este erro:
File "<stdin>", line 1, in <module>
File "C:\Users\ajaym\AppData\Local\Programs\Python\Python37\lib\site-packages\pytube\__main__.py", line 91, in __init__
self.prefetch()
File "C:\Users\ajaym\AppData\Local\Programs\Python\Python37\lib\site-packages\pytube\__main__.py", line 183, in prefetch
self.js_url = extract.js_url(self.watch_html)
File "C:\Users\ajaym\AppData\Local\Programs\Python\Python37\lib\site-packages\pytube\extract.py", line 143, in js_url
base_js = get_ytplayer_config(html)["assets"]["js"]
KeyError: 'assets'
Respostas
2 SachinRajput Nov 02 2020 at 11:12
Tente fazer isso funcionou para mim. Também pode resolver o seu problema.
pip uninstall pytube
pip uninstall pytube3
python -m pip install git+https://github.com/nficano/pytube
2 Ragnar Nov 02 2020 at 13:01
Isso é o que eu usei recentemente
from pytube import YouTube
import os
link = "https://www.youtube.com/watch?v=wl8X-kV-gmU&ab_channel=MixHound"
path = 'C:\\YouTube_download_path'
def downloadYouTube(videourl, path):
yt = YouTube(videourl)
yt = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
if not os.path.exists(path):
os.makedirs(path)
yt.download(path)
downloadYouTube(link, path)
O que significa um erro “Não é possível encontrar o símbolo” ou “Não é possível resolver o símbolo”?