Skip to content

Commit c52f8f0

Browse files
author
r33int
committed
Fix dubmness
1 parent bb6f790 commit c52f8f0

File tree

1 file changed

+276
-13
lines changed

1 file changed

+276
-13
lines changed

crunchyroll-dl.sh

+276-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

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

76
function start {
87
tput setaf 4; echo "Checking for youtube-dl..."
@@ -20,8 +19,10 @@ function start {
2019
}
2120

2221
function quit {
22+
echo ""
2323
tput setaf 5;echo "Exiting. Have a great day!"
24-
sleep 0.5
24+
tput setaf 2;echo "Don't forget to star me on GitHub if this script helped you! https://l.r33.space/crdl"
25+
sleep 1
2526
tput reset
2627
exit 1
2728
}
@@ -30,33 +31,295 @@ function cookie {
3031
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"
3132
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."
3233
echo ""
33-
tput setaf 6;read -e -p "Path: " cookies
34-
if [ -f $cookies ]
34+
tput setaf 6;read -r -e -p "Path: " cookies
35+
if [ ! -f "$cookies" ]
3536
then
3637
echo ""
37-
tput setaf 2;echo "Yep, I found the file you specified!"
38+
tput setaf 1;echo "You seem to have not specified a cookie file. Proceeding offline."
39+
sleep 0.5
3840
tput reset
39-
download-cookie
41+
quality_nocookie
4042
else
4143
echo ""
42-
tput setaf 1;echo "You seem to have not specified a cookie file. Maximum quality is 480p."
44+
tput setaf 2;echo "Yep, I found the file you specified!"
45+
sleep 0.5
4346
tput reset
44-
download-nocookie
47+
quality_cookie
4548
fi
4649
}
4750

48-
function downloadcookie {
49-
echo test
51+
function quality_cookie {
52+
tput setaf 2;echo "Now, choose the quality you want to download."
53+
echo ""
54+
tput setaf 6;echo "1) 480p"
55+
echo "2) 720p"
56+
echo "3) 1080p"
57+
echo "4) Best quality possible"
58+
echo "5) Go back"
59+
echo "6) Exit"
60+
echo ""
61+
while [[ $OPTION0 != "1" && $OPTION0 != "2" && $OPTION0 != "3" && $OPTION0 != "4" && $OPTION0 != "5" && $OPTION0 != "6" ]]; do
62+
read -r -p "Select an option [1-5]: " OPTION0
63+
done
64+
quality_cookie2
65+
}
66+
67+
function quality_cookie2 {
68+
case $OPTION0 in
69+
1) #480p
70+
quality="480"
71+
link
72+
;;
73+
2) #720p
74+
quality="720"
75+
link
76+
;;
77+
3) #1080p
78+
quality="1080"
79+
link
80+
;;
81+
4) #Best quality possible
82+
quality="best"
83+
link
84+
;;
85+
5) #Go back
86+
OPTION0=""
87+
tput reset
88+
cookie
89+
;;
90+
6) #Exit
91+
quit
92+
;;
93+
esac
94+
}
95+
96+
97+
function quality_nocookie {
98+
tput setaf 2;echo "Now, choose the quality you want to download."
99+
echo ""
100+
tput setaf 6;echo "1) 480p"
101+
echo "2) Go back"
102+
echo "3) Exit"
103+
echo ""
104+
while [[ $OPTION1 != "1" && $OPTION1 != "2" && $OPTION1 != "3" ]]; do
105+
read -r -p "Select an option [1-3]: " OPTION1
106+
done
107+
quality_nocookie2
108+
}
109+
110+
function quality_nocookie2 {
111+
case $OPTION1 in
112+
1) #480p
113+
quality="480"
114+
link
115+
;;
116+
2) #Go back
117+
OPTION1=""
118+
tput reset
119+
cookie
120+
;;
121+
3) #Exit
122+
quit
123+
;;
124+
esac
125+
}
126+
127+
function link {
128+
tput reset;tput setaf 6
129+
echo "Enter the URL of the video you want do download. If you want to download an entiere series, enter its link."
130+
tput setaf 5;echo "Reference URL: http://www.crunchyroll.com/laid-back-camp/episode-12-mount-fuji-and-the-laid-back-camp-girls-758807"
131+
tput setaf 5;echo "Reference URL (entiere series): http://www.crunchyroll.com/laid-back-camp"
132+
echo ""
133+
tput setaf 6;read -r -p "URL: " url
134+
if [[ $url =~ $urlregex ]]
135+
then
136+
echo ""
137+
tput setaf 2;echo "Seems good!"
138+
sleep 0.3
139+
path
140+
else
141+
echo ""
142+
tput setaf 1;echo "This link seems to be invalid. Make sure you entered a valid Crunchyroll link."
143+
sleep 0.8
144+
link
145+
fi
50146
}
51147

52-
function downloadnocookie {
53-
echo test
148+
function link_batch {
149+
tput reset;tput setaf 6
150+
echo "Enter the URL of the video you want do download."
151+
tput setaf 5;echo "Reference URL: http://www.crunchyroll.com/laid-back-camp/episode-12-mount-fuji-and-the-laid-back-camp-girls-758807"
152+
echo ""
153+
tput setaf 6;read -r -p "URL: " url
154+
if [[ $url =~ $urlregex ]]
155+
then
156+
echo ""
157+
tput setaf 2;echo "Seems good!"
158+
sleep 0.3
159+
download
160+
else
161+
echo ""
162+
tput setaf 1;echo "This link seems to be invalid. Make sure you entered a valid Crunchyroll link."
163+
sleep 0.8
164+
download
165+
fi
54166
}
55167

56168
function path {
57-
echo test
169+
tput reset
170+
tput setaf 6;echo "Where do you want to save your file? Empty input will save to the script's folder."
171+
echo ""
172+
read -r -e -p "Path: " path
173+
tput reset
174+
sleep 0.2
175+
language
176+
}
177+
178+
function language {
179+
tput setaf 6;echo "Choose the language you want to download subtitles for. Subtitles will be saved in a separate .ass file"
180+
tput setaf 1;echo "Not all languages may be available for all videos, so check availability before choosing. Please let me know if there is any missing language by opening an issue. https://l.r33.space/crdlissue"
181+
echo "";tput setaf 6
182+
echo "1) English (US)"
183+
echo "2) English (UK)"
184+
echo "3) Arabic"
185+
echo "4) French"
186+
echo "5) German"
187+
echo "6) Italian"
188+
echo "7) Portuguese (Brasil)"
189+
echo "8) Portuguese (Portugal)"
190+
echo "9) Russian"
191+
echo "10) Spanish"
192+
echo "11) Spanish (Spain)"
193+
echo "12) Go back"
194+
echo "13) Exit"
195+
echo ""
196+
while [[ $OPTION2 != "1" && $OPTION2 != "2" && $OPTION2 != "3" && $OPTION2 != "4" && $OPTION2 != "5" && $OPTION2 != "6" && $OPTION2 != "7" && $OPTION2 != "8" && $OPTION2 != "9" && $OPTION2 != "10" && $OPTION2 != "11" && $OPTION2 != "12" && $OPTION2 != "13" ]]; do
197+
read -r -p "Select an option [1-13]: " OPTION2
198+
done
199+
language2
200+
}
201+
202+
function language2 {
203+
case $OPTION2 in
204+
1) #English (US)
205+
language="enUS"
206+
download
207+
;;
208+
2) #English (UK)
209+
language="enGB"
210+
download
211+
;;
212+
3) #Arabic
213+
language="arME"
214+
download
215+
;;
216+
4) #French
217+
language="frFR"
218+
download
219+
;;
220+
5) #German
221+
language="deDE"
222+
download
223+
;;
224+
6) #Italian
225+
language="itIT"
226+
download
227+
;;
228+
7) #Portuguese (Brasil)
229+
language="ptBR"
230+
download
231+
;;
232+
8) #Portuguese (Portugal)
233+
language="ptPT"
234+
download
235+
;;
236+
9) #Russian
237+
language="ruRU"
238+
download
239+
;;
240+
10) #Spanish
241+
language="esLA"
242+
download
243+
;;
244+
11) #Spanish (Spain)
245+
language="esES"
246+
download
247+
;;
248+
12) #Go back
249+
OPTION2=""
250+
tput reset
251+
path
252+
;;
253+
13) #Exit
254+
quit
255+
;;
256+
esac
257+
}
258+
259+
function download {
260+
tput reset
261+
tput setaf 2;echo "Alright, let's download your video now! youtube-dl is going to execute below. This may take some time."
262+
tput setaf 5;echo "If you have not logged in, you might get an error about cookies file. Ignore it."
263+
echo ""
264+
if path=""
265+
then
266+
if quality="best"
267+
then
268+
youtube-dl --write-sub --sub-lang "$language" --cookies "$cookies" "$url"
269+
else
270+
youtube-dl --write-sub --sub-lang "$language" -f "best[height=$quality]" --cookies "$cookies" "$url"
271+
fi
272+
else
273+
if quality="best"
274+
then
275+
youtube-dl -o "$path/%(title)s-%(id)s.%(ext)s" --write-sub --sub-lang "$language" --cookies "$cookies" "$url"
276+
else
277+
youtube-dl -o "$path/%(title)s-%(id)s.%(ext)s" --write-sub --sub-lang "$language" -f "best[height=$quality]" --cookies "$cookies" "$url"
278+
fi
279+
fi
280+
echo ""
281+
tput setaf 2;echo "youtube-dl command has completed. Your download should be done!"
282+
tput setaf 1;echo "If you have encontered any problem, please open an issue on GitHub with the full terminal log. https://l.r33.space/crdlissue"
283+
whattodonext
58284
}
59285

286+
function whattodonext {
287+
echo ""
288+
tput setaf 5;echo "What to do next?"
289+
tput setaf 6;echo "1) Download another video"
290+
echo "2) Download another video (same settings)"
291+
echo "3) Exit"
292+
echo ""
293+
294+
while [[ $OPTION3 != "1" && $OPTION3 != "2" && $OPTION3 != "3" ]]; do
295+
read -r -p "Select an option [1-3]: " OPTION3
296+
done
297+
whattodonext2
298+
}
299+
300+
function whattodonext2 {
301+
case $OPTION3 in
302+
1) #Download another video
303+
if [ ! -f "$cookies" ]
304+
then
305+
OPTION3=""
306+
tput reset
307+
quality_nocookie
308+
else
309+
tput reset
310+
quality_cookie
311+
fi
312+
;;
313+
2) #Download another video (same settings)
314+
OPTION3=""
315+
link_batch
316+
;;
317+
3) #Exit
318+
quit
319+
;;
320+
esac
321+
}
322+
60323
tput reset
61324
sleep 0.2
62325
start

0 commit comments

Comments
 (0)