-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
119 lines (99 loc) · 3.63 KB
/
main.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
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
from fake_useragent import UserAgent
from requests import get, exceptions
from bs4 import BeautifulSoup
from sys import argv
def get_data(url, to_update):
headers = {
"User-Agent": str(UserAgent.chrome),
}
r = get(url, headers=headers)
soup = BeautifulSoup(r.text, 'html.parser')
film_names = soup.find_all('h2', class_='film-name')
for film_name in film_names:
link = film_name.a['href']
title = film_name.a['title']
input_string = f'TinyZoneTv Link: https://tinyzonetv.cc{link}\nHDToday Link: https://hdtoday.se{link}\nTitle: {title}\n\n'.encode(encoding='utf-8')
with open(to_update, 'ba') as f1:
f1.write(input_string)
def series(page_count):
print("\n\nTv Shows Updating\n")
with open('series.txt', 'bw') as f0:
pass
i = 1
page = []
while i <= page_count:
try:
URL = f'https://tinyzonetv.cc/tv-show?page={i}'
get_data(URL, 'series.txt')
page.append(i)
print(f'On Page: {page.pop()}')
i+=1
except exceptions.ConnectionError:
#print(i)
i = i
def movies(page_count):
print("\n\nMovies Updating\n")
with open('films.txt', 'bw') as f0:
pass
i = 1
page = []
while i <= page_count:
try:
URL = f'https://hdtoday.se/movie?page={i}'
get_data(URL, 'films.txt')
page.append(i)
print(f'On Page: {page.pop()}')
i+=1
except exceptions.ConnectionError:
#print(i)
i = i
try:
what = argv[1].lower()
if(what == "series"):
pages = int(input("""\n
Enter page count for series available either on
https://tinyzonetv.cc/tv-show, or
https://hdtoday.se/tv-show.
Default count is 405.
""") or 405)
series(pages)
elif(what == "movies"):
pages = int(input("""\n
Enter page count for movies available either on
https://tinyzonetv.cc/movie, or
https://hdtoday.se/movie.
Default count is 1261.
""") or 1261)
movies(pages)
elif(what == "both"):
pages_series = int(input("""\n
Enter page count for series available either on
https://tinyzonetv.cc/tv-show, or
https://hdtoday.se/tv-show.
Default count is 405.
""") or 405)
pages_movies = int(input("""\n
Enter page count for movies available either on
https://tinyzonetv.cc/movie, or
https://hdtoday.se/movie.
Default count is 1261.
""") or 1261)
series(pages_series)
movies(pages_movies)
else:
print("""\n\n
Invalid argument.
python main.py [argv]
series: to update series list
movies: to update movies list
both: to update both
\n\n""")
print("\n\nUpdated!!!")
except Exception:
print("""
Invalid argument.
python main.py [argv]
series: to update series list
movies: to update movies list
both: to update both
""")