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

Fixes in Subtitulos.es plugin #42

Open
wants to merge 2 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
26 changes: 16 additions & 10 deletions periscope/plugins/Subtitulos.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
u"French" : "fr",
u"Brazilian" : "pt-br",
u"Portuguese" : "pt",
u"Español (Latinoamérica)" : "es",
u"Español (España)" : "es",
u"Español (Latinoamérica)" : "es-la",
u"Español (España)" : "es-es",
u"Español" : "es",
u"Italian" : "it",
u"Català" : "ca"}
u"Català" : "ca",
u"Galego" : "ga"}

class Subtitulos(SubtitleDatabase.SubtitleDB):
url = "http://www.subtitulos.es"
Expand All @@ -45,14 +46,19 @@ def __init__(self, config, cache_folder_path):
#http://www.subtitulos.es/dexter/4x01
self.host = "http://www.subtitulos.es"
self.release_pattern = re.compile("Versión (.+) ([0-9]+).([0-9])+ megabytes")


def process(self, filepath, langs):
''' main method to call on the plugin, pass the filename and the wished
languages and it will query the subtitles source '''
fname = unicode(self.getFileName(filepath).lower())
guessedData = self.guessFileData(fname)
if guessedData['type'] == 'tvshow':

if "es" in langs:
langs.append("es-es")
langs.append("es-la")

log.debug("Languagess choosen: %s" % langs)
subs = self.query(guessedData['name'], guessedData['season'], guessedData['episode'], guessedData['teams'], langs)
return subs
else:
Expand All @@ -71,8 +77,8 @@ def query(self, name, season, episode, teams, langs=None):
for subs in soup("div", {"id":"version"}):
version = subs.find("p", {"class":"title-sub"})
subteams = self.release_pattern.search("%s"%version.contents[1]).group(1).lower()
teams = set(teams)
subteams = self.listTeams([subteams], [".", "_", " ", "/"])
teams = self.listTeams(teams, [".", "_", " ", "/", "-"])
subteams = self.listTeams([subteams], [".", "_", " ", "/", "-"])

log.debug("Team from website: %s" %subteams)
log.debug("Team from file: %s" %teams)
Expand All @@ -81,16 +87,16 @@ def query(self, name, season, episode, teams, langs=None):
for lang_html in nexts:
langLI = lang_html.findNext("li",{"class":"li-idioma"} )
lang = self.getLG(langLI.find("strong").contents[0].string.strip())

statusLI = lang_html.findNext("li",{"class":"li-estado green"} )
statusLI = lang_html.findNext("li",{"class":re.compile("li-estado.*")} )
status = statusLI.contents[0].string.strip()

link = statusLI.findNext("span", {"class":"descargar green"}).find("a")["href"]
link = statusLI.findNext("span", {"class":re.compile("descargar.*")})
if status == "Completado" 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["link"] = link.find("a")["href"]
result["page"] = searchurl
sublinks.append(result)

Expand Down