LoginSignup
4
3

More than 3 years have passed since last update.

(CUIでできる)ubuntu18.04でyoutube-dlを使って複数のyoutube動画の自動ダウンロード

Last updated at Posted at 2020-07-21

複数のyoutube動画を自動でダウンロードしてほしい!

所持しているurlから動画を自動でダウンロードする必要が出てきたので書きました。(実行に移すかは別として。)後サーバで勝手にやって欲しいのでCUIで実行できるようにという条件付き。

基本的に使うのはyoutube-dlで、取得動画を任意の形式に変換するのにffmpegを用いているっぽい。まあ結局どっちもインストールする必要がある。

インストール方法

ffmpegのインストール

terminal
sudo apt update
sudo apt install ffmpeg

youtube-dlのインストール

aptでもインストール可能だが、古いバージョンが入る場合があるので直接wgetしてインストールが無難。
インストール後chmodで実行権限を付与する。

terminal
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

簡単に使い方説明

ダウンロード

terminal
youtube-dl "欲しい動画のURL" -f mp4

出来る限り高画質・高音質でダウンロード(mp4でダウンロード出来る場合)(試してない)

terminal
youtube-dl "欲しい動画のURL" -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]"

(本題)複数ダウンロード

1urlを一行としたファイルを作成します。

target_urls
http://youtube.com/watch?v=num_1
http://youtube.com/watch?v=num_2
...
http://youtube.com/watch?v=num_n
terminal
youtube-dl -f mp4 -a target_urls

参考URL

youtube-dl全般
http://bobbyquine.hatenablog.com/entry/2018/01/05/025418
ffmpegのインストール
https://qiita.com/momongaclub/items/92608827be59c14688c8
複数ダウンロード
https://qastack.jp/ubuntu/334081/downloading-multiple-files-with-youtube-dl

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3