diff options
author | vitiko98 <[email protected]> | 2022-08-29 20:50:50 -0400 |
---|---|---|
committer | vitiko98 <[email protected]> | 2022-08-29 20:50:50 -0400 |
commit | 09d1eb78c95d2a1bee85f8e17cd9877149e26afb (patch) | |
tree | 223f7fe4dcd5fb995082ef8019f460ad7b71f834 | |
parent | 26082780d579bd1ffdca0e8c4bef393966db982c (diff) | |
download | bazarr-09d1eb78c95d2a1bee85f8e17cd9877149e26afb.tar.gz bazarr-09d1eb78c95d2a1bee85f8e17cd9877149e26afb.zip |
Avoid error trying to scan some videosv1.1.1-beta.20
This removes unused code from subliminal_patch's core. Thanks to
refining, we don't need extra magic to guess from filenames anymore.
-rw-r--r-- | libs/subliminal_patch/core.py | 32 | ||||
-rw-r--r-- | tests/subliminal_patch/test_core.py | 19 |
2 files changed, 21 insertions, 30 deletions
diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py index d8c327f46..88b16db1f 100644 --- a/libs/subliminal_patch/core.py +++ b/libs/subliminal_patch/core.py @@ -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 diff --git a/tests/subliminal_patch/test_core.py b/tests/subliminal_patch/test_core.py new file mode 100644 index 000000000..17451ccdf --- /dev/null +++ b/tests/subliminal_patch/test_core.py @@ -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) |