Merge remote-tracking branch 'origin/development' into development

pull/2550/head v1.4.4-beta.10
morpheus65535 5 months ago
commit 2f1e3645b0

@ -121,7 +121,9 @@ def subtitles_sync_references(subtitles_path, sonarr_episode_id=None, radarr_mov
if not media_data:
return references_dict
data = parse_video_metadata(media_data.path, media_data.file_size, media_data.episode_file_id, None,
mapped_path = path_mappings.path_replace(media_data.path)
data = parse_video_metadata(mapped_path, media_data.file_size, media_data.episode_file_id, None,
use_cache=True)
elif radarr_movie_id:
media_data = database.execute(
@ -132,7 +134,9 @@ def subtitles_sync_references(subtitles_path, sonarr_episode_id=None, radarr_mov
if not media_data:
return references_dict
data = parse_video_metadata(media_data.path, media_data.file_size, None, media_data.movie_file_id,
mapped_path = path_mappings.path_replace_movie(media_data.path)
data = parse_video_metadata(mapped_path, media_data.file_size, None, media_data.movie_file_id,
use_cache=True)
if not data:

@ -325,9 +325,9 @@ class LegendasdivxProvider(Provider):
search_url = _searchurl.format(
query=querytext,
season=video.season,
episode=video.episode,
imdbid=video.series_imdb_id.replace('tt', '') if video.series_imdb_id else None,
season='' if isinstance(video, Movie) else video.season,
episode='' if isinstance(video, Movie) else video.episode,
imdbid='' if isinstance(video, Movie) else video.series_imdb_id.replace('tt', '') if video.series_imdb_id else None,
op=op,
d_op=d_op,
)

@ -62,7 +62,7 @@ class Subtitle(Subtitle_):
_guessed_encoding = None
_is_valid = False
use_original_format = False
format = "srt" # default format is srt
# format = "srt" # default format is srt
def __init__(self, language, hearing_impaired=False, page_link=None, encoding=None, mods=None, original_format=False):
# set subtitle language to hi if it's hearing_impaired
@ -74,6 +74,21 @@ class Subtitle(Subtitle_):
self.mods = mods
self._is_valid = False
self.use_original_format = original_format
self._og_format = None
@property
def format(self):
if self.use_original_format and self._og_format is not None:
logger.debug("Original format requested [%s]", self._og_format)
return self._og_format
logger.debug("Will assume srt format")
return "srt"
# Compatibility
@format.setter
def format(self, val):
self._og_format = val
def __repr__(self):
r_info = str(self.release_info or "").replace("\n", " | ").strip()
@ -292,10 +307,12 @@ class Subtitle(Subtitle_):
logger.info("Got FPS from MicroDVD subtitle: %s", subs.fps)
else:
logger.info("Got format: %s", subs.format)
if self.use_original_format:
self.format = subs.format
self._og_format = subs.format
self._is_valid = True
logger.debug("Using original format")
# if self.use_original_format:
# self.format = subs.format
# self._is_valid = True
# logger.debug("Using original format")
return True
except pysubs2.UnknownFPSError:

@ -8,9 +8,9 @@ from fese.exceptions import LanguageNotFound
import pytest
from subliminal_patch.core import Episode
from subliminal_patch.core import Movie
from subliminal_patch.providers.embeddedsubtitles import _clean_ass_subtitles
from subliminal_patch.providers.embeddedsubtitles import (
_discard_possible_incomplete_subtitles,
_clean_ass_subtitles,
)
from subliminal_patch.providers.embeddedsubtitles import _get_pretty_release_name
from subliminal_patch.providers.embeddedsubtitles import _MemoizedFFprobeVideoContainer
@ -127,7 +127,9 @@ def fake_streams():
@pytest.mark.parametrize("tags_", [{}, {"language": "und", "title": "Unknown"}])
def test_list_subtitles_unknown_as_fallback(mocker, tags_, video_single_language):
with EmbeddedSubtitlesProvider(unknown_as_fallback=True, fallback_lang="en") as provider:
with EmbeddedSubtitlesProvider(
unknown_as_fallback=True, fallback_lang="en"
) as provider:
fake = FFprobeSubtitleStream(
{"index": 3, "codec_name": "subrip", "tags": tags_}
)
@ -144,7 +146,9 @@ def test_list_subtitles_unknown_as_fallback(mocker, tags_, video_single_language
def test_list_subtitles_unknown_as_fallback_w_real_english_subtitles(
video_single_language, mocker
):
with EmbeddedSubtitlesProvider(unknown_as_fallback=True, fallback_lang="en") as provider:
with EmbeddedSubtitlesProvider(
unknown_as_fallback=True, fallback_lang="en"
) as provider:
fakes = [
FFprobeSubtitleStream(
{"index": 3, "codec_name": "subrip", "tags": {"language": "und"}}
@ -165,7 +169,7 @@ def test_list_subtitles_unknown_as_fallback_w_real_english_subtitles(
@pytest.mark.parametrize("tags_", [{}, {"language": "und", "title": "Unknown"}])
def test_list_subtitles_unknown_as_fallback_disabled(tags_):
with EmbeddedSubtitlesProvider(unknown_as_fallback=False,fallback_lang="en"):
with EmbeddedSubtitlesProvider(unknown_as_fallback=False, fallback_lang="en"):
with pytest.raises(LanguageNotFound):
assert FFprobeSubtitleStream(
{"index": 3, "codec_name": "subrip", "tags": tags_}
@ -362,6 +366,21 @@ def test_download_subtitle_single(video_single_language):
assert subtitle.is_valid()
def test_download_subtitle_single_is_ass(video_single_language):
with EmbeddedSubtitlesProvider() as provider:
subtitle = provider.list_subtitles(
video_single_language, {Language.fromalpha2("en")}
)[0]
provider.download_subtitle(subtitle)
assert subtitle.is_valid()
assert subtitle.format == "srt"
subtitle.use_original_format = True
assert subtitle.format == "ass"
def test_memoized(video_single_language, mocker):
with EmbeddedSubtitlesProvider() as provider:
provider.list_subtitles(video_single_language, {Language.fromalpha2("en")})

Loading…
Cancel
Save