tf import dubtiles for movies
This commit is contained in:
@@ -186,7 +186,7 @@ def unmux(ctx,
|
||||
|
||||
if trackDescriptor.getType() == TrackType.SUBTITLE or not subtitles_only:
|
||||
|
||||
# SEASON_EPISODE_STREAM_LANGUAGE_MATCH = '[sS]([0-9]+)[eE]([0-9]+)_([0-9]+)_([a-z]{3})(?:_([A-Z]{3}))*'
|
||||
# SEASON_EPISODE_STREAM_LANGUAGE_DISPOSITIONS_MATCH = '[sS]([0-9]+)[eE]([0-9]+)_([0-9]+)_([a-z]{3})(?:_([A-Z]{3}))*'
|
||||
targetPrefix = f"{targetLabel}{targetIndicator}_{trackDescriptor.getIndex()}_{trackDescriptor.getLanguage().threeLetter()}"
|
||||
|
||||
td: TrackDisposition
|
||||
|
||||
@@ -29,7 +29,9 @@ class MediaDescriptor:
|
||||
#407 remove as well
|
||||
EXCLUDED_MEDIA_TAGS = ["creation_time"]
|
||||
|
||||
SEASON_EPISODE_STREAM_LANGUAGE_MATCH = '[sS]([0-9]+)[eE]([0-9]+)_([0-9]+)_([a-z]{3})(?:_([A-Z]{3}))*'
|
||||
SEASON_EPISODE_STREAM_LANGUAGE_DISPOSITIONS_MATCH = '[sS]([0-9]+)[eE]([0-9]+)_([0-9]+)_([a-z]{3})(?:_([A-Z]{3}))*'
|
||||
STREAM_LANGUAGE_DISPOSITIONS_MATCH = '[sS]([0-9]+)[eE]([0-9]+)_([0-9]+)_([a-z]{3})(?:_([A-Z]{3}))*'
|
||||
|
||||
SUBTITLE_FILE_EXTENSION = 'vtt'
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
@@ -396,27 +398,33 @@ class MediaDescriptor:
|
||||
|
||||
def searchSubtitleFiles(self, searchDirectory, prefix):
|
||||
|
||||
sesl_match = re.compile(MediaDescriptor.SEASON_EPISODE_STREAM_LANGUAGE_MATCH)
|
||||
sesld_match = re.compile(f"{prefix}_{MediaDescriptor.SEASON_EPISODE_STREAM_LANGUAGE_DISPOSITIONS_MATCH}")
|
||||
sld_match = re.compile(f"{prefix}_{MediaDescriptor.STREAM_LANGUAGE_DISPOSITIONS_MATCH}")
|
||||
|
||||
subtitleFileDescriptors = []
|
||||
|
||||
for subtitleFilename in os.listdir(searchDirectory):
|
||||
if subtitleFilename.startswith(prefix) and subtitleFilename.endswith(
|
||||
"." + MediaDescriptor.SUBTITLE_FILE_EXTENSION
|
||||
):
|
||||
sesl_result = sesl_match.search(subtitleFilename)
|
||||
if sesl_result is not None:
|
||||
|
||||
sesld_result = sesld_match.search(subtitleFilename)
|
||||
sld_result = None if not sesld_result is None else sld_match.search(subtitleFilename)
|
||||
|
||||
if not sesld_result is None:
|
||||
|
||||
subtitleFilePath = os.path.join(searchDirectory, subtitleFilename)
|
||||
if os.path.isfile(subtitleFilePath):
|
||||
|
||||
subtitleFileDescriptor = {}
|
||||
subtitleFileDescriptor["path"] = subtitleFilePath
|
||||
subtitleFileDescriptor["season"] = int(sesl_result.group(1))
|
||||
subtitleFileDescriptor["episode"] = int(sesl_result.group(2))
|
||||
subtitleFileDescriptor["index"] = int(sesl_result.group(3))
|
||||
subtitleFileDescriptor["language"] = sesl_result.group(4)
|
||||
subtitleFileDescriptor["season"] = int(sesld_result.group(1))
|
||||
subtitleFileDescriptor["episode"] = int(sesld_result.group(2))
|
||||
subtitleFileDescriptor["index"] = int(sesld_result.group(3))
|
||||
subtitleFileDescriptor["language"] = sesld_result.group(4)
|
||||
|
||||
dispSet = set()
|
||||
dispCaptGroups = sesl_result.groups()
|
||||
dispCaptGroups = sesld_result.groups()
|
||||
numCaptGroups = len(dispCaptGroups)
|
||||
if numCaptGroups > 4:
|
||||
for groupIndex in range(numCaptGroups - 4):
|
||||
@@ -427,6 +435,29 @@ class MediaDescriptor:
|
||||
|
||||
subtitleFileDescriptors.append(subtitleFileDescriptor)
|
||||
|
||||
if not sld_result is None:
|
||||
|
||||
subtitleFilePath = os.path.join(searchDirectory, subtitleFilename)
|
||||
if os.path.isfile(subtitleFilePath):
|
||||
|
||||
subtitleFileDescriptor = {}
|
||||
subtitleFileDescriptor["path"] = subtitleFilePath
|
||||
subtitleFileDescriptor["index"] = int(sld_result.group(1))
|
||||
subtitleFileDescriptor["language"] = sld_result.group(2)
|
||||
|
||||
dispSet = set()
|
||||
dispCaptGroups = sld_result.groups()
|
||||
numCaptGroups = len(dispCaptGroups)
|
||||
if numCaptGroups > 2:
|
||||
for groupIndex in range(numCaptGroups - 2):
|
||||
disp = TrackDisposition.fromIndicator(dispCaptGroups[groupIndex + 2])
|
||||
if disp is not None:
|
||||
dispSet.add(disp)
|
||||
subtitleFileDescriptor["disposition_set"] = dispSet
|
||||
|
||||
subtitleFileDescriptors.append(subtitleFileDescriptor)
|
||||
|
||||
|
||||
self.__logger.debug(f"searchSubtitleFiles(): Available subtitle files {subtitleFileDescriptors}")
|
||||
|
||||
return subtitleFileDescriptors
|
||||
@@ -450,7 +481,8 @@ class MediaDescriptor:
|
||||
[
|
||||
d
|
||||
for d in availableFileSubtitleDescriptors
|
||||
if d["season"] == int(season) and d["episode"] == int(episode)
|
||||
if ((season == -1 and episode == -1)
|
||||
or (d["season"] == int(season) and d["episode"] == int(episode)))
|
||||
],
|
||||
key=lambda d: d["index"],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user