Add original_series to Episode

This commit is contained in:
Antoine Bertin
2016-02-05 18:12:40 +01:00
parent 5e8cbad452
commit 5c23a0b375
9 changed files with 23 additions and 18 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ class Addic7edSubtitle(Subtitle):
if video.title and sanitize(self.title) == sanitize(video.title):
matches.add('title')
# year
if video.year == self.year:
if video.original_series and self.year is None or video.year and video.year == self.year:
matches.add('year')
# release_group
if video.release_group and self.version and video.release_group.lower() in self.version.lower():
+1 -1
View File
@@ -57,7 +57,7 @@ class OpenSubtitlesSubtitle(Subtitle):
if video.series and sanitize(self.series_name) == sanitize(video.series):
matches.add('series')
# year
if video.year == self.movie_year:
if video.original_series and self.movie_year is None or video.year and video.year == self.movie_year:
matches.add('year')
# season
if video.season and self.series_season == video.season:
+1 -1
View File
@@ -50,7 +50,7 @@ class PodnapisiSubtitle(Subtitle):
if video.series and sanitize(self.title) == sanitize(video.series):
matches.add('series')
# year
if video.year == self.year:
if video.original_series and self.year is None or video.year and video.year == self.year:
matches.add('year')
# season
if video.season and self.season == video.season:
+1 -1
View File
@@ -53,7 +53,7 @@ class TVsubtitlesSubtitle(Subtitle):
if video.episode and self.episode == video.episode:
matches.add('episode')
# year
if self.year == video.year:
if video.original_series and self.year is None or video.year and video.year == self.year:
matches.add('year')
# release_group
if video.release_group and self.release and video.release_group.lower() in self.release.lower():
+1 -1
View File
@@ -210,7 +210,7 @@ def guess_matches(video, guess, partial=False):
if video.year and 'year' in guess and guess['year'] == video.year:
matches.add('year')
# count "no year" as an information
if not partial and video.year is None and 'year' not in guess:
if not partial and video.original_series and 'year' not in guess:
matches.add('year')
elif isinstance(video, Movie):
# year
+9 -4
View File
@@ -129,11 +129,13 @@ class Episode(Video):
:param int episode: episode number of the episode.
:param str title: title of the episode.
:param int year: year of the series.
:param bool original_series: whether the series is the first with this name.
:param int tvdb_id: TVDB id of the episode.
:param \*\*kwargs: additional parameters for the :class:`Video` constructor.
"""
def __init__(self, name, series, season, episode, title=None, year=None, tvdb_id=None, **kwargs):
def __init__(self, name, series, season, episode, title=None, year=None, original_series=True, tvdb_id=None,
**kwargs):
super(Episode, self).__init__(name, **kwargs)
#: Series of the episode
@@ -151,6 +153,9 @@ class Episode(Video):
#: Year of series
self.year = year
#: The series is the first with this name
self.original_series = original_series
#: TVDB id of the episode
self.tvdb_id = tvdb_id
@@ -162,10 +167,10 @@ class Episode(Video):
if 'title' not in guess or 'season' not in guess or 'episode' not in guess:
raise ValueError('Insufficient data to process the guess')
return cls(name, guess['title'], guess['season'], guess['episode'], format=guess.get('format'),
return cls(name, guess['title'], guess['season'], guess['episode'], title=guess.get('episode_title'),
year=guess.get('year'), format=guess.get('format'), original_series='year' not in guess,
release_group=guess.get('release_group'), resolution=guess.get('screen_size'),
video_codec=guess.get('video_codec'), audio_codec=guess.get('audio_codec'),
title=guess.get('episode_title'), year=guess.get('year'))
video_codec=guess.get('video_codec'), audio_codec=guess.get('audio_codec'))
@classmethod
def fromname(cls, name):
+1 -1
View File
@@ -54,7 +54,7 @@ def episodes():
'dallas_s01e03':
Episode('Dallas.S01E03.mkv', 'Dallas', 1, 3),
'dallas_2012_s01e03':
Episode('Dallas.2012.S01E03.mkv', 'Dallas', 1, 3, year=2012),
Episode('Dallas.2012.S01E03.mkv', 'Dallas', 1, 3, year=2012, original_series=False),
'marvels_agents_of_shield_s02e06':
Episode('Marvels.Agents.of.S.H.I.E.L.D.S02E06.720p.HDTV.x264-KILLERS.mkv',
'Marvel\'s Agents of S.H.I.E.L.D.', 2, 6, format='HDTV', release_group='KILLERS', resolution='720p',
+7 -7
View File
@@ -27,7 +27,7 @@ def test_movie_equations():
def test_compute_score(episodes):
video = episodes['bbt_s07e05']
subtitle = Addic7edSubtitle(Language('eng'), True, None, 'the big BANG theory', 6, 4, None, None, '1080p', None)
assert compute_score(subtitle, video) == episode_scores['series']
assert compute_score(subtitle, video) == episode_scores['series'] + episode_scores['year']
def test_get_score_cap(movies):
@@ -43,9 +43,9 @@ def test_compute_score_episode_imdb_id(movies):
subtitle = OpenSubtitlesSubtitle(Language('eng'), True, None, 1, 'hash', 'movie', None,
'Man of Steel', 'man.of.steel.2013.720p.bluray.x264-felony.mkv', 2013, 770828,
None, None, 'utf-8')
assert compute_score(subtitle, video) == sum(movie_scores.get(m, 0)
for m in ('title', 'format', 'imdb_id', 'year', 'video_codec',
'resolution', 'release_group'))
assert compute_score(subtitle, video) == sum(movie_scores.get(m, 0) for m in
('imdb_id', 'title', 'year', 'release_group', 'format', 'resolution',
'video_codec'))
def test_compute_score_episode_title(episodes):
@@ -53,9 +53,9 @@ def test_compute_score_episode_title(episodes):
subtitle = PodnapisiSubtitle(Language('eng'), True, None, 1,
['The.Big.Bang.Theory.S07E05.The.Workplace.Proximity.720p.HDTV.x264-DIMENSION.mkv'],
None, 7, 5, None)
assert compute_score(subtitle, video) == sum(episode_scores.get(m, 0)
for m in ('episode', 'title', 'season', 'format', 'series',
'video_codec', 'resolution', 'release_group'))
assert compute_score(subtitle, video) == sum(episode_scores.get(m, 0) for m in
('series', 'year', 'season', 'episode', 'release_group', 'format',
'resolution', 'video_codec', 'title'))
def test_compute_score_hash_hearing_impaired(movies):
+1 -1
View File
@@ -54,7 +54,7 @@ def test_get_matches_video_codec_resolution(episodes):
def test_get_matches_no_match(episodes):
subtitle = TVsubtitlesSubtitle(Language('por'), None, 261077, 'Game of Thrones', 3, 10, None, '1080p.BluRay',
subtitle = TVsubtitlesSubtitle(Language('por'), None, 261077, 'Game of Thrones', 3, 10, 2011, '1080p.BluRay',
'DEMAND')
matches = subtitle.get_matches(episodes['bbt_s07e05'])
assert matches == set()