-
Notifications
You must be signed in to change notification settings - Fork 0
/
7ed-manual.sh
executable file
·51 lines (43 loc) · 1.71 KB
/
7ed-manual.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
#!/bin/bash
# For each video file in the execution directory, asks for matching subtitle
# Downloads subtitle from Addic7ed, then rename video file.
for f in *.{mp4,avi}
do
if [ -f "$f" ]
then
ext="${f##*.}"
regex="(.*)\.[s|S]?([0-9]{1,2})[x|X|e|E]?([0-9]{2})(.*)"
[[ $f =~ $regex ]]
serie=`echo ${BASH_REMATCH[1]} | tr '[:upper:]' '[:lower:]'`
serie=$(echo $serie | tr '\.' '_')
season=`echo ${BASH_REMATCH[2]}`
season=$(expr $season + 0)
episode=`echo ${BASH_REMATCH[3]}`
episode=$(expr $episode + 0)
if [ $season -eq 0 ] && [ $episode -eq 0 ]; then
continue
fi
referer="Referer:http://addic7ed.com/serie/$serie/$season/$episode/addic7ed"
if [ "$serie" == "marvels_agent_carter" ]; then
serie="marvel's_agent_carter"
elif [ "$serie" == "marvels_agents_of_s_h_i_e_l_d" ]; then
serie="marvel's_agents_of_s.h.i.e.l.d."
elif [ "$serie" == "marvels_daredevil" ]; then
serie="marvel's_daredevil"
fi
link="http://addic7ed.com/serie/$serie/$season/$episode/8"
echo "$f"
echo "Link: $link"
read -e -p "Subs? " url
if [[ ! -z "$url" ]]
then
filename="$(curl -sIL $url -H "$referer" | sed -r -e 's/^ *Content-Disposition[ \t]*:[ \t]*[^ \t;]+;[ \t]*filename[ \t]*=[ \t]*("(([^"]|\")*)".*|([^; \t\r"]+)(([^;\r]*[^; \t\r]+)*)[ \t]*(;.*|[\r]?)$)/\2\4\5/' -e 't' -e 'd')"
name=`echo $filename | sed -E 's/\.\S*Addic7ed.com.srt$//g'`
curl --silent -O -J -L $url -H "$referer"
mv "$filename" "$name".srt
mv "$f" "$name"."$ext"
fi
echo
fi
done
tree