Solía descargar canciones de la siguiente manera:
from pytube import YouTube video = YouTube('https://www.youtube.com/watch?v=AWXvSBHB210') video.streams.get_by_itag(251).download()Desde hoy hay este error:
Rastreo (última llamada más reciente): Archivo "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube_ main _.py", línea 170, en fmt_streams extract.apply_signature(stream_manifest , self.vid_info, self.js) Archivo "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\extract.py", línea 409, en apply_signature cipher = Cipher( js=js) Archivo "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", línea 43, en init self.throttling_plan = get_throttling_plan(js) Archivo "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", línea 387, en get_throttling_plan raw_code = get_throttling_function_code(js) Archivo "C:\Users\Me \AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", línea 293, en get_throttling_function_code name = re.escape(get_throttling_function_name(js)) File "C:\Users\Me\AppData \Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", línea 278, en get_thrott ling_function_name aumentar RegexMatchError( pytube.exceptions.RegexMatchError: get_throttling_function_name: no se pudo encontrar una coincidencia para múltiples
Durante el manejo de la excepción anterior, ocurrió otra excepción:
Rastreo (última llamada más reciente): Archivo "C:\Users\Me\Documents\YouTubeDownloader.py", línea 3, en video.streams.get_by_itag(251).download() Archivo "C:\Users\Me\AppData \Local\Programs\Python\Python39\lib\site-packages\pytube_ main _.py", línea 285, en streams devuelve StreamQuery(self.fmt_streams) File "C:\Users\Me\AppData\Local\Programs\Python \Python39\lib\site-packages\pytube_ main _.py", línea 177, en fmt_streams extract.apply_signature(stream_manifest, self.vid_info, self.js) Archivo "C:\Users\Me\AppData\Local\Programs\ Python\Python39\lib\site-packages\pytube\extract.py", línea 409, en apply_signature cipher = Cipher(js=js) File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib \site-packages\pytube\cipher.py", línea 43, en init self.throttling_plan = get_throttling_plan(js) Archivo "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\ pytube\cipher.py", línea 387, en get_throttling_plan raw_code = get_throttling_function_code(js) File "C:\Users\Me\AppData\Local\Programs\Python \Python39\lib\site-packages\pytube\cipher.py", línea 293, en get_throttling_function_code name = re.escape(get_throttling_function_name(js)) File "C:\Users\Me\AppData\Local\Programs\Python\Python39 \lib\site-packages\pytube\cipher.py", línea 278, en get_throttling_function_name aumentar RegexMatchError( pytube.exceptions.RegexMatchError: get_throttling_function_name: no se pudo encontrar una coincidencia para varios
Tuve el mismo problema cuando estaba usando pytube 11.0.0
así que descubrí que hay una falta de coincidencia en el filtro de expresión regular en la biblioteca pytube en la clase cipher.py
patrones_función = [
r'a\.C&&\(b=a\.get\("n"\)\)&&\(b=([^(]+)\(b\),a\.set\("n",b\)\)}};', ]Ahora hay una actualización del código pytube ayer a 11.0.1
patrones_función = [
r'a\.[AZ]&&\(b=a\.get\("n"\)\)&&\(b=([^(]+)\(b\)', ]¡Con esta actualización de código ahora funciona la descarga de videos de YouTube con pytube!
actualiza tu biblioteca de pytube con este comando
python3 -m pip instalar --actualizar pytube
Actualizar pytube
python3 -m pip instalar --actualizar pytube