mirror of https://github.com/morpheus65535/bazarr
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
|
@ -739,7 +739,6 @@ def scan_video(path, dont_use_actual_file=False, hints=None, providers=None, ski
|
||||||
|
|
||||||
"""
|
"""
|
||||||
hints = hints or {}
|
hints = hints or {}
|
||||||
video_type = hints.get("type")
|
|
||||||
|
|
||||||
# check for non-existing path
|
# check for non-existing path
|
||||||
if not dont_use_actual_file and not os.path.exists(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)
|
dirpath, filename = os.path.split(path)
|
||||||
logger.info('Determining basic video properties for %r in %r', filename, dirpath)
|
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
|
hints["single_value"] = True
|
||||||
# if "title" in hints:
|
# if "title" in hints:
|
||||||
# hints["expected_title"] = [hints["title"]]
|
# 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))
|
logger.debug('GuessIt found: %s', json.dumps(guessed_result, cls=GuessitEncoder, indent=4, ensure_ascii=False))
|
||||||
video = Video.fromguess(path, guessed_result)
|
video = Video.fromguess(path, guessed_result)
|
||||||
video.hints = hints
|
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"])
|
|
||||||
|
|
||||||
if dont_use_actual_file and not hash_from:
|
if dont_use_actual_file and not hash_from:
|
||||||
return video
|
return video
|
||||||
|
|
|
@ -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 New Issue