#398 Default / Forced für unmuxed/imported Streams
This commit is contained in:
@@ -170,7 +170,7 @@ def unmux(ctx,
|
|||||||
|
|
||||||
season = fp.getSeason()
|
season = fp.getSeason()
|
||||||
episode = fp.getEpisode()
|
episode = fp.getEpisode()
|
||||||
|
|
||||||
#TODO: Recognition für alle Formate anpassen
|
#TODO: Recognition für alle Formate anpassen
|
||||||
targetLabel = label if label else fp.getFileBasename()
|
targetLabel = label if label else fp.getFileBasename()
|
||||||
targetIndicator = f"_S{season}E{episode}" if label and season != -1 and episode != -1 else ''
|
targetIndicator = f"_S{season}E{episode}" if label and season != -1 and episode != -1 else ''
|
||||||
@@ -185,9 +185,13 @@ def unmux(ctx,
|
|||||||
|
|
||||||
if trackDescriptor.getType() == TrackType.SUBTITLE or not subtitles_only:
|
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})'
|
# SEASON_EPISODE_STREAM_LANGUAGE_MATCH = '[sS]([0-9]+)[eE]([0-9]+)_([0-9]+)_([a-z]{3})(?:_([A-Z]{3}))*'
|
||||||
targetPrefix = f"{targetLabel}{targetIndicator}_{trackDescriptor.getIndex()}_{trackDescriptor.getLanguage().threeLetter()}"
|
targetPrefix = f"{targetLabel}{targetIndicator}_{trackDescriptor.getIndex()}_{trackDescriptor.getLanguage().threeLetter()}"
|
||||||
|
|
||||||
|
td: TrackDisposition
|
||||||
|
for td in sorted(trackDescriptor.getDispositionSet(), key=lambda d: d.index()):
|
||||||
|
targetPrefix += f"_{td.indicator()}"
|
||||||
|
|
||||||
unmuxSequence = getUnmuxSequence(trackDescriptor, sourcePath, targetPrefix, targetDirectory = output_directory)
|
unmuxSequence = getUnmuxSequence(trackDescriptor, sourcePath, targetPrefix, targetDirectory = output_directory)
|
||||||
|
|
||||||
if unmuxSequence:
|
if unmuxSequence:
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class MediaDescriptor:
|
|||||||
#407 remove as well
|
#407 remove as well
|
||||||
EXCLUDED_MEDIA_TAGS = ["creation_time"]
|
EXCLUDED_MEDIA_TAGS = ["creation_time"]
|
||||||
|
|
||||||
SEASON_EPISODE_STREAM_LANGUAGE_MATCH = '[sS]([0-9]+)[eE]([0-9]+)_([0-9]+)_([a-z]{3})'
|
SEASON_EPISODE_STREAM_LANGUAGE_MATCH = '[sS]([0-9]+)[eE]([0-9]+)_([0-9]+)_([a-z]{3})(?:_([A-Z]{3}))*'
|
||||||
SUBTITLE_FILE_EXTENSION = 'vtt'
|
SUBTITLE_FILE_EXTENSION = 'vtt'
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
@@ -404,7 +404,7 @@ class MediaDescriptor:
|
|||||||
if importedFilePath:
|
if importedFilePath:
|
||||||
|
|
||||||
self.__logger.info(f"Substituting subtitle stream #{td.getIndex()} "
|
self.__logger.info(f"Substituting subtitle stream #{td.getIndex()} "
|
||||||
+ f"({td.getType().label()}:{td.getSubIndex()})"
|
+ f"({td.getType().label()}:{td.getSubIndex()}) "
|
||||||
+ f"with import from file {td.getExternalSourceFilePath()}")
|
+ f"with import from file {td.getExternalSourceFilePath()}")
|
||||||
|
|
||||||
importFileTokens += [
|
importFileTokens += [
|
||||||
@@ -483,6 +483,16 @@ class MediaDescriptor:
|
|||||||
subtitleFileDescriptor["index"] = int(sesl_result.group(3))
|
subtitleFileDescriptor["index"] = int(sesl_result.group(3))
|
||||||
subtitleFileDescriptor["language"] = sesl_result.group(4)
|
subtitleFileDescriptor["language"] = sesl_result.group(4)
|
||||||
|
|
||||||
|
dispSet = set()
|
||||||
|
dispCaptGroups = sesl_result.groups()
|
||||||
|
numCaptGroups = len(dispCaptGroups)
|
||||||
|
if numCaptGroups > 4:
|
||||||
|
for groupIndex in range(numCaptGroups - 4):
|
||||||
|
disp = TrackDisposition.fromIndicator(dispCaptGroups[groupIndex + 4])
|
||||||
|
if disp is not None:
|
||||||
|
dispSet.add(disp)
|
||||||
|
subtitleFileDescriptor["disposition_set"] = dispSet
|
||||||
|
|
||||||
subtitleFileDescriptors.append(subtitleFileDescriptor)
|
subtitleFileDescriptors.append(subtitleFileDescriptor)
|
||||||
|
|
||||||
self.__logger.debug(f"searchSubtitleFiles(): Available subtitle files {subtitleFileDescriptors}")
|
self.__logger.debug(f"searchSubtitleFiles(): Available subtitle files {subtitleFileDescriptors}")
|
||||||
@@ -525,6 +535,9 @@ class MediaDescriptor:
|
|||||||
self.__logger.debug(f"importSubtitles(): Found matching subtitle file {msfd['path']}")
|
self.__logger.debug(f"importSubtitles(): Found matching subtitle file {msfd['path']}")
|
||||||
matchingSubtitleTrackDescriptor[0].setExternalSourceFilePath(msfd["path"])
|
matchingSubtitleTrackDescriptor[0].setExternalSourceFilePath(msfd["path"])
|
||||||
|
|
||||||
|
# TODO: Check if useful
|
||||||
|
# matchingSubtitleTrackDescriptor[0].setDispositionSet(msfd["disposition_set"])
|
||||||
|
|
||||||
|
|
||||||
def getConfiguration(self, label: str = ''):
|
def getConfiguration(self, label: str = ''):
|
||||||
yield f"--- {label if label else 'MediaDescriptor '+str(id(self))} {' '.join([str(k)+'='+str(v) for k,v in self.__mediaTags.items()])}"
|
yield f"--- {label if label else 'MediaDescriptor '+str(id(self))} {' '.join([str(k)+'='+str(v) for k,v in self.__mediaTags.items()])}"
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class TrackCodec(Enum):
|
|||||||
|
|
||||||
def extension(self):
|
def extension(self):
|
||||||
"""Returns the corresponding extension"""
|
"""Returns the corresponding extension"""
|
||||||
return int(self.value['extension'])
|
return str(self.value['extension'])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def identify(identifier: str):
|
def identify(identifier: str):
|
||||||
|
|||||||
@@ -309,6 +309,9 @@ class TrackDescriptor:
|
|||||||
def getDispositionSet(self):
|
def getDispositionSet(self):
|
||||||
return self.__dispositionSet
|
return self.__dispositionSet
|
||||||
|
|
||||||
|
def setDispositionSet(self, dispositionSet: set):
|
||||||
|
self.__dispositionSet = dispositionSet
|
||||||
|
|
||||||
def getDispositionFlag(self, disposition: TrackDisposition) -> bool:
|
def getDispositionFlag(self, disposition: TrackDisposition) -> bool:
|
||||||
return bool(disposition in self.__dispositionSet)
|
return bool(disposition in self.__dispositionSet)
|
||||||
|
|
||||||
|
|||||||
@@ -66,3 +66,11 @@ class TrackDisposition(Enum):
|
|||||||
return matchingDispositions[0]
|
return matchingDispositions[0]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def fromIndicator(indicator: str):
|
||||||
|
matchingDispositions = [d for d in TrackDisposition if d.indicator() == str(indicator)]
|
||||||
|
if matchingDispositions:
|
||||||
|
return matchingDispositions[0]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user