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 Podnapisi.py #36

Open
wants to merge 6 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
33 changes: 27 additions & 6 deletions periscope/plugins/Podnapisi.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,40 @@ def query(self, token, langs=None):
''' makes a query on podnapisi and returns info (link, lang) about found subtitles'''
guessedData = self.guessFileData(token)
sublinks = []
params = {"sK" : token}
if langs and len(langs) == 1:
params["sJ"] = self.getLanguage(langs[0])
sJ = self.getLanguage(langs[0])
else:
params["sJ"] = 0
sJ = 0
sK = guessedData["name"].replace(" ", ".")

searchurl = self.host + self.search + urllib.urlencode(params)
#Series name adaptation
if sK == "once.upon.a.time.2011":
sK = "once.upon.a.time"

sTS = str(guessedData["season"])
sTE = str(guessedData["episode"])
teams = guessedData["teams"]
sR = ""
for team in teams:
sR = sR + "+" + team
sR = sR.replace("-", "+").replace("+hd-", "").replace("+hd", "").replace("+tv-", "").replace("720p-", "").replace("1080p-", "").replace("bluray-", "").replace("x264-", "").replace("720p", "").repl
if "dimension" in sR:
sR += "+lol+sys"
if "immerse" in sR:
sR += "+xii+asap"
if "orenji" in sR:
sR += "+fqm"
options = "&sK=" + sK + "&sJ=" + sJ + "&sTS=" + sTS + "&sTE=" + sTE + "&sR=" + sR

searchurl = self.host + self.search + options
content = self.downloadContent(searchurl, 10)

# Workaround for the Beautifulsoup 3.1 bug
content = content.replace("scr'+'ipt", "script")
soup = BeautifulSoup(content)
for subs in soup("tr", {"class":"a"}) + soup("tr", {"class": "b"}):
details = subs.find("span", {"class" : "opis"}).findAll("b")
if guessedData["type"] == "tvshow" and guessedData["season"] == int(details[0].text) and guessedData["episode"] == int(details[1].text):
details = subs.find("td").findAll("b")
if guessedData["type"] == "tvshow" and guessedData["season"] == int(details[1].text) and guessedData["episode"] == int(details[2].text):
links = subs.findAll("a")
lng = subs.find("a").find("img")["src"].rsplit("/", 1)[1][:-4]
if langs and not self.getLG(lng) in langs:
Expand Down Expand Up @@ -117,6 +136,8 @@ def createFile(self, subtitle):
content = content.replace("</br", "<br")
soup = BeautifulSoup(content)
dlimg = soup.find("img", {"title" : "Download"})
if dlimg == None:
dlimg = soup.find("img", {"src" : "/images/simple/downloadS.gif"})
subtitle["link"] = self.host + dlimg.parent["href"]

SubtitleDatabase.SubtitleDB.createFile(self, subtitle)
Expand Down