|
|
@ -40,7 +40,7 @@ class EmbeddedSubtitle(Subtitle):
|
|
|
|
self.container: FFprobeVideoContainer = container
|
|
|
|
self.container: FFprobeVideoContainer = container
|
|
|
|
self.forced = stream.disposition.forced
|
|
|
|
self.forced = stream.disposition.forced
|
|
|
|
self.page_link = self.container.path
|
|
|
|
self.page_link = self.container.path
|
|
|
|
self.release_info = os.path.basename(self.page_link)
|
|
|
|
self.release_info = _get_pretty_release_name(stream, container)
|
|
|
|
self.media_type = media_type
|
|
|
|
self.media_type = media_type
|
|
|
|
|
|
|
|
|
|
|
|
self._matches: set = matches
|
|
|
|
self._matches: set = matches
|
|
|
@ -117,6 +117,8 @@ class EmbeddedSubtitlesProvider(Provider):
|
|
|
|
self._blacklist.add(path)
|
|
|
|
self._blacklist.add(path)
|
|
|
|
streams = []
|
|
|
|
streams = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
streams = _discard_possible_incomplete_subtitles(list(streams))
|
|
|
|
|
|
|
|
|
|
|
|
if not streams:
|
|
|
|
if not streams:
|
|
|
|
logger.debug("No subtitles found for container: %s", video)
|
|
|
|
logger.debug("No subtitles found for container: %s", video)
|
|
|
|
|
|
|
|
|
|
|
@ -260,6 +262,39 @@ def _check_hi_fallback(streams, languages):
|
|
|
|
logger.debug("HI fallback not needed: %s", compatible_streams)
|
|
|
|
logger.debug("HI fallback not needed: %s", compatible_streams)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _discard_possible_incomplete_subtitles(streams):
|
|
|
|
|
|
|
|
"""Check number_of_frames attributes from subtitle streams in order to find
|
|
|
|
|
|
|
|
supposedly incomplete subtitles"""
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
max_frames = max(stream.number_of_frames for stream in streams)
|
|
|
|
|
|
|
|
except ValueError:
|
|
|
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Blatantly assume there's nothing to discard as some ffprobe streams don't
|
|
|
|
|
|
|
|
# have number_of_frames tags
|
|
|
|
|
|
|
|
if not max_frames:
|
|
|
|
|
|
|
|
return streams
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.debug("Checking possible incomplete subtitles (max frames: %d)", max_frames)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
valid_streams = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for stream in streams:
|
|
|
|
|
|
|
|
# 500 < 1200
|
|
|
|
|
|
|
|
if stream.number_of_frames < max_frames // 2:
|
|
|
|
|
|
|
|
logger.debug(
|
|
|
|
|
|
|
|
"Possible bad subtitle found: %s (%s frames - %s frames)",
|
|
|
|
|
|
|
|
stream,
|
|
|
|
|
|
|
|
stream.number_of_frames,
|
|
|
|
|
|
|
|
max_frames,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
valid_streams.append(stream)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return valid_streams
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _is_fuse_rclone_mount(path: str):
|
|
|
|
def _is_fuse_rclone_mount(path: str):
|
|
|
|
# Experimental!
|
|
|
|
# Experimental!
|
|
|
|
|
|
|
|
|
|
|
@ -272,3 +307,8 @@ def _is_fuse_rclone_mount(path: str):
|
|
|
|
# https://forum.rclone.org/t/fuse-inode-number-aufs/215/5
|
|
|
|
# https://forum.rclone.org/t/fuse-inode-number-aufs/215/5
|
|
|
|
# https://pkg.go.dev/bazil.org/fuse/fs?utm_source=godoc#GenerateDynamicInode
|
|
|
|
# https://pkg.go.dev/bazil.org/fuse/fs?utm_source=godoc#GenerateDynamicInode
|
|
|
|
return len(str(os.stat(path).st_ino)) > 18
|
|
|
|
return len(str(os.stat(path).st_ino)) > 18
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_pretty_release_name(stream, container):
|
|
|
|
|
|
|
|
bname = os.path.basename(container.path)
|
|
|
|
|
|
|
|
return f"{os.path.splitext(bname)[0]}.{stream.suffix}"
|
|
|
|