This repository has been archived by the owner on Jan 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
result.py
51 lines (46 loc) · 2.43 KB
/
result.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
import feedparser, re
import trackma.AnimeInfoExtractor
class Result:
result = []
url_RSS = None
show_name = None
show_ep = None
quality = None
def __init__(self, url_RSS, show_name, show_ep, quality):
self.url_RSS = url_RSS
self.show_name = show_name
self.show_ep = show_ep
self.quality = quality
self.Processing()
self.returnResult()
def Processing(self):
self.url_RSS = self.url_RSS.replace('%title%', self.show_name.replace(' ', '+').replace(':', '%3A').replace(';', '%3B'))
offset = 1
navigable = bool(re.search('%pagenumber%', self.url_RSS))
splitedUrl= self.url_RSS.split('%pagenumber%')
tracker_feed = feedparser.parse(splitedUrl[0]+str(offset)+splitedUrl[1])
while tracker_feed.entries:
tracker_feed = feedparser.parse(splitedUrl[0]+str(offset)+splitedUrl[1])
offset += 1
for i in tracker_feed.entries:
animeinfo = trackma.AnimeInfoExtractor.AnimeInfoExtractor(i.title)
if self.quality is None and self.show_ep is None:
self.result.append([i.title, i.links[0]['href']])
elif self.quality is None and animeinfo.getEpisodeNumbers() == (self.show_ep, None):
self.result.append([i.title, i.links[0]['href']])
elif self.show_ep is None and re.match('.*' + self.quality.replace('p', '') + '.*',
animeinfo.resolution):
self.result.append([i.title, i.links[0]['href']])
elif self.quality is not None and self.show_ep is not None and self.show_ep is None and re.match('.*' + self.quality.replace('p', '') + '.*',animeinfo.resolution) and animeinfo.getEpisodeNumbers() == (self.show_ep, None):
self.result.append([i.title, i.links[0]['href']])
if not navigable:
break
def returnResult(self):
returnList = dict()
for i,j in enumerate(self.result):
infoResult = trackma.AnimeInfoExtractor.AnimeInfoExtractor(j[0])
returnList[i+1] = [infoResult.name, str(infoResult.episodeStart) + ''.join(
"-" + str(infoResult.episodeEnd) if infoResult.episodeEnd != None else ''), str(infoResult.resolution), str(infoResult.subberTag)]
return returnList
def getlink(self, choice):
return self.result[choice][1]