星期二, 2月 18, 2014

20140218 youtube-dl with openSUSE 13.1

有時候會有從 Youtube 下載影片的需求

參考 How to save Youtube video on Linux http://xmodulo.com/2013/03/how-to-save-youtube-videos-on-linux.html


發現他在 standard 套件庫內


# zypper  search  youtube
Retrieving repository 'NCHC-Packman' metadata ............................[done]
Building repository 'NCHC-Packman' cache .................................[done]
Loading repository data...
Reading installed packages...


S | Name                 | Summary                                  | Type      
--+----------------------+------------------------------------------+-----------
i | grilo-plugin-youtube | Media discovering and browsing framewo-> | package   
 | youtube-dl           | Download Videos from youtube.com         | package   
 | youtube-dl           | Download Videos from youtube.com         | srcpackage


安裝 youtube-dl


# zypper   install  youtube-dl
Loading repository data...
Reading installed packages...
Resolving package dependencies...


The following NEW package is going to be installed:
 youtube-dl


1 new package to install.
Overall download size: 226.1 KiB. After the operation, additional 899.5 KiB
will be used.
Continue? [y/n/? shows all options] (y): y


透過 youtube-dl  -F 來觀察可以下載的格式


> youtube-dl  -F  http://www.youtube.com/watch?v=13eLHrDcb1k
[youtube] Setting language
[youtube] 13eLHrDcb1k: Downloading video webpage
[youtube] 13eLHrDcb1k: Downloading video info webpage
[youtube] 13eLHrDcb1k: Extracting video information
Available formats:
22 : mp4 [720x1280]
18 : mp4 [360x640]
43 : webm [360x640]
5 : flv [240x400]
17 : mp4 [144x176]


指定要下載的格式進行下載 (請注意 -f 是小寫)


> youtube-dl  -f  22  http://www.youtube.com/watch?v=13eLHrDcb1k
[youtube] Setting language
[youtube] 13eLHrDcb1k: Downloading video webpage
[youtube] 13eLHrDcb1k: Downloading video info webpage
[youtube] 13eLHrDcb1k: Extracting video information
[download] Destination: Your Eyes - 竹内まりや ( 安堂ロイド~A.I. knows LOVE?~ 主題歌 )Yo1ko2 Cover-13eLHrDcb1k.mp4
[download] 100.0% of 15.98MiB at 26.02MiB/s ETA 00:00


觀察輸出


> ls
2013ironman                                                                                    下載
AddPackmanRepo.sh                                                                              公共
bin                                                                                            圖片
Dropbox                                                                                        影片
forticlientsslvpn                                                                              文件
forticlientsslvpn_linux_4.0.2010.tar.gz                                                        桌面
javaLearn                                                                                      模板
public_html                                                                                    相關會議資訊.docx
Your Eyes - 竹内まりや ( 安堂ロイド~A.I. knows LOVE?~ 主題歌 )Yo1ko2 Cover-13eLHrDcb1k.mp4  音樂


在指令的選項部份, man 了一下相關選項,找一下可能的有用選項
  • --all-formats 下載所有的格式
  • -a, --batch-file  使用檔案的方式批次下載


例如


> cat   video.list
http://www.youtube.com/watch?v=13eLHrDcb1k
http://www.youtube.com/watch?v=JFlqULfmg2M



> youtube-dl   -a   video.list
[youtube] Setting language
[youtube] 13eLHrDcb1k: Downloading video webpage
[youtube] 13eLHrDcb1k: Downloading video info webpage
[youtube] 13eLHrDcb1k: Extracting video information
[download] Destination: Your Eyes - 竹内まりや ( 安堂ロイド~A.I. knows LOVE?~ 主題歌 )Yo1ko2 Cover-13eLHrDcb1k.mp4
[download] 100.0% of 15.98MiB at 40.78MiB/s ETA 00:00
[youtube] JFlqULfmg2M: Downloading video webpage
[youtube] JFlqULfmg2M: Downloading video info webpage
[youtube] JFlqULfmg2M: Extracting video information
[download] Destination: Hiroshi Kitadani - Pegasus Fantasy Cover no AF 2006 [DBBR]-JFlqULfmg2M.mp4
[download] 100.0% of 16.46MiB at 30.48MiB/s ETA 00:00

下載為 mp3
首先要安裝 ffmpeg 套件

>youtube-dl    http://www.youtube.com/watch?v=13eLHrDcb1k --extract-audio --audio-format mp3



沒有留言: