mirror of
https://github.com/morpheus65535/bazarr
synced 2025-02-13 09:45:26 +00:00
Avoid error trying to scan some videos
This removes unused code from subliminal_patch's core. Thanks to refining, we don't need extra magic to guess from filenames anymore.
This commit is contained in:
parent
26082780d5
commit
09d1eb78c9
2 changed files with 21 additions and 30 deletions
|
@ -739,7 +739,6 @@ def scan_video(path, dont_use_actual_file=False, hints=None, providers=None, ski
|
|||
|
||||
"""
|
||||
hints = hints or {}
|
||||
video_type = hints.get("type")
|
||||
|
||||
# check for non-existing path
|
||||
if not dont_use_actual_file and not os.path.exists(path):
|
||||
|
@ -752,42 +751,15 @@ def scan_video(path, dont_use_actual_file=False, hints=None, providers=None, ski
|
|||
dirpath, filename = os.path.split(path)
|
||||
logger.info('Determining basic video properties for %r in %r', filename, dirpath)
|
||||
|
||||
# hint guessit the filename itself and its 2 parent directories if we're an episode (most likely
|
||||
# Series name/Season/filename), else only one
|
||||
split_path = os.path.normpath(path).split(os.path.sep)[-3 if video_type == "episode" else -2:]
|
||||
|
||||
# remove crap from folder names
|
||||
if video_type == "episode":
|
||||
if len(split_path) > 2:
|
||||
split_path[-3] = remove_crap_from_fn(split_path[-3])
|
||||
else:
|
||||
if len(split_path) > 1:
|
||||
split_path[-2] = remove_crap_from_fn(split_path[-2])
|
||||
|
||||
guess_from = os.path.join(*split_path)
|
||||
|
||||
# remove crap from file name
|
||||
guess_from = remove_crap_from_fn(guess_from)
|
||||
|
||||
# guess
|
||||
hints["single_value"] = True
|
||||
# if "title" in hints:
|
||||
# hints["expected_title"] = [hints["title"]]
|
||||
|
||||
guessed_result = guessit(guess_from, options=hints)
|
||||
guessed_result = guessit(path, options=hints)
|
||||
|
||||
logger.debug('GuessIt found: %s', json.dumps(guessed_result, cls=GuessitEncoder, indent=4, ensure_ascii=False))
|
||||
video = Video.fromguess(path, guessed_result)
|
||||
video.hints = hints
|
||||
|
||||
# get possibly alternative title from the filename itself
|
||||
alt_guess = guessit(filename, options=hints)
|
||||
if "title" in alt_guess and alt_guess["title"] != guessed_result["title"]:
|
||||
if video_type == "episode":
|
||||
video.alternative_series.append(alt_guess["title"])
|
||||
else:
|
||||
video.alternative_titles.append(alt_guess["title"])
|
||||
logger.debug("Adding alternative title: %s", alt_guess["title"])
|
||||
video.hints = hints # ?
|
||||
|
||||
if dont_use_actual_file and not hash_from:
|
||||
return video
|
||||
|
|
19
tests/subliminal_patch/test_core.py
Normal file
19
tests/subliminal_patch/test_core.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from pathlib import Path
|
||||
|
||||
from subliminal_patch import core
|
||||
|
||||
|
||||
def test_scan_video_movie(tmpdir):
|
||||
video_path = Path(tmpdir, "Taxi Driver 1976 Bluray 720p x264.mkv")
|
||||
video_path.touch()
|
||||
|
||||
result = core.scan_video(str(video_path))
|
||||
assert isinstance(result, core.Movie)
|
||||
|
||||
|
||||
def test_scan_video_episode(tmpdir):
|
||||
video_path = Path(tmpdir, "The Wire S01E01 Bluray 720p x264.mkv")
|
||||
video_path.touch()
|
||||
|
||||
result = core.scan_video(str(video_path))
|
||||
assert isinstance(result, core.Episode)
|
Loading…
Reference in a new issue