Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Addic7ed.py #33

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 52 additions & 25 deletions periscope/plugins/Addic7ed.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ def query(self, name, season, episode, teams, langs=None):
content = content.replace("The safer, easier way", "The safer, easier way \" />")

soup = BeautifulSoup(content)
for subs in soup("td", {"class":"NewsTitle", "colspan" : "3"}):
if not self.release_pattern.match(str(subs.contents[1])):
continue
subteams = self.release_pattern.match(str(subs.contents[1])).groups()[0].lower()
for subs in soup("table", {"width":"100%", "border":"0", "align":"center", "class":"tabel95"}):
if not self.release_pattern.match(str(subs.contents[1].contents[1].contents[1])):
continue
subteams = self.release_pattern.match(str(subs.contents[1].contents[1].contents[1])).groups()[0].lower()

# Addic7ed only takes the real team into account
fteams = []
for team in teams:
Expand All @@ -110,28 +110,55 @@ def query(self, name, season, episode, teams, langs=None):
logging.debug("[Addic7ed] Team from website: %s" %subteams)
logging.debug("[Addic7ed] Team from file: %s" %teams)
logging.debug("[Addic7ed] match ? %s" %subteams.issubset(teams))
langs_html = subs.findNext("td", {"class" : "language"})
lang = self.getLG(langs_html.contents[0].strip().replace(' ', ''))
#logging.debug("[Addic7ed] Language : %s - lang : %s" %(langs_html, lang))

statusTD = langs_html.findNext("td")
status = statusTD.find("strong").string.strip()
for langs_html in subs.findAll("td", {"class" : "language"}):
lang = self.getLG(langs_html.contents[0].strip().replace(' ', ''))
statusTD = langs_html.findNext("td", {"width" : "19%"})
status = statusTD.find("b").string.strip()
# take the last one (most updated if it exists)
links = statusTD.findNext("td").findAll("a")
link = "%s%s"%(self.host,links[len(links)-1]["href"])

# take the last one (most updated if it exists)
links = statusTD.findNext("td").findAll("a")
link = "%s%s"%(self.host,links[len(links)-1]["href"])

#logging.debug("%s - match : %s - lang : %s" %(status == "Completed", subteams.issubset(teams), (not langs or lang in langs)))
if status == "Completed" and subteams.issubset(teams) and (not langs or lang in langs) :
result = {}
result["release"] = "%s.S%.2dE%.2d.%s" %(name.replace("_", ".").title(), int(season), int(episode), '.'.join(subteams)
)
result["lang"] = lang
result["link"] = link
result["page"] = searchurl
sublinks.append(result)
#Replace web teams names by compatible ones if webteam-fileteam no match
if not subteams.issubset(teams):
for webteam in subteams:
if webteam == "lol":
subteams = set(['dimension'])
logging.debug("[Addic7ed] Team translated: %s" %subteams)
continue
if webteam == "sys":
subteams = set(['dimension'])
logging.debug("[Addic7ed] Team translated: %s" %subteams)
continue
if webteam == "xii":
subteams = set(['immerse'])
logging.debug("[Addic7ed] Team translated: %s" %subteams)
continue
if webteam == "asap":
subteams = set(['immerse'])
logging.debug("[Addic7ed] Team translated: %s" %subteams)
continue
if webteam == "fqm":
subteams = set(['orenji'])
logging.debug("[Addic7ed] Team translated: %s" %subteams)
continue

if status == "Completed" and subteams.issubset(teams) and lang == langs[0]:
result = {}
result["release"] = "%s.S%.2dE%.2d.%s" %(name.replace("_", ".").title(), int(season), int(episode), '.'.join(subteams))
result["lang"] = lang
result["link"] = link
result["page"] = searchurl
sublinks.append(result)
return sublinks
if status == "Completed" and subteams.issubset(teams) and lang == langs[1]:
result = {}
result["release"] = "%s.S%.2dE%.2d.%s" %(name.replace("_", ".").title(), int(season), int(episode), '.'.join(subteams))
result["lang"] = lang
result["link"] = link
result["page"] = searchurl
sublinks.append(result)
return sublinks

def listTeams(self, subteams, separators):
teams = []
for sep in separators:
Expand Down