mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-22 07:42:32 +00:00
Add 'other' attribute to Video class
This commit is contained in:
parent
118eb09db0
commit
923bcb4382
4 changed files with 82 additions and 9 deletions
|
@ -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"))
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
48
tests/subliminal_patch/test_video.py
Normal file
48
tests/subliminal_patch/test_video.py
Normal file
|
@ -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"
|
Loading…
Reference in a new issue