-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain_script.py
executable file
·78 lines (59 loc) · 2.17 KB
/
main_script.py
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
""" This script checks for the new episodes of any TV series or anime.
Enter the path name accordingly.
"""
import os
import sys
from utils import is_internet_connected, path_check, zero_prefix
from new_episode_check import tv_episode_check, anime_episode_check
# Browse the TV Series folder
def tv_series(path, name_list, mode):
print('\n\nchecking tv series...\n')
for name in name_list:
path_check(path, name)
series = ' '.join(name.split()[:-2])
season = int(name.split()[-1])
ep_season_occurrence = 's' + zero_prefix(season) + 'e'
dir_contents = [ep.lower() for ep in os.listdir(path + name)]
dir_contents_idx = [ep.find(ep_season_occurrence.lower()) for ep in dir_contents]
dir_episodes = [ep[x+4:x+6] for x, ep in zip(dir_contents_idx, dir_contents)]
dir_episodes.sort(key=int)
new_ep = int(1 if os.listdir(path + name) == [] else int(dir_episodes[-1]) + 1)
tv_episode_check(
series, season,
'https://en.wikipedia.org/wiki/',
mode, new_ep
)
print('\n###########################################################')
# Browse the Anime folder
def anime(path, name_list):
print('\n\nchecking anime...\n')
for name in name_list:
path_check(path, name)
dir_contents = [ep.split('.')[0] for ep in os.listdir(path + name)]
dir_contents.sort(key=int)
new_ep = int('1' if os.listdir(path + name) == [] else str(int(dir_contents[-1]) + 1))
anime_episode_check(
name,
'http://www.chia-anime.tv/episode/',
new_ep
)
print('\n###########################################################')
if not is_internet_connected():
print('No internet connection')
sys.exit(0)
tv_list = [
'Gotham Season 4',
'The Flash Season 4',
'Arrow Season 6',
'The Big Bang Theory Season 11'
]
anime_list = [
'Boruto Naruto Next Generations',
'Dragon Ball Super',
'One Piece'
]
path_anime = '/media/shan/Local Disk/Anime/'
path_tv = '/media/shan/Local Disk/TV/'
modes = ['Local File', 'Timed']
tv_series(path_tv, tv_list, modes[1])
anime(path_anime, anime_list)