Skip to content

Commit

Permalink
crunchyrollDownloader is back and is better than ever!
Browse files Browse the repository at this point in the history
The script has been revwritten from scratch! Hope you will appreciate it! This is also the first release.
  • Loading branch information
r33int committed Apr 2, 2018
1 parent 9037abd commit 73164e8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 98 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -9,14 +9,14 @@ This script downloads anime videos from Crunchyroll using youtube-dl.
### Requirements :
1. Any Linux distribution. Other unix systems untested but should work.
2. youtube-dl installed.
3. A Crunchyroll account. You can use a free account but will only allow downloads up to 480p and premium episodes won't work.
3. A Crunchyroll account. You can use a free account but this will only allow downloads up to 480p and premium episodes won't work.
4. A working brain.

#### How does it work ?
First, clone this repository. You can do that from GitHub web interface or with the command :
First things first, clone this repository. You can do that from GitHub web interface or with the command:
`git clone https://github.com/r33int/crunchyrollDownloader.git`

Then, make the script executable using
Make the script executable using:
`chmod +x crunchyroll-dl.sh`

Finally, execute it and follow the instructions.
Expand All @@ -28,6 +28,6 @@ To authentificate to Crunchyroll, you will need a cookies.txt file. To extract t

Once installed, go to crunchyroll.com, login if that's not already done (don't forget to tick "Stay logged in"), then click on the extensions's icon, and click download.

![](https://r33int.pw/pic/crdl.jpg)
![](https://pic.r33.space/uploads/big/da7b0635af59caa0f5826f85e51d095b.png)

Finally, your cookies.txt file is ready.
Finally, your cookies.txt file is ready. For convenience, I recommand putting this file in the folder where the script is.
148 changes: 55 additions & 93 deletions crunchyroll-dl.sh
@@ -1,100 +1,62 @@
#!/bin/bash
function jumpto
{
label=$1
cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
eval "$cmd"
exit
}

cookiesstep=${1:-"cookiesstep"}


#Some variables...
urlregex='(http://crunchyroll.com/|http://www.crunchyroll.com)[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
qualityregex='[1-3]'

echo Checking for youtube-dl...
sleep 0.2
if ! type "youtube-dl" > /dev/null; then
tput setaf 1;echo youtube-dl has not been found. Please install it and relaunch this script. If you are sure you have it installed, please open an issue on GitHub. https://l.r33.space/crdlissue
echo Press CTRL+C to exit.
sleep infinity
else
sleep 0.5
clear
tput setaf 6;echo Welcome!
sleep 0.2
tput setaf 5;echo This script makes it easier to download anime videos from Crunchyroll using youtube-dl.
sleep 0.2
echo Enjoy!
sleep 0.2
echo
tput setaf 2;read -e -p 'First, enter the link of the video you want to download: ' link
function start {
tput setaf 4; echo "Checking for youtube-dl..."
sleep 0.2
if ! type "youtube-dl" > /dev/null; then
tput setaf 1;echo "youtube-dl has not been found. Please install it and relaunch this script. If you are sure you have it installed, please open an issue on GitHub. https://l.r33.space/crdlissue"
echo Press CTRL+C to exit.
sleep infinity
else
tput setaf 2;echo "youtube-dl has been found, we may continue!"
sleep 0.1
tput reset
cookie
fi
}

if [[ $link =~ $urlregex ]]
then
sleep 0.5
clear
PS3='Now, select the quality you want to use: '
options=("480p" "720p" "1080p" "Exit")
select opt in "${options[@]}"
do
case $opt in
"480p")
quality='480'
break
;;
"720p")
quality='720'
break
;;
"1080p")
quality='1080'
break
;;
"Exit")
tput reset
exit
;;
*)
tput setaf 1;echo Invalid selection.;tput setaf 2;;
esac
done
sleep 0.5
cookiesstep:
clear
read -e -p 'Enter the path of your cookies.txt file. Not sure of what it is? Check the readme on GitHub for details. https://l.r33.space/crdl: ' cookies
if [ -f $cookies ]
then
echo Cookies file found.
sleep 0.5
clear
echo 'Where do you want to save your video? Empty input will save to the current path.'
tput setaf 1;read -e -p 'Enter path: ' output
sleep 0.5
clear
tput setaf 5;echo 'Alright. At the moment, this script downloads english subtitles at the moment. If you need another language, feel free to modify the script!'
echo Starting download...
sleep 0.5
tput setaf 4
if [$output = ""]
then
youtube-dl --write-sub --sub-lang enUS -f "best[height=$quality]" --cookies $cookies $link
tput setaf 2;echo 'youtube-dl command has completed! Download should be done. If you have encountered any issue, please open an issue on GitHub. https://l.r33.space/crdlissue'
tput reset
else
youtube-dl -o "$output/%(title)s-%(id)s.%(ext)s" --write-sub --sub-lang enUS -f "best[height=$quality]" --cookies $cookies $link
tput setaf 2;echo 'youtube-dl command has completed! Download should be done. If you have encountered any issue, please open an issue on GitHub. https://l.r33.space/crdlissue'
tput reset
fi
else
tput setaf 1 echo Cookies file not found. Please try again.
sleep 0.5
tput setaf 2
jumpto cookiesstep
fi
else
function quit {
tput setaf 5;echo "Exiting. Have a great day!"
sleep 0.5
tput setaf 1; echo "Invalid link. Make sure you entered a Crunchyroll link."
fi
fi
tput reset
exit 1
}

function cookie {
tput setaf 6;echo "First of all, let's identify you! If you want to use an account, please specify the path of your cookies.txt file. Not sure about what I am talking about? Check README for more details. https://l.r33.space/crdl"
tput setaf 5;echo "If you do not want to use an account, just press enter. Please keep in mind that without an account, you will not be able to download premium-only videos and maximum quality is 480p."
echo ""
tput setaf 6;read -e -p "Path: " cookies
if [ -f $cookies ]
then
echo ""
tput setaf 2;echo "Yep, I found the file you specified!"
tput reset
download-cookie
else
echo ""
tput setaf 1;echo "You seem to have not specified a cookie file. Maximum quality is 480p."
tput reset
download-nocookie
fi
}

function downloadcookie {
echo test
}

function downloadnocookie {
echo test
}

function path {
echo test
}

tput reset
sleep 0.2
start

0 comments on commit 73164e8

Please sign in to comment.