-
Notifications
You must be signed in to change notification settings - Fork 0
/
tv_eptitles
executable file
·51 lines (45 loc) · 1.23 KB
/
tv_eptitles
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
# match "#-##" to "#-## - "
# check if show title was provided
# if not, quit
if [ -z "$1" ]; then
echo "ERROR: No TV show was provided."
exit
fi
# grab the source txt
TEMPINDEX=$(lynx -dump -nolist epguides.com/$1 | grep "Episode #")
SEARCH="Titles"
let INDEX=${#TEMPINDEX}-6
# need to work on epguides.com search for
# 1-01 OR 1- 1
# "Episode Title" OR "Titles"
# need to support double episode files, such as s01e02-03
# For seasons 1 to 9
for file in [0-9]-[0-9][0-9].*; do
FILENAME="${file%.*}"
EXT="${file##*.}"
if [ ${#FILENAME} == 4 ]; then
OOGA=$(lynx -width=300 -dump -nolist epguides.com/$1 | grep "$FILENAME")
TITLE=${OOGA:$INDEX}
TITLE=${TITLE//\ \[*\]/}
TITLE=${TITLE//\ \([0-9]\)/}
if [[ $TITLE == "" ]]; then
let INDEX=${#TEMPINDEX}-13
echo "inside"
fi
echo "$file >>> $FILENAME - $TITLE.$EXT"
mv "$file" "$FILENAME - $TITLE.$EXT"
fi
done
# For seasons 10+
for file in [0-9][0-9]-[0-9][0-9].*; do
FILENAME="${file%.*}"
EXT="${file##*.}"
if [ ${#FILENAME} == 5 ]; then
OOGA=$(lynx -width=300 -dump -nolist epguides.com/$1 | grep "$FILENAME")
TITLE=${OOGA:$INDEX}
TITLE=${TITLE//\ \[*\]/}
echo "$file >>> $FILENAME - $TITLE.$EXT"
mv "$file" "$FILENAME - $TITLE.$EXT"
fi
done