-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
76 lines (65 loc) · 2.3 KB
/
Main.py
File metadata and controls
76 lines (65 loc) · 2.3 KB
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
from htmlParse import Parser
from datetime import datetime
class ParseEpisodes:
def __init__(self):
self.shows = ["https://next-episode.net/game-of-thrones",
"https://next-episode.net/brooklyn-nine-nine",
"https://next-episode.net/lucifer",
"https://next-episode.net/the-blacklist",
"https://next-episode.net/izombie",
"https://next-episode.net/archer", # currently breaks
"https://next-episode.net/seal-team",
"https://next-episode.net/s.w.a.t.",
"https://next-episode.net/blindspot"]
def parse(self):
"""
Main method: parses the data and sorts it.
"""
self.create_parse_object()
"""Currently first removing fails and then sorting doesn't work since
during the removal I add a set stating which episode has failed
So temporarly it may fix the issue to first sort and then remove.
"""
self.remove_fails()
self.sort()
def get_all(self):
"""
Returns a list of dictionaries containing each episodes data.
The list is sorted by release date
"""
self.output = []
for p in self.pp:
self.output.append(p.get_output())
return self.output
def create_parse_object(self):
"""
Creates the htmlParser objects:
downloads the html data,
returns a dictionary which holds a single episodes data
"""
self.pp = []
for show in self.shows:
p = Parser(show)
p.parse()
self.pp.append(p)
def remove_fails(self):
"""
Removes the episodes from the list that failed to load.
"""
for i in self.pp:
print("type i : ", type(i))
if i.is_fail():
# print("No info available for > " + i.title)
# self.pp.append({"Name:", i.title, "Info:", "No info available"})
self.pp.remove(i)
def sort(self):
"""
Sorts the list of episodes by release date
"""
self.pp.sort(key = lambda date: datetime.strptime(date.get_date(), '%a %b %d, %Y'))
for p in self.pp:
print("")
p.output_next_ep()
m = ParseEpisodes()
m.parse()
x = m.get_all()