diff options
author | Vitiko <[email protected]> | 2022-11-19 16:38:37 -0400 |
---|---|---|
committer | Vitiko <[email protected]> | 2022-11-19 16:38:37 -0400 |
commit | 923bcb438298beef7cf4e620e6611a07c51ebcbc (patch) | |
tree | 6080b97bd0908e3c725648285d40c6f72c0faaf8 | |
parent | 118eb09db03f54cd371983653530d2c2c26da83e (diff) | |
download | bazarr-1.1.3-beta.21.tar.gz bazarr-1.1.3-beta.21.zip |
Add 'other' attribute to Video classv1.1.3-beta.21
-rw-r--r-- | libs/subliminal/video.py | 4 | ||||
-rw-r--r-- | libs/subliminal_patch/subtitle.py | 2 | ||||
-rw-r--r-- | libs/subliminal_patch/video.py | 37 | ||||
-rw-r--r-- | tests/subliminal_patch/test_video.py | 48 |
4 files changed, 82 insertions, 9 deletions
diff --git a/libs/subliminal/video.py b/libs/subliminal/video.py index 546861249..1264d0b84 100644 --- a/libs/subliminal/video.py +++ b/libs/subliminal/video.py @@ -183,7 +183,7 @@ class Episode(Video): year=guess.get('year'), source=guess.get('source'), 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'), - streaming_service=guess.get("streaming_service"), + streaming_service=guess.get("streaming_service"), other=guess.get("other"), edition=guess.get("edition", guess.get("alternative_title"))) @classmethod @@ -233,7 +233,7 @@ class Movie(Video): alternative_titles.append(u"%s %s" % (guess['title'], guess['alternative_title'])) return cls(name, guess.get('title', 'Unknown Title'), source=guess.get('source'), release_group=guess.get('release_group'), - resolution=guess.get('screen_size'), video_codec=guess.get('video_codec'), + resolution=guess.get('screen_size'), video_codec=guess.get('video_codec'), other=guess.get("other"), audio_codec=guess.get('audio_codec'), year=guess.get('year'), alternative_titles=alternative_titles, streaming_service=guess.get("streaming_service"), edition=guess.get("edition")) diff --git a/libs/subliminal_patch/subtitle.py b/libs/subliminal_patch/subtitle.py index 158d399f5..e3f49e852 100644 --- a/libs/subliminal_patch/subtitle.py +++ b/libs/subliminal_patch/subtitle.py @@ -548,7 +548,7 @@ def guess_matches(video, guess, partial=False): if _has_match(video, guess, key): matches.add(key) - for key in ("streaming_service", "edition"): + for key in ("streaming_service", "edition", "other"): if _check_optional(video, guess, key): matches.add(key) diff --git a/libs/subliminal_patch/video.py b/libs/subliminal_patch/video.py index b58c452be..244e5ea36 100644 --- a/libs/subliminal_patch/video.py +++ b/libs/subliminal_patch/video.py @@ -15,12 +15,36 @@ class Video(Video_): audio_languages = None external_subtitle_languages = None - def __init__(self, name, source=None, release_group=None, resolution=None, video_codec=None, audio_codec=None, - imdb_id=None, hashes=None, size=None, subtitle_languages=None, audio_languages=None, - streaming_service=None, edition=None): - super(Video, self).__init__(name, source=source, release_group=release_group, resolution=resolution, - video_codec=video_codec, audio_codec=audio_codec, imdb_id=imdb_id, hashes=hashes, - size=size, subtitle_languages=subtitle_languages) + def __init__( + self, + name, + source=None, + release_group=None, + resolution=None, + video_codec=None, + audio_codec=None, + imdb_id=None, + hashes=None, + size=None, + subtitle_languages=None, + audio_languages=None, + streaming_service=None, + edition=None, + other=None, + **kwargs + ): + super(Video, self).__init__( + name, + source=source, + release_group=release_group, + resolution=resolution, + video_codec=video_codec, + audio_codec=audio_codec, + imdb_id=imdb_id, + hashes=hashes, + size=size, + subtitle_languages=subtitle_languages, + ) self.original_name = os.path.basename(name) self.plexapi_metadata = {} self.hints = {} @@ -29,3 +53,4 @@ class Video(Video_): self.streaming_service = streaming_service self.edition = edition self.original_path = name + self.other = other diff --git a/tests/subliminal_patch/test_video.py b/tests/subliminal_patch/test_video.py new file mode 100644 index 000000000..44f63957a --- /dev/null +++ b/tests/subliminal_patch/test_video.py @@ -0,0 +1,48 @@ +from subliminal import Episode, Movie +from subliminal_patch.video import Video + + +def test_video_fromguess_episode(): + video = Video.fromguess( + "Breaking.Bad.S01E01.Bluray.mkv", + {"type": "episode", "streaming_service": "foo", "random_key": "bar"}, + ) + assert video.streaming_service == "foo" + assert video.other is None + assert isinstance(video, Episode) + + +def test_video_fromguess_movie(): + video = Video.fromguess( + "Taxi.Driver.1976.Bluray.mkv", + {"type": "movie", "edition": "foo", "random_key": "bar", "other": "Proper"}, + ) + assert video.edition == "foo" + assert video.other == "Proper" + assert isinstance(video, Movie) + + +def test_video_fromname_episode(): + video = Video.fromname("Breaking.Bad.S01E01.NF.WEB-DL.1080p.x264-FOO.mkv") + + assert video.series == "Breaking Bad" + assert video.title is None + assert video.season == 1 + assert video.episode == 1 + assert video.source == "Web" + assert video.streaming_service == "Netflix" + assert video.resolution == "1080p" + assert video.video_codec == "H.264" + assert video.release_group == "FOO" + + +def test_video_fromname_movie(): + video = Video.fromname("Some.Flick.2022.UHD.Bluray.Proper.2160p.FLAC.HEVC-FOO.mkv") + + assert video.source == "Ultra HD Blu-ray" + assert video.title == "Some Flick" + assert video.year == 2022 + assert video.other == "Proper" + assert video.resolution == "2160p" + assert video.video_codec == "H.265" + assert video.audio_codec == "FLAC" |