环境
演示环境:linux
要求
linux 环境能够科研上网(透明模式)
安装 ffmpeg
1 |
|
2023.09.01 更新
youtube-dl 已失效
使用yt-dlp 替代
1 |
|
youtube-dl常用参数:
查看 视频资源 高清类型1
2
3
4
5
6
7
8
9
10
11
12
13
14
15-F url 查看视频资源的所有质量类型
-R 3 失败重试3次
--sleep-interval 3 每次下载间隔3秒(防止太频繁被youtube限流)
-i 忽略下载错误的,若无该参数,一个视频下载失败,就不再下载了
-f bestvideo+bestaudio 选择最佳视频,最佳音频
--merge-output-format mkv 输出封装格式
-o '%(title)s.%(ext)s' 输出文件名格式(参考:https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template)
字幕选项:(比如有些英文课程,带上字幕方便理解)
默认的字幕在 potplayer 播放器可以显示, 但是 IOS的 nPlayer 播放器 不支持显示
--write-sub 下载字幕
--all-subs 下载字幕语言所有种类
--sub-lang zh-TW,ja 下载字幕语言种类
--embed-subs 合成字幕轨到封装
--convert-subs=srt 字幕转换,youtobe专用字幕格式转换为通用字幕格式(转换之后 IOS的 nPlayer 才可以显示字幕)
视频资源质量查看
示例: 1080P, 没有4K
1 |
|
示例:有1080P, 也有4K
1 |
|
视频下载
最佳视频+最佳音频
1 |
|
效果图1:
视频下载带字幕
1 |
|
效果图2:
字幕格式转换
将youtobe专用字幕格式转换为通用字幕格式1
2
3
4
5
6
7
8
9
10
11
12
13
14
15chunli@blog:~/download$ youtube-dl -f 278+249 --sub-lang zh-TW --write-sub --convert-subs=srt --embed-subs --merge-output-format mkv https://www.youtube.com/watch?v=Z-5OX1vwmPI
[youtube] Z-5OX1vwmPI: Downloading webpage
[info] Writing video subtitles to: 高中電子學_第4章 雙極性接面電晶體_1.雙極性電晶體的構造及特性_4-1.2 電晶體的符號、4-1.3 電晶體各極體的摻雜濃度關係_陳以熙-Z-5OX1vwmPI.zh-TW.vtt
[download] Destination: 高中電子學_第4章 雙極性接面電晶體_1.雙極性電晶體的構造及特性_4-1.2 電晶體的符號、4-1.3 電晶體各極體的摻雜濃度關係_陳以熙-Z-5OX1vwmPI.f278.webm
[download] 100% of 3.42MiB in 00:42
[download] Destination: 高中電子學_第4章 雙極性接面電晶體_1.雙極性電晶體的構造及特性_4-1.2 電晶體的符號、4-1.3 電晶體各極體的摻雜濃度關係_陳以熙-Z-5OX1vwmPI.f249.webm
[download] 100% of 4.13MiB in 00:51
[ffmpeg] Merging formats into "高中電子學_第4章 雙極性接面電晶體_1.雙極性電晶體的構造及特性_4-1.2 電晶體的符號、4-1.3 電晶體各極體的摻雜濃度關係_陳以熙-Z-5OX1vwmPI.mkv"
Deleting original file 高中電子學_第4章 雙極性接面電晶體_1.雙極性電晶體的構造及特性_4-1.2 電晶體的符號、4-1.3 電晶體各極體的摻雜濃度關係_陳以熙-Z-5OX1vwmPI.f278.webm (pass -k to keep)
Deleting original file 高中電子學_第4章 雙極性接面電晶體_1.雙極性電晶體的構造及特性_4-1.2 電晶體的符號、4-1.3 電晶體各極體的摻雜濃度關係_陳以熙-Z-5OX1vwmPI.f249.webm (pass -k to keep)
[ffmpeg] Converting subtitles
Deleting original file 高中電子學_第4章 雙極性接面電晶體_1.雙極性電晶體的構造及特性_4-1.2 電晶體的符號、4-1.3 電晶體各極體的摻雜濃度關係_陳以熙-Z-5OX1vwmPI.zh-TW.vtt (pass -k to keep)
[ffmpeg] Embedding subtitles in '高中電子學_第4章 雙極性接面電晶體_1.雙極性電晶體的構造及特性_4-1.2 電晶體的符號、4-1.3 電晶體各極體的摻雜濃度關係_陳以熙-Z-5OX1vwmPI.mkv'
Deleting original file 高中電子學_第4章 雙極性接面電晶體_1.雙極性電晶體的構造及特性_4-1.2 電晶體的符號、4-1.3 電晶體各極體的摻雜濃度關係_陳以熙-Z-5OX1vwmPI.zh-TW.srt (pass -k to keep)
chunli@blog:~/download$
效果图3:
下载所有字幕
支持 视频列表形式的 URL1
2
3
4
5
6
7
8
9
10
11
12
13
14chunli@blog:~/download$ youtube-dl -f 278+249 --write-sub --all-subs --convert-subs=srt --embed-subs --merge-output-format mkv https://www.youtube.com/watch?v=PHe0bXAIuk0
[youtube] PHe0bXAIuk0: Downloading webpage
[info] Writing video subtitles to: How The Economic Machine Works by Ray Dalio-PHe0bXAIuk0.fr.vtt
[info] Writing video subtitles to: How The Economic Machine Works by Ray Dalio-PHe0bXAIuk0.en.vtt
[info] Writing video subtitles to: How The Economic Machine Works by Ray Dalio-PHe0bXAIuk0.de.vtt
[info] Writing video subtitles to: How The Economic Machine Works by Ray Dalio-PHe0bXAIuk0.tr.vtt
[info] Writing video subtitles to: How The Economic Machine Works by Ray Dalio-PHe0bXAIuk0.it.vtt
[info] Writing video subtitles to: How The Economic Machine Works by Ray Dalio-PHe0bXAIuk0.und.vtt
[info] Writing video subtitles to: How The Economic Machine Works by Ray Dalio-PHe0bXAIuk0.es-ES.vtt
[info] Writing video subtitles to: How The Economic Machine Works by Ray Dalio-PHe0bXAIuk0.ja.vtt
[download] Destination: How The Economic Machine Works by Ray Dalio-PHe0bXAIuk0.f278.webm
[download] 100% of 9.67MiB in 02:51
[download] Destination: How The Economic Machine Works by Ray Dalio-PHe0bXAIuk0.f249.webm
[download] 36.3% of 12.01MiB at 57.74KiB/s ETA 02:15
效果图4
效果图4-nplayer
下载视频列表
最高质量-带字幕-所有字幕-字幕转换-保留缓存-间隔下载-下载重试-MKV封装-指定文件名格式1
2
3
4
5
6
7
8chunli@blog:~/download$ cat template_youtobe_dl/run_youtobe_dl.sh
#!/bin/bash
URL="https://www.youtube.com/watch?v=upe1T1023yo&list=PLI6pJZaOCtF3BGm_O2f4Xy2La0zJ4-4lJ"
youtube-dl -f bestvideo+bestaudio --write-sub --all-subs --convert-subs=srt --embed-subs -k -R 3 --sleep-interval 3 --merge-output-format mkv -o '%(title)s.%(ext)s' $URL
chunli@blog:~/download$
批量任务下载
URL任务准备
list.txt1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92微算機原理及應用(I)
https://www.youtube.com/watch?v=Hv_BzQZI5BI&list=PLI6pJZaOCtF0DBjbueOO6Kh8HOiJwImjn
微算機原理及應用(II)
https://www.youtube.com/watch?v=fNTDmaiTglU&list=PLI6pJZaOCtF2nmFzrl5UBwtKVDQvUekr9
高中電子學實習_工廠安全衛生及電子應用產品介紹
https://www.youtube.com/watch?v=bWsKhGmaVrc&list=PLI6pJZaOCtF1xx4esGP6rFIzLcpnp2D5b
高中電子學實習_二極體及應用電路
https://www.youtube.com/watch?v=RA3wxR0MnTY&list=PLI6pJZaOCtF3ZtG8SHxbZ7SU-UbFu134E
高中電子學實習_雙極性接面電晶體多級放大電路
https://www.youtube.com/watch?v=2BFz_9lsUd0&list=PLI6pJZaOCtF1LagSw7FCg4Fgo5dvwn4fu
高中電子學實習_金氧半場效電晶體(MOSFET)之判別
https://www.youtube.com/watch?v=rxvwfjsPu7w&list=PLI6pJZaOCtF3TS--eiZgLmiafjnZHkxeZ
高中電子學實習_金氧半場效電晶體數位電路
https://www.youtube.com/watch?v=wJceuEV2YzI&list=PLI6pJZaOCtF1oNab7oCcEBTE0MWHk8Krp
高中電子學實習_金氧半場效電晶體放大電路
https://www.youtube.com/watch?v=XmSa9K7DeU0&list=PLI6pJZaOCtF2qKDPurYQFF4vUJ_1jpo6b
高中電子學實習_金氧半場效電晶體多級放大電路
https://www.youtube.com/watch?v=Cl1BahqZK30&list=PLI6pJZaOCtF1fUAdhcTzNgxsNmVJwbNaZ
高中電子學實習_雙極性接面電晶體
https://www.youtube.com/watch?v=UXIoTEdFui8&list=PLI6pJZaOCtF0XKgY3iKeV3xJ6xzMYuZSq
高中電子學實習_音訊放大電路
https://www.youtube.com/watch?v=fJuxn57xDKE&list=PLI6pJZaOCtF3Yjf_XCq_ph2EgE2BPb7Ni
高中電子學實習_雙極性接面電晶體放大電路
https://www.youtube.com/watch?v=S47Q3IOfa_Y&list=PLI6pJZaOCtF0afECKSaf6AcEWHv-2oiJh
電子學實習_運算放大器應用電路
https://www.youtube.com/watch?v=JuCiDMrVVC0&list=PLI6pJZaOCtF26Vb9lzMLIMCUuQs51j98t
電子學實習_運算放大器振盪電路及濾波器
https://www.youtube.com/watch?v=xCODLoynFt4&list=PLI6pJZaOCtF2vzctcTN6R4aa_c65ST47Z
[高中]選修物理_近代物理
https://www.youtube.com/watch?v=yka_hThOjNU&list=PLI6pJZaOCtF0TaLLXuHvKB39CgueID2UC
高中數位邏輯_數字系統
https://www.youtube.com/watch?v=DN3aWVScL_Q&list=PLI6pJZaOCtF0IJiRiGyCMMEqPu-x9T2va
[高工]數位邏輯_基本邏輯閘
https://www.youtube.com/watch?v=ScCdax2dVOw&list=PLI6pJZaOCtF0VCFyeDd9jVx-XZsFFCzms
[高工]數位邏輯_布林代數及第摩根
https://www.youtube.com/watch?v=C72X8qkGKng&list=PLI6pJZaOCtF0fGVEbal0S37jh5csiMAt2
[高工]數位邏輯_布林代數的化簡
https://www.youtube.com/watch?v=XEPTdb95CrQ&list=PLI6pJZaOCtF2SOiWesnxvRYDs98FfhuT6
[高工]數位邏輯_組合邏輯電路之設
https://www.youtube.com/watch?v=Dwza5xMWwbY&list=PLI6pJZaOCtF2tJIQ2ASseHZAIQciDlyjl
[高工]數位邏輯_正反器
https://www.youtube.com/watch?v=3_sK3UkncJE&list=PLI6pJZaOCtF1PDGIzAnbFoWaoT4rpX2Ux
[高工]數位邏輯_循序邏輯電路之設
https://www.youtube.com/watch?v=6QZSNSevSA4&list=PLI6pJZaOCtF2Qbr7ZGz0WR00K-EUKmLDY
[高工]數位邏輯實習_基本邏輯閘實驗
https://www.youtube.com/watch?v=NYF7WEg0h_E&list=PLI6pJZaOCtF0Sp0TMG_IqVR5F_3ESKoDN
[高工]數位邏輯實習_工場安全及衛生
https://www.youtube.com/watch?v=A_T73wBNjIs&list=PLI6pJZaOCtF2_l-6ZsyUGHYPlCFpyoprJ
[高工]數位邏輯實習_邏輯實驗儀器
https://www.youtube.com/watch?v=DiJNwmMsI3k&list=PLI6pJZaOCtF10UhxMBiU-_aSGAptRdLbF
[高工]數位邏輯實習_基本邏輯閘實驗
https://www.youtube.com/watch?v=NYF7WEg0h_E&list=PLI6pJZaOCtF0Sp0TMG_IqVR5F_3ESKoDN
[高工]數位邏輯實習_組合邏輯實驗
https://www.youtube.com/watch?v=rZNwrCljTf0&list=PLI6pJZaOCtF2vIVOj1QY8BOtRNKjSbgER
[高工]數位邏輯實習_加法器及減法器
https://www.youtube.com/watch?v=xw4sYQ5g8Vk&list=PLI6pJZaOCtF2ZI0ksTLGaNnjtPU2N3EGt
[高工]數位邏輯實習_組合邏輯電路
https://www.youtube.com/watch?v=uXFImkM8LEg&list=PLI6pJZaOCtF1dwnU9hrUUA_Fbil6Kfdva
[高工]數位邏輯實習_正反器實驗
https://www.youtube.com/watch?v=GyTPzivkXRU&list=PLI6pJZaOCtF0diZcLHwdNtlLX8xCVEuGN
[高工]數位邏輯實習_循序邏輯電路應用實驗
https://www.youtube.com/watch?v=nV4Smh5GIuQ&list=PLI6pJZaOCtF1_bE5pg4V79QAKdNx533mz
特定脚本
1 |
|
批量下载
1 |
|
查看下载任务
1 |
|
查看下载结果
1 |
|