Mac+Python+youtube_dl下载国外网站视频遇到的坑以及解决方案(想要Python源码一次下载很多个视频的联系我)

一、问题描述

  想使用Python中的youtube_dl下载youtube的视频,源码如下:

import youtube_dl

link = ['https://www.youtube.com/shorts/xxx']
with youtube_dl.YoutubeDL() as ydl:
    ydl.download(link)

   但是下载的时候报错了,报错如下:

   youtube_dl.utils.DownloadError: ERROR: Unable to recognize tab page; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see    https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

二、问题分析

  报错原因是在Youtube在2023年2月15日左右进行了调整,使用youtube_dl都会出现这种错误。

三、解决方法

  使用yt-dlp代替youtube_dl;即首先安装yt-dlp,命令如下:

  pip3 install  yt-dlp

四、使用yt-dlp下载视频的方法

1、首先查看要下载视频可下载的格式,命令如下:

sudo yt-dlp https://www.youtube.com/shorts/xxx -F

结果展示如下:

 2、找到你要下载格式的ID,然后下载,比如我下载mp4,命令如下:

sudo yt-dlp https://www.youtube.com/shorts/xxx -f 137

3、在下载目录查看下载的内容

 

posted @ 2023-07-28 12:37  梅梅不想踩坑  阅读(523)  评论(0编辑  收藏  举报