Skip to content

Instantly share code, notes, and snippets.

@okinjp
Last active November 25, 2020 03:24
Show Gist options
  • Save okinjp/ce624c9b731ee9ac4c53c71ef71a4603 to your computer and use it in GitHub Desktop.
Save okinjp/ce624c9b731ee9ac4c53c71ef71a4603 to your computer and use it in GitHub Desktop.
youtube-dlのチャンネルダウンロードをバックグラウンド実行できるスクリプト
#!/bin/bash
####
# CONFIG
# シェル(標準はbash)
SHELL=/bin/bash
# 半角英数などでチャンネル名が分かるもの。他のscreenで使っていないもの。
SNAME=kagura_nana
# 標準でmkvだがffmpegやavconvがあればmp4なども可能
FORMAT=mkv
# チャンネルのURL
PURL="https://www.youtube.com/channel/UCbfv8uuUXt3RSJGEwxny5Rw"
# ダウンロード済みのリストをいれるディレクトリ
LISTDIR=./ytdl/lists
# ダウンロード先のディレクトリ
DLDIR=./ytdl
####
screen -S $SNAME -X stuff '\n'
if [ $? = 0 ];then
echo 'already screen opened'
else
screen -dmS $SNAME
sleep 2s
fi
cd ~
screen -S $SNAME -X stuff "PATH=$PATH\n"
screen -S $SNAME -X stuff "SNAME=$SNAME\n"
screen -S $SNAME -X stuff "PURL=$FORMAT\n"
screen -S $SNAME -X stuff "PURL=$PURL\n"
screen -S $SNAME -X stuff "PURL=$LISTDIR\n"
screen -S $SNAME -X stuff "PURL=$DLDIR\n"
screen -S $SNAME -X stuff "youtube-dl \"$PURL/videos\" -o \"$DLDIR/$SNAME/%(title)s.%(ext)s\" -f \"bestvideo+bestaudio/best\" --merge-output-format \"$FORMAT\" --add-metadata --ignore-errors --download-archive $LISTDIR/$SNAME-list.txt\n"
screen -S $SNAME -X stuff "youtube-dl \"$PURL/playlists\" -o \"$DLDIR/$SNAME/%(title)s.%(ext)s\" -f \"bestvideo+bestaudio/best\" --merge-output-format \"$FORMAT\" --add-metadata --ignore-errors --download-archive $LISTDIR/$SNAME-list.txt -4\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment