aboutsummaryrefslogtreecommitdiffhomepage
path: root/libs/subliminal/providers/podnapisi.py
diff options
context:
space:
mode:
Diffstat (limited to 'libs/subliminal/providers/podnapisi.py')
-rw-r--r--libs/subliminal/providers/podnapisi.py54
1 files changed, 18 insertions, 36 deletions
diff --git a/libs/subliminal/providers/podnapisi.py b/libs/subliminal/providers/podnapisi.py
index 5dcf25583..f643682b9 100644
--- a/libs/subliminal/providers/podnapisi.py
+++ b/libs/subliminal/providers/podnapisi.py
@@ -31,7 +31,7 @@ class PodnapisiSubtitle(Subtitle):
def __init__(self, language, hearing_impaired, page_link, pid, releases, title, season=None, episode=None,
year=None):
- super(PodnapisiSubtitle, self).__init__(language, hearing_impaired=hearing_impaired, page_link=page_link)
+ super(PodnapisiSubtitle, self).__init__(language, hearing_impaired, page_link)
self.pid = pid
self.releases = releases
self.title = title
@@ -49,8 +49,7 @@ class PodnapisiSubtitle(Subtitle):
# episode
if isinstance(video, Episode):
# series
- if video.series and (sanitize(self.title) in (
- sanitize(name) for name in [video.series] + video.alternative_series)):
+ if video.series and sanitize(self.title) == sanitize(video.series):
matches.add('series')
# year
if video.original_series and self.year is None or video.year and video.year == self.year:
@@ -67,8 +66,7 @@ class PodnapisiSubtitle(Subtitle):
# movie
elif isinstance(video, Movie):
# title
- if video.title and (sanitize(self.title) in (
- sanitize(name) for name in [video.title] + video.alternative_titles)):
+ if video.title and sanitize(self.title) == sanitize(video.title):
matches.add('title')
# year
if video.year and self.year == video.year:
@@ -84,11 +82,7 @@ class PodnapisiProvider(Provider):
"""Podnapisi Provider."""
languages = ({Language('por', 'BR'), Language('srp', script='Latn')} |
{Language.fromalpha2(l) for l in language_converters['alpha2'].codes})
- server_url = 'https://www.podnapisi.net/subtitles/'
- subtitle_class = PodnapisiSubtitle
-
- def __init__(self):
- self.session = None
+ server_url = 'http://podnapisi.net/subtitles/'
def initialize(self):
self.session = Session()
@@ -114,9 +108,7 @@ class PodnapisiProvider(Provider):
pids = set()
while True:
# query the server
- r = self.session.get(self.server_url + 'search/old', params=params, timeout=10)
- r.raise_for_status()
- xml = etree.fromstring(r.content)
+ xml = etree.fromstring(self.session.get(self.server_url + 'search/old', params=params, timeout=10).content)
# exit if no results
if not int(xml.find('pagination/results').text):
@@ -126,14 +118,10 @@ class PodnapisiProvider(Provider):
# loop over subtitles
for subtitle_xml in xml.findall('subtitle'):
# read xml elements
- pid = subtitle_xml.find('pid').text
- # ignore duplicates, see http://www.podnapisi.net/forum/viewtopic.php?f=62&t=26164&start=10#p213321
- if pid in pids:
- continue
-
language = Language.fromietf(subtitle_xml.find('language').text)
hearing_impaired = 'n' in (subtitle_xml.find('flags').text or '')
page_link = subtitle_xml.find('url').text
+ pid = subtitle_xml.find('pid').text
releases = []
if subtitle_xml.find('release').text:
for release in subtitle_xml.find('release').text.split():
@@ -146,11 +134,15 @@ class PodnapisiProvider(Provider):
year = int(subtitle_xml.find('year').text)
if is_episode:
- subtitle = self.subtitle_class(language, hearing_impaired, page_link, pid, releases, title,
- season=season, episode=episode, year=year)
+ subtitle = PodnapisiSubtitle(language, hearing_impaired, page_link, pid, releases, title,
+ season=season, episode=episode, year=year)
else:
- subtitle = self.subtitle_class(language, hearing_impaired, page_link, pid, releases, title,
- year=year)
+ subtitle = PodnapisiSubtitle(language, hearing_impaired, page_link, pid, releases, title,
+ year=year)
+
+ # ignore duplicates, see http://www.podnapisi.net/forum/viewtopic.php?f=62&t=26164&start=10#p213321
+ if pid in pids:
+ continue
logger.debug('Found subtitle %r', subtitle)
subtitles.append(subtitle)
@@ -167,21 +159,11 @@ class PodnapisiProvider(Provider):
return subtitles
def list_subtitles(self, video, languages):
- season = episode = None
if isinstance(video, Episode):
- titles = [video.series] + video.alternative_series
- season = video.season
- episode = video.episode
- else:
- titles = [video.title] + video.alternative_titles
-
- for title in titles:
- subtitles = [s for l in languages for s in
- self.query(l, title, season=season, episode=episode, year=video.year)]
- if subtitles:
- return subtitles
-
- return []
+ return [s for l in languages for s in self.query(l, video.series, season=video.season,
+ episode=video.episode, year=video.year)]
+ elif isinstance(video, Movie):
+ return [s for l in languages for s in self.query(l, video.title, year=video.year)]
def download_subtitle(self, subtitle):
# download as a zip