Created
June 16, 2016 17:42
-
-
Save nejni-marji/7863ae77d759311bce31df09e550cb3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#set -x | |
# {{{ getopts | |
while getopts ":i::o:p" VAR ; do | |
case $VAR in | |
i) # --input-file | |
export PLYDL_INPUT=$OPTARG | |
;; | |
o) # --output-file | |
export PLYDL_OUTPUT=$OPTARG | |
;; | |
esac | |
done | |
# }}} | |
# {{{ setopts | |
if [[ -z "$PLYDL_INPUT" ]] ; then | |
echo "No input file selected, exiting" | |
export PLYDL_INPUT=plydl_input.txt # Default needed for -p | |
exit | |
fi | |
if [[ -z "$PLYDL_OUTPUT" ]] ; then | |
export PLYDL_OUTPUT=playlist.m3u | |
fi | |
# }}} | |
export PLYDL_LEN=`cat $PLYDL_INPUT | wc -l` | |
touch $PLYDL_OUTPUT && rm $PLYDL_OUTPUT | |
# {{{ download and make | |
for PLYDL_VIDEO in `seq 1 2 $PLYDL_LEN` ; do | |
export PLYDL_TITLE_NUM=$PLYDL_VIDEO | |
export PLYDL_ID_NUM=$(($PLYDL_VIDEO + 1)) | |
export PLYDL_TITLE="`sed $PLYDL_TITLE_NUM'p;d' $PLYDL_INPUT`" | |
export PLYDL_ID="`sed $PLYDL_ID_NUM'p;d' $PLYDL_INPUT`" | |
youtube-dl --ignore-errors --output "%(id)s.%(ext)s" -- $PLYDL_ID | |
export PLYDL_FILE="`find $PWD | grep -- $PLYDL_ID`" | |
echo "#EXTM3U" >> $PLYDL_OUTPUT | |
echo "#EXTINF:,$PLYDL_TITLE" >> $PLYDL_OUTPUT | |
echo "$PLYDL_FILE" >> $PLYDL_OUTPUT | |
echo "#EXTM3U" | |
echo "#EXTINF:,$PLYDL_TITLE" | |
echo "$PLYDL_FILE" | |
done | |
# }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment