summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVitiko <[email protected]>2023-03-10 18:12:37 -0400
committerVitiko <[email protected]>2023-03-10 18:12:37 -0400
commit587af7d138f1b11e034c16a70b1032a8932cc59c (patch)
tree8afabad720a88b14e18fc7ca6d84ba087b41dc47
parentdec2f7d4788d720ad9503220050ae83e7c6462e0 (diff)
downloadbazarr-587af7d138f1b11e034c16a70b1032a8932cc59c.tar.gz
bazarr-587af7d138f1b11e034c16a70b1032a8932cc59c.zip
Supersubtitles provider: fix #2092v1.2.1-beta.1
-rw-r--r--libs/subliminal_patch/providers/supersubtitles.py29
-rw-r--r--tests/subliminal_patch/test_supersubtitles.py25
2 files changed, 31 insertions, 23 deletions
diff --git a/libs/subliminal_patch/providers/supersubtitles.py b/libs/subliminal_patch/providers/supersubtitles.py
index 7f779fedb..e19bf629e 100644
--- a/libs/subliminal_patch/providers/supersubtitles.py
+++ b/libs/subliminal_patch/providers/supersubtitles.py
@@ -59,19 +59,6 @@ class SuperSubtitlesSubtitle(Subtitle):
"""SuperSubtitles Subtitle."""
provider_name = 'supersubtitles'
- def __str__(self):
- subtit = "Subtitle id: " + str(self.subtitle_id) \
- + " Series: " + self.series \
- + " Season: " + str(self.season) \
- + " Episode: " + str(self.episode) \
- + " Version: " + str(self.version) \
- + " Releases: " + str(self.releases) \
- + " DownloadLink: " + str(self.page_link) \
- + " Matches: " + str(self.matches)
- if self.year:
- subtit = subtit + " Year: " + str(self.year)
- return subtit.encode('utf-8')
-
def __init__(self, language, page_link, subtitle_id, series, season, episode, version,
releases, year, imdb_id, uploader, asked_for_episode=None, asked_for_release_group=None):
super(SuperSubtitlesSubtitle, self).__init__(language, page_link=page_link)
@@ -86,8 +73,7 @@ class SuperSubtitlesSubtitle(Subtitle):
if year:
self.year = int(year)
- self.release_info = u" ,".join([u"%s (%s)" % (self.__get_name(), releases[0])] +
- (releases[1:] if len(releases) > 1 else []))
+ self.release_info = "\n".join([self.__get_name(), *self.releases])
self.page_link = page_link
self.asked_for_release_group = asked_for_release_group
self.asked_for_episode = asked_for_episode
@@ -98,18 +84,15 @@ class SuperSubtitlesSubtitle(Subtitle):
def numeric_id(self):
return self.subtitle_id
- def __get_name(self):
- ep_addon = (" S%02dE%02d" % (self.season, self.episode)) if self.episode else ""
- return u"%s%s%s" % (self.series, " (%s)" % self.year if self.year else "", ep_addon)
-
- def __repr__(self):
- return '<%s %r [%s]>' % (
- self.__class__.__name__, u"%s [%s]" % (self.__get_name(), self.version), self.language)
-
@property
def id(self):
return str(self.subtitle_id)
+ def __get_name(self):
+ ep_addon = f"S{self.season:02}E{self.episode:02}" if self.episode else ""
+ year_str = f" ({self.year})"
+ return f"{self.series}{year_str or ''} {ep_addon}".strip()
+
def get_matches(self, video):
matches = set()
update_matches(matches, video, self.releases)
diff --git a/tests/subliminal_patch/test_supersubtitles.py b/tests/subliminal_patch/test_supersubtitles.py
index 3794a04ca..00d118264 100644
--- a/tests/subliminal_patch/test_supersubtitles.py
+++ b/tests/subliminal_patch/test_supersubtitles.py
@@ -105,3 +105,28 @@ def test_download_movie_subtitle(movies):
with SuperSubtitlesProvider() as provider:
provider.download_subtitle(subtitle)
assert subtitle.is_valid()
+
+
+def test_subtitle_reprs(movies):
+ subtitle = SuperSubtitlesSubtitle(
+ Language.fromalpha2("en"),
+ "https://www.feliratok.eu/index.php?action=letolt&felirat=1634579718",
+ 1634579718,
+ "Dune",
+ 0,
+ 0,
+ "",
+ [
+ "NF.WEB-DL.1080p-TEPES",
+ "NF.WEBRip.1080p-TEPES",
+ "WEBRip-ION10",
+ "WEBRip-ION265",
+ "WEBRip.1080p-RARBG",
+ ],
+ "",
+ "",
+ "",
+ asked_for_episode=None,
+ )
+ assert isinstance(subtitle.__repr__(), str)
+ assert isinstance(subtitle.__str__(), str)