11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

オートメーターでYouTubeダウンロード

Posted at

Homebrewでyoutube-dlをインスコ。

Terminal
brew install youtube-dl

オートメーターでコマンド実行のサービスを作成。
URLを引数として受け取るようにし、

Automator
VID=`echo $1 | sed 's/^.*v=//g'`;
FMT=`youtube-dl -F ${VID} | grep mp4 | sort -r | head -1 | cut -b 1-2`;
cd ~/Downloads;
youtube-dl -o '%(title)s.%(ext)s' -f ${FMT} ${VID};

これを実行すると自動的にmp4で可能なサイズの中で最も大きいものをフォーマットとして選び、ダウンロードしてくれる。
好みに合わせてmp4の部分を他のフォーマットにしたり、ソートの-rを取れば最も小さなサイズを選択したり、cdのところで保存フォルダを変えられます。

ちなみにnicovideo-dlなるものもありました。
コマンドの内容は名前から察する通りですが、使える機能がyoutube-dlほど多くないのと、nicovideo-dlのほうは-uでユーザーネーム、-pでパスワードを指定しないと一部の動画しかアクセス出来ないかもしれません。
youtube-dlでも-u,-pでログイン出来ますが、ログインしなくてもダウンロード出来るので必要性が感じられません。
むしろログインに時間を取られてしまうだけです。

Automator
VID=`echo $1 | sed 's/\(^.*\/watch\/\)//g' | sed 's/?.*$//g'`;
cd ~/Downloads;
nicovideo-dl -u ユーザーネーム -p パスワード -t ${VID};

これでいけます。
実行はURL上で右クリックでコンテキストメニュー開いてサービスから選ぶ。

11
11
1

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
11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?