文章分类

热门文章

iMyShare,公众号:神秘的热心网友 关注微信公众号

定期分享神兵利器,优质资源,精品学习资料,实用互联网小技巧!

Python利用youtube-dl库快速搭建视频解析下载网站,支持下载1000+网站的视频

MeetUp
2020-06-14
12305
2

youtube-dl简介

大名鼎鼎的开源视频下载工具——youtube-dl,想必大家应该早有耳闻了吧?网上的各种大佬几乎快已经将这个东西吹爆了,其实确实很腻害!虽然名字叫youtube,但实际上支持许多视频网站,比如:Vimeo、Tumblr、甚至国内的优酷、腾讯视频、哔哩哔哩等等(点击查看所有支持下载的视频网站)。并且提供了丰富的下载选项,比如选择下载的画质、格式、字幕,播放列表进行批量下载等等。重点是作为开源库,更新非常频繁,基本不用担心哪天不能用的问题!

youtube-dl的下载、安装和使用

因为本文主要是介绍如何利用youtube-dl库快速搭建视频解析下载网站,所以下载和安装部分就不是重点了,大家直接点击这里进行下载安装即可

下载完成后,我们只需要使用一条简单的命令即可下载YouTube视频,比如使用:youtube-dl -F [url]下载单条YouTube视频。

使用youtube-dl库下载YouTube视频,并支持选择格式使用youtube-dl下载YouTube视频

使用也是非常简单的,基本都是一条命令即可搞定视频下载。命令的基本规则是:

youtube-dl [OPTIONS] URL [URL...]

后面可以是单个URL,或者是多个URL的列表。然后OPTIONS就非常丰富了,具体可以参见这里:youtube-dl OPTIONS

youtube-dl视频下载原理简介

上面简单介绍了一下,基本一条命令即可下载YouTube视频,是不是感觉很强大?这么强大的库,咱必须扒一扒他的原理啊!经过一顿debug,看堆栈,单步走......此处省略无数字。最终get到此库的核心是使用了YoutubeDL这个类中的extract_info方法爬取了视频的下载地址,然后通过视频下载地址进行下载,最终通过ffmpeg进行视频合并,转格式等操作。

既然搞清楚了原理,咱就动手试试看看这个extract_info方法到底有多强?这里几行代码即可写个测试看看extract_info输出的是什么内容?

# coding="utf-8"
from youtube_dl import YoutubeDL

def youtubeDL(url):
	'''
	cachedir: 禁用缓存
	quiet: 不打印
	extract_flat: 如果是播放列表,仅返回视频列表,不解析每个视频的下载地址
	'''
	ydl = YoutubeDL({'cachedir': False, 'quiet': True, 'extract_flat': True,})
	result = ydl.extract_info(url, download=False,)
	return result

if __name__ == '__main__':
	print(youtubeDL('https://www.youtube.com/watch?v=-RkQDlUV4Fc'))

在终端运行后,最终看到如下输出

python使用youtube-dl进行视频下载

将输出结果格式化一下,大概就是这样一份标准的输出,里面包括视频的下载地址、封面、标题、时长、视频大小等等信息。

{
    'id': '-RkQDlUV4Fc',
    'uploader': 'Tropical House Radio',
    'uploader_id': 'UCwuMGwU6kX_lvkrYoVQWBGw',
    'uploader_url': 'http://www.youtube.com/channel/UCwuMGwU6kX_lvkrYoVQWBGw',
    'channel_id': 'UCwuMGwU6kX_lvkrYoVQWBGw',
    'channel_url': 'http://www.youtube.com/channel/UCwuMGwU6kX_lvkrYoVQWBGw',
    'upload_date': '20200612',
    'license': None,
    'creator': None,
    'title': 'Mega Hits 2020 🌱 The Best Of Vocal Deep House Music Mix 2020 🌱 Summer Music Mix 2020 #96',
    'alt_title': None,
    'thumbnail': 'https://i.ytimg.com/vi/-RkQDlUV4Fc/hqdefault.jpg',
    'description': "Mega Hits 2020 🌱 The Best Of Vocal Deep House Music Mix 2020 🌱 Summer Music Mix 2020 #96\n\n#SummerMusicMix #BestOfDeepHouse #HotSummer #SUMMERMIX2020 #SUMMERMUSIC2020\n\n✔ Leave a like on the video to show your support\n\n─────────── Support Tropical House ☼ ───────────\n🌿Follow THR\nhttp://bit.ly/SubscribeTropicalHouseRecords\nhttp://bit.ly/Spotify_THR\nhttp://bit.ly/Instagram_THR\nhttp://bit.ly/Facebook_THR\n\n★Follow us on spotify: https://spoti.fi/2TJ4Dyj\n★Submit music: https://bit.ly/2VcIDxx\n★YouTube: https://www.youtube.com/c/THRKygo\n★Facebook: https://www.facebook.com/ChillTownMusic/\n\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n★ Music By ★\n\n🌿 Follow Frequency :\nFollow us on\nInstagram → https://www.instagram.com/frequencymu...\nFacebook → https://www.facebook.com/frequencymus...\nSoundcloud → https://soundcloud.com/thisisfrequency\nTwitter → https://twitter.com/frequencymusico\n\n🌿 Follow ZilDeep\n» Spotify: https://spoti.fi/306DOIO\n» Soundcloud: https://soundcloud.com/zildeeprecords\n\n🌿 FOLLOW ZERO CLAIM RECORDS\n» http://facebook.com/zeroclaim\n» https://soundcloud.com/zeroclaim\n🌿 FOLLOW ARTIST\n» http://facebook.com/damauimusic\n» https://soundcloud.com/damaui\n\n🌿 Follow Magic Records\n» Stream/Download: https://fanlink.to/bJy2\n» Magic Spotify: https://lnk.to/magicmusic\n» Magic No Copyright Music: https://magicmusicllc.com/\n» Magic Instagram: http://bit.ly/2Iny5FN\n» Submit Your DEMO: https://bit.ly/2rrL9m0\n\n🌿 Follow Epic Tones Online:\n» Spotify: https://spoti.fi/2Lrvprh\n» Instagram: https://bit.ly/2sPVxnR\n» SoundCloud: https://bit.ly/1V3lGKg\n» Facebook: https://bit.ly/2sL0mzZ\n\nConnect with NCS\n• http://soundcloud.com/nocopyrightsounds\n• http://instagram.com/nocopyrightsounds_\n• http://facebook.com/NoCopyrightSounds\n• http://twitter.com/NCSounds\n• http://spoti.fi/NCS\n\n★ Credit Video ★\n\n🌿 Video By: Gavin Beals\n» Youtube: https://www.youtube.com/user/gbeals100\n» Instagram: https://www.instagram.com/th3venture/\n\n🌿 Video By: Gaëtan Piolot\n» Youtube: https://bit.ly/34EUPLa\n» Instagram: @gaetanpiolot\n\n🌿 Video by ThinLineMedia\n»Youtube: https://bit.ly/3bgId0I\n»Facebook: https://bit.ly/3c4ojWQ\n»Instagram: https://bit.ly/2VoEOX4\n»Website: thinlinemedia.com\n\n🌿 Video by Lilian Pang\n➤ Website: http://www.lilianpang.com\n➤ Youtube: https://www.youtube.com/c/LilianPang\n➤ Instagram: https://www.instagram.com/lilianxpang/\n➤ Facebook: https://m.facebook.com/lilianxpang/\n\n🌿 Video By Ben Mikha\n➤ https://bit.ly/2EDRPUj\n➤ https://instagram.com/benmikha\n➤ https://benmikha.com/\n\n🌿 Video by Lilian Pang\n➤ Website: http://www.lilianpang.com\n➤ Youtube: https://www.youtube.com/c/LilianPang\n➤ Instagram: https://www.instagram.com/lilianxpang/\n➤ Facebook: https://m.facebook.com/lilianxpang/\n\n🌿Videos by Juhani Sarglep:\nInstargram : https://bit.ly/2L6er3s\nInstargram : https://bit.ly/2W5Rh3y\nYouTube : https://bit.ly/3c9JFTk\nWebsite : https://www.foureyestwosouls.com\n\nTracklist:\nUpdating...\n\n🎬  If you’re a filmmaker interested in promoting your content, contact us at 💌 channel@hgmedia.vn 💌\n\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n🚫  The music and the background in the following video are not free to use, if you'd like to use the music/background in this video, please contact the artist.\n\n⚠️ These videos may cause people with photosensitive epilepsy to convulse in seizures. Viewer discretion is advised. ⚠️\n\n☢ If any producer or label has an issue with any of the uploads please get in contact with me and us will delete it immediately.",
    'categories': None,
    'tags': ['Popular', 'Songs', 'Mix', '2020', 'Camila Cabello',
        'Ed Sheeran', 'Justin Bieber', 'Kygo', 'Style', 'Chill',
        'Chill Out', 'spotify music', 'youtube music', 'hot mix',
        'girl', 'youtubers', 'logan paul', 'best music',
        'pop music', 'dance mix', 'disco polo', 'musicas',
        'electronicas', 'new year mix', 'new music',
        'tropical mix', 'deep house', 'summer mix', 'winter mix',
        'remixes', 'mashups', 'brazil mix', 'popular songs',
        'electro mix', 'car music', 'top USA', 'edm mix',
        'Coldplay', 'drake', 'summer music 2020', 'world hits',
        'charts', 'Tropical House Radio', '#96'
    ],
    'subtitles':{},
    'automatic_captions':{},
    'duration': 9942,
    'age_limit': 0,
    'annotations': None,
    'chapters': None,
    'webpage_url': 'https://www.youtube.com/watch?v=-RkQDlUV4Fc',
    'view_count': 86491,
    'like_count': 913,
    'dislike_count': 75,
    'average_rating': 4.6963563,
    'formats': [
    {
        'format_id': '251',
        'url': 'https://r4---sn-i3beln7s.googlevideo.com/videoplayback?expire=1592091798&ei=NRDlXvX1O92qlQS4poqIDw&ip=203.218.240.5&id=o-ALKzkrgh-2iKtd-JFkURDPhR6KNb-V0oTR5il0TI6aep&itag=251&source=youtube&requiressl=yes&mh=SG&mm=31%2C26&mn=sn-i3beln7s%2Csn-a5msen7s&ms=au%2Conr&mv=m&mvi=3&pl=20&initcwndbps=1103750&vprv=1&mime=audio%2Fwebm&gir=yes&clen=169852014&dur=9941.741&lmt=1592039334786923&mt=1592070099&fvip=4&keepalive=yes&c=WEB&txp=5511222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRAIge3sdei0rZvp04ja2REh3p3pKwPu0t0elmevmBvUOfbYCIGwGglE-0zanDtxCPkZpHSCpSppKQq6Wnf-1IlF2qeiD&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgRkZp81m-Zx7Wwso43wdGUsEWYStogQMoFMPl1jY5SssCIQDr1vG-uehmq-6769eHWkRdRD2V6l0F_RsGw5s3AybEFQ%3D%3D&ratebypass=yes',
        'player_url': None,
        'ext': 'webm',
        'format_note': 'tiny',
        'acodec': 'opus',
        'abr': 160,
        'asr': 48000,
        'filesize': 169852014,
        'fps': None,
        'height': None,
        'tbr': 164.211,
        'width': None,
        'vcodec': 'none',
        'downloader_options':
        {
            'http_chunk_size': 10485760
        },
        'format': '251 - audio only (tiny)',
        'protocol': 'https',
        'http_headers':
        {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3686.0 Safari/537.36',
            'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'en-us,en;q=0.5'
        }
    },
    {
        'format_id': '137',
        'url': 'https://r4---sn-i3beln7s.googlevideo.com/videoplayback?expire=1592091798&ei=NRDlXvX1O92qlQS4poqIDw&ip=203.218.240.5&id=o-ALKzkrgh-2iKtd-JFkURDPhR6KNb-V0oTR5il0TI6aep&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=SG&mm=31%2C26&mn=sn-i3beln7s%2Csn-a5msen7s&ms=au%2Conr&mv=m&mvi=3&pl=20&initcwndbps=1103750&vprv=1&mime=video%2Fmp4&gir=yes&clen=4858593415&dur=9941.697&lmt=1592041534441678&mt=1592070099&fvip=4&keepalive=yes&c=WEB&txp=5516222&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRAIgOhYOlMqA4RNf9JNvaw9QKrYpo5mDAsyv3RJSdg4BSYYCIGvtFITtILLTddZVng-jU24FX-l4sXVIMmuuQjbdZcEH&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgRkZp81m-Zx7Wwso43wdGUsEWYStogQMoFMPl1jY5SssCIQDr1vG-uehmq-6769eHWkRdRD2V6l0F_RsGw5s3AybEFQ%3D%3D&ratebypass=yes',
        'player_url': None,
        'ext': 'mp4',
        'height': 1080,
        'format_note': '1080p',
        'vcodec': 'avc1.640028',
        'asr': None,
        'filesize': 4858593415,
        'fps': 30,
        'tbr': 5813.874,
        'width': 1920,
        'acodec': 'none',
        'downloader_options':
        {
            'http_chunk_size': 10485760
        },
        'format': '137 - 1920x1080 (1080p)',
        'protocol': 'https',
        'http_headers':
        {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3686.0 Safari/537.36',
            'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'en-us,en;q=0.5'
        }
    },
    ],
    'is_live': None,
    'start_time': None,
    'end_time': None,
    'series': None,
    'season_number': None,
    'episode_number': None,
    'track': None,
    'artist': None,
    'album': None,
    'release_date': None,
    'release_year': None,
    'extractor': 'youtube',
    'webpage_url_basename': 'watch',
    'extractor_key': 'Youtube',
    'playlist': None,
    'playlist_index': None,
    'thumbnails': [
    {
        'url': 'https://i.ytimg.com/vi/-RkQDlUV4Fc/hqdefault.jpg',
        'id': '0'
    }],
    'display_id': '-RkQDlUV4Fc',
    'requested_subtitles': None,
    'requested_formats': (
    {
        'format_id': '137',
        'url': 'https://r4---sn-i3beln7s.googlevideo.com/videoplayback?expire=1592091798&ei=NRDlXvX1O92qlQS4poqIDw&ip=203.218.240.5&id=o-ALKzkrgh-2iKtd-JFkURDPhR6KNb-V0oTR5il0TI6aep&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=SG&mm=31%2C26&mn=sn-i3beln7s%2Csn-a5msen7s&ms=au%2Conr&mv=m&mvi=3&pl=20&initcwndbps=1103750&vprv=1&mime=video%2Fmp4&gir=yes&clen=4858593415&dur=9941.697&lmt=1592041534441678&mt=1592070099&fvip=4&keepalive=yes&c=WEB&txp=5516222&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRAIgOhYOlMqA4RNf9JNvaw9QKrYpo5mDAsyv3RJSdg4BSYYCIGvtFITtILLTddZVng-jU24FX-l4sXVIMmuuQjbdZcEH&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgRkZp81m-Zx7Wwso43wdGUsEWYStogQMoFMPl1jY5SssCIQDr1vG-uehmq-6769eHWkRdRD2V6l0F_RsGw5s3AybEFQ%3D%3D&ratebypass=yes',
        'player_url': None,
        'ext': 'mp4',
        'height': 1080,
        'format_note': '1080p',
        'vcodec': 'avc1.640028',
        'asr': None,
        'filesize': 4858593415,
        'fps': 30,
        'tbr': 5813.874,
        'width': 1920,
        'acodec': 'none',
        'downloader_options':
        {
            'http_chunk_size': 10485760
        },
        'format': '137 - 1920x1080 (1080p)',
        'protocol': 'https',
        'http_headers':
        {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3686.0 Safari/537.36',
            'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'en-us,en;q=0.5'
        }
    },
    {
        'format_id': '251',
        'url': 'https://r4---sn-i3beln7s.googlevideo.com/videoplayback?expire=1592091798&ei=NRDlXvX1O92qlQS4poqIDw&ip=203.218.240.5&id=o-ALKzkrgh-2iKtd-JFkURDPhR6KNb-V0oTR5il0TI6aep&itag=251&source=youtube&requiressl=yes&mh=SG&mm=31%2C26&mn=sn-i3beln7s%2Csn-a5msen7s&ms=au%2Conr&mv=m&mvi=3&pl=20&initcwndbps=1103750&vprv=1&mime=audio%2Fwebm&gir=yes&clen=169852014&dur=9941.741&lmt=1592039334786923&mt=1592070099&fvip=4&keepalive=yes&c=WEB&txp=5511222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRAIge3sdei0rZvp04ja2REh3p3pKwPu0t0elmevmBvUOfbYCIGwGglE-0zanDtxCPkZpHSCpSppKQq6Wnf-1IlF2qeiD&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgRkZp81m-Zx7Wwso43wdGUsEWYStogQMoFMPl1jY5SssCIQDr1vG-uehmq-6769eHWkRdRD2V6l0F_RsGw5s3AybEFQ%3D%3D&ratebypass=yes',
        'player_url': None,
        'ext': 'webm',
        'format_note': 'tiny',
        'acodec': 'opus',
        'abr': 160,
        'asr': 48000,
        'filesize': 169852014,
        'fps': None,
        'height': None,
        'tbr': 164.211,
        'width': None,
        'vcodec': 'none',
        'downloader_options':
        {
            'http_chunk_size': 10485760
        },
        'format': '251 - audio only (tiny)',
        'protocol': 'https',
        'http_headers':
        {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3686.0 Safari/537.36',
            'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'en-us,en;q=0.5'
        }
    }),
    'format': '137 - 1920x1080 (1080p)+251 - audio only (tiny)',
    'format_id': '137+251',
    'width': 1920,
    'height': 1080,
    'resolution': None,
    'fps': 30,
    'vcodec': 'avc1.640028',
    'vbr': None,
    'stretched_ratio': None,
    'acodec': 'opus',
    'abr': 160,
    'ext': 'mp4'
}

然后我们将输出中的视频链接粘贴到浏览器,发现是可以直接播放和下载的,简直简单完美啊!

播放下载youtube视频

在线视频解析下载网站搭建

知道原理之后,我们搭建一个视频解析下载网站就很简单了。我们只需要做一个简单的前端网页,让用户输入视频链接。然后前端调后端接口,将视频链接传给后端。后端使用youtube-dl中的extract_info方法得到视频的下载地址,然后将视频的下载地址传给前端。前端将视频的下载链接展示在网页上,用户就可以自由选择下载了。

使用youtube-dl搭建的视频下载网站

首先我们设置一个URL路由,将视频解析接口URL路由到我们的youtubeDL视频解析方法。

from .views import youtubeDL

urlpatterns = [
    path('api/', youtubeDL)
]

然后在youtubeDL方法中,对youtube-dl的extract_info解析出的视频下载数据进行重新封装。主要就是处理一些异常,将extract_info得到的字典进行重新封装,比如去掉异常数据,去掉不需要的数据等等。代码比较简单,就不贴详细代码了。

def youtubeDL(url):
	'''
	cachedir: 禁用缓存
	quiet: 不打印
	no_warnings:不要打印任何警告信息
	extract_flat: 如果是播放列表,仅返回视频列表,不解析每个视频的下载地址
	nocheckcertificate:不验证SSL证书
	'''
	ydl = YoutubeDL({'cachedir': False, 'quiet': True, 'no_warnings': True, 'extract_flat': True, 'nocheckcertificate': True,})
	try:
		result = ydl.extract_info(url, download=False,)
	except Exception as e:
		if('is not a valid URL' in str(e)):
			return {'code': -1, 'message': 'Invalid URL'}
		if('Unsupported URL' in str(e)):
			return {'code': -1, 'message': 'Unsupported URL'}
		if('This video is unavailable' in str(e)):
			return {'code': -1, 'message': 'This video is unavailable'}
		if('HTTP Error 404' in str(e)):
			return {'code': -1, 'message': 'This video is unavailable'}
		print(e)
		return {'code': -1, 'message': 'Analysis failed'}
		'''
		此处省略了一些代码,主要是数据重新封装
		'''
		return JsonResponse({'code': 0, 'message': 'Success', 'data': dic})

需要注意的是,YouTubeDL这个类在实例化的时候是有很多参数可配置的。这些参数在代码中都有详细说明,用的时候看一遍,基本就明白每个参数是什么意思了。

class YoutubeDL(object):
    """YoutubeDL class.

    YoutubeDL objects are the ones responsible of downloading the
    actual video file and writing it to disk if the user has requested
    it, among some other tasks. In most cases there should be one per
    program. As, given a video URL, the downloader doesn't know how to
    extract all the needed information, task that InfoExtractors do, it
    has to pass the URL to one of them.

    For this, YoutubeDL objects have a method that allows
    InfoExtractors to be registered in a given order. When it is passed
    a URL, the YoutubeDL object handles it to the first InfoExtractor it
    finds that reports being able to handle it. The InfoExtractor extracts
    all the information about the video or videos the URL refers to, and
    YoutubeDL process the extracted information, possibly using a File
    Downloader to download the video.

    YoutubeDL objects accept a lot of parameters. In order not to saturate
    the object constructor with arguments, it receives a dictionary of
    options instead. These options are available through the params
    attribute for the InfoExtractors to use. The YoutubeDL also
    registers itself as the downloader in charge for the InfoExtractors
    that are added to it, so this is a "mutual registration".

    Available options:

    username:          Username for authentication purposes.
    password:          Password for authentication purposes.
    videopassword:     Password for accessing a video.
    ap_mso:            Adobe Pass multiple-system operator identifier.
    ap_username:       Multiple-system operator account username.
    ap_password:       Multiple-system operator account password.
    usenetrc:          Use netrc for authentication instead.
    verbose:           Print additional info to stdout.
    quiet:             Do not print messages to stdout.
    no_warnings:       Do not print out anything for warnings.
    forceurl:          Force printing final URL.
    forcetitle:        Force printing title.
    forceid:           Force printing ID.
    forcethumbnail:    Force printing thumbnail URL.
    forcedescription:  Force printing description.
    forcefilename:     Force printing final filename.
    forceduration:     Force printing duration.
    forcejson:         Force printing info_dict as JSON.
    dump_single_json:  Force printing the info_dict of the whole playlist

前端拿到视频的下载链接后,按顺序遍历一下,将这些视频的真实下载链接展示在页面上即可。然后再将前端页面美化美化,基本就可以做成一个视频下载网站了,是不是很简单!比如下面这个网站就是用youtube-dl做的,据说这个站长每年广告收入有20W左右(别人咋就这么会恰烂钱,我就单纯的像一张纸🤦‍,我太难了)

使用youtube-dl搭建的视频解析下载网站


相关资源推荐:

									
交流评论
按Ctrl + D添加至书签,从此不迷路!
关注公众号
iMyShare,公众号:神秘的热心网友
有些东西我只想与你们聊聊,赶紧微信扫码上车!
个人微信:niceso-friend(有微信群)
合作邮箱:niceso@163.com