Skip to content

Instantly share code, notes, and snippets.

@okinjp
Last active June 27, 2021 16:25
Show Gist options
  • Save okinjp/99623c7488b0b50ac17ec27094483a1d to your computer and use it in GitHub Desktop.
Save okinjp/99623c7488b0b50ac17ec27094483a1d to your computer and use it in GitHub Desktop.
#!/bin/bash
# ytdl-screen-core
VERSION=2021062806
if [ "$1" = "v" ];then
echo $VERSION
fi
if [ ! -d $DLDIR/$SNAME ]; then
mkdir -p $DLDIR/$SNAME
if [ $? = 0 ];then
echo 'cannot make DLDIR('$DLDIR/$SNAME'). '
exit
fi
fi
if [ ! -d $LISTDIR ]; then
mkdir -p $LISTDIR
if [ $? = 0 ];then
echo 'cannot make LISTDIR('$LISTDIR').'
exit
fi
fi
if [ ! -d $LOGDIR/$SNAME ]; then
mkdir -p $LOGDIR/$SNAME
if [ $? = 0 ];then
echo 'cannot make LOGDIR('$LOGDIR/$SNAME').'
exit
fi
fi
screen -S $SNAME -X stuff '\n'
if [ $? = 0 ];then
echo 'already screen opened.'
else
screen -dmS $SNAME
sleep 2s
fi
screen -S $SNAME -X stuff "PATH=$PATH\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 | grep -v 'B/s ETA' >> $LOGDIR/$SNAME-`date +%Y%m%d`.log\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 | grep -v 'B/s ETA' >> $LOGDIR/$SNAME-`date +%Y%m%d`.log\n"
screen -S $SNAME -X stuff "exit\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment