Last active
August 6, 2022 15:06
-
-
Save sashagra/c8b032dccf219ff0fa9dac9ab5a80d34 to your computer and use it in GitHub Desktop.
bin/bash script for multi episode downloads from voot.com with youtube-dl
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
#!/usr/bin/env bash | |
# File links.txt includes urls of pages of episodes separated by space | |
# Also you need preinstaled youtube-dl. You cat get it from this page: | |
# https://ytdl-org.github.io/youtube-dl/download.html | |
readonly filewithurls="links.txt" | |
readonly ytdltext="Usage: youtube-dl [OPTIONS] URL [URL...]" | |
j=0 | |
k=0 | |
formatcodes=() | |
# ############# Checking links.txt ###################### | |
if ! [ -f ./"$filewithurls" ]; then | |
echo "========================================================" | |
echo "===================== WARNING! ___======================" | |
echo "File $filewithurls not found in this folder" | |
echo "Chech your file $filewithurls or make it and paste in it" | |
echo "URLs with spaces between them. Then run script again" | |
echo "========================================================" | |
exit 1 | |
fi | |
# ############### Reading links from file ################ | |
links=(`cat $filewithurls`) | |
# ############# Checking youtube-dl ###################### | |
checkytdl="`youtube-dl -h | grep -i Usage`" | |
if ! [ -f /usr/local/bin/youtube-dl ]; then | |
if [[ "$checkytdl" == "$ytdltext" ]] | |
then | |
echo "OK. There is youtube-dl in your system" | |
else | |
echo "youtube-dl do not found in your system" | |
echo "You have to install it before runing this script" | |
echo "Go to https://ytdl-org.github.io/youtube-dl/download.html" | |
exit 1 | |
fi | |
fi | |
# ############# Inputing format codes and checking it ###################### | |
for i in ${links[@]}; do | |
youtube-dl -F $i | |
if [[ j -eq 0 ]]; then | |
j=1 | |
echo "Type format code for each videofile before downloading" | |
echo "Or if you want best quality type 'best'" | |
read -p "Type format code for video #$j or 'best' for all videos: " formatcode | |
if [[ $formatcode == "best" ]]; then # Downloading all videos with best quality | |
for i in ${links[@]} | |
do | |
echo "=====================> Downloading $i with 'best' quality" | |
youtube-dl $i | |
done | |
exit 0 | |
fi | |
checkformatcode="`youtube-dl -F $i | grep $formatcode`" | |
while [[ "$checkformatcode" == "" ]]; do | |
echo "Sorry. This video has another format than $formatcode." | |
read -p "Check it and type again: " formatcode | |
checkformatcode="`youtube-dl -F $i | grep $formatcode`" | |
done | |
formatcodes[$k]=$formatcode | |
j=2 | |
k=1 | |
else | |
read -p "Type format code for video #$j: " formatcode | |
checkformatcode="`youtube-dl -F $i | grep $formatcode`" | |
while [[ "$checkformatcode" == "" ]]; do | |
echo "Sorry. This video has another format than $formatcode." | |
read -p "Check it and type again: " formatcode | |
checkformatcode="`youtube-dl -F $i | grep $formatcode`" | |
done | |
formatcodes[$k]=$formatcode | |
j=$(($j + 1)) | |
k=$(($k + 1)) | |
fi | |
done | |
echo "===================== Downloading ========================" | |
# ############# Downloading ###################### | |
j=0 | |
for i in ${links[@]} | |
do | |
echo "=====================> Downloading $i with quality ${formatcodes[$j]}" | |
youtube-dl -f ${formatcodes[$j]} $i | |
j=$(($j + 1)) | |
done | |
# ################## END ###################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment