-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrunchy.sh
159 lines (139 loc) · 3.92 KB
/
crunchy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
# This argument sets a premium username Crunchyroll account.
# By command line, it is "-u username" or "--username username"
USERNAME="" # Default: "" (Means guest session).
# This argument sets a password for your username Crunchyroll account.
# By command line, it is "-p password" or "--password password"
PASSWORD="" # Default: "" (Means guest session if username is not specific).
# This argument sets video resolution.
# By command line, it is "-r value" or "--resolution value".
# Default: "" (Means best resolution).
# Change to other value as "worst", "240p", "360p", "480p", "720p", "1080p", "best".
RESOLUTION="1080"
# This argument sets the episodes to download.
# By command line, it is "-e <s>" or "--episodes <s>"
EPISODES="" # Default: "" (Means all).
# This argument sets subtitle format.
# By command line, it is "-f value" or "--format value".
# Default: "" (Means ass format).
FORMAT="ass"
# This argument sets output path.
# By command line, it is "-o value" or "--output value".
# Default: "" (Means same directory).
OUTPUT=""
# This argument sets Batch file.
# By command line, it is "-b value" or "--batch value".
# Default: "" (default: CrunchyRoll.txt).
BATCH=""
# CHECKING...
if [ ${#} -eq 0 ]
then
echo "Error. Crunchy needs a input URL as parameter."
echo "Syntaxis:"
echo " ${0} -i URL [-f format] [-s force] [-c] [-o output]"
exit -1
fi
# PARSING...
while [ ${#} -gt 0 ]
do
case "${1}" in
-i|--input)
INPUT="${2}"
shift
;;
-o|--output)
if [ "${2:0:1}" = "/" ]
then
OUTPUT="${2}"
else
OUTPUT="${DEST_DIR}/${2}"
fi
if [ -z "$(echo ${OUTPUT##*/} | grep "\.")" ] # Output given is a directory.
then
DEST_DIR="$(readlink -f "${OUTPUT}")"
unset OUTPUT
fi
shift
;;
-u|--username)
USERNAME="${2}"
shift
;;
-p|--password)
PASSWORD="${2}"
shift
;;
-e|--episodes)
EPISODES="${2}"
shift
;;
-f|--format)
FORMAT="${2}"
shift
;;
-b|--batch)
BATCH="${2}"
shift
;;
-r|--resolution)
RESOLUTION="${2}"
shift
;;
*)
echo "Error. Unexpected argument: ${1}"
exit -1
;;
esac
shift
done
# PREPARING PARAMETERS
if [ -n "${USERNAME}" ]
then
USERNAME="-u ${USERNAME}"
fi
if [ -n "${PASSWORD}" ]
then
PASSWORD="-p ${PASSWORD}"
fi
if [ -n "${RESOLUTION}" ]
then
RESOLUTION="-r ${RESOLUTION}"
else
RESOLUTION="-r 1080"
fi
if [ -n "${EPISODES}" ]
then
EPISODES="-e ${EPISODES}"
fi
if [ -n "${FORMAT}" ]
then
FORMAT="-f ${FORMAT}"
else
FORMAT="-f ass"
fi
if [ -n "${OUTPUT}" ]
then
OUTPUT="-o ${OUTPUT}"
else
OUTPUT="-o /downloads"
fi
if [ -n "${BATCH}" ]
then
BATCH="-b ${BATCH}"
fi
if [ -n "${INPUT}" ]
then
INPUT="${INPUT}"
fi
# MAIN...
if [ -n "${BATCH}" ]
then
crunchy ${USERNAME} ${PASSWORD} ${BATCH} ${OUTPUT} ${RESOLUTION} ${FORMAT}
else
if [ -n "${EPISODES}" ]
then
crunchy ${USERNAME} ${PASSWORD} ${OUTPUT} ${RESOLUTION} ${FORMAT} ${INPUT} ${EPISODES}
else
crunchy ${USERNAME} ${PASSWORD} ${OUTPUT} ${RESOLUTION} ${FORMAT} ${INPUT}
fi
fi