imp #400 import subtitle output #397 unmuxing output

main
Maveno 11 months ago
parent 4716c4d11c
commit e2b6a4bf7c

@ -121,19 +121,26 @@ def getUnmuxSequence(trackDescriptor: TrackDescriptor, sourcePath, targetPrefix,
if not trackCodec in CODEC_LOOKUP_TABLE.keys(): if not trackCodec in CODEC_LOOKUP_TABLE.keys():
return [] return []
# executable and input file
commandTokens = FfxController.COMMAND_TOKENS + ['-i', sourcePath] commandTokens = FfxController.COMMAND_TOKENS + ['-i', sourcePath]
trackType = trackDescriptor.getType() trackType = trackDescriptor.getType()
targetPathBase = os.path.join(targetDirectory, targetPrefix) if targetDirectory else targetPrefix targetPathBase = os.path.join(targetDirectory, targetPrefix) if targetDirectory else targetPrefix
# mapping
commandTokens += ['-map', commandTokens += ['-map',
f"0:{trackType.indicator()}:{trackDescriptor.getSubIndex()}", f"0:{trackType.indicator()}:{trackDescriptor.getSubIndex()}",
'-c', '-c',
'copy'] 'copy']
# TODO #425: Codec Enum
# output format
if 'format' in CODEC_LOOKUP_TABLE[trackCodec].keys(): if 'format' in CODEC_LOOKUP_TABLE[trackCodec].keys():
commandTokens += ['-f', CODEC_LOOKUP_TABLE[trackCodec]['format']] commandTokens += ['-f', CODEC_LOOKUP_TABLE[trackCodec]['format']]
# TODO #425: Codec enum
# output filename
commandTokens += [f"{targetPathBase}.{CODEC_LOOKUP_TABLE[trackCodec]['extension']}"] commandTokens += [f"{targetPathBase}.{CODEC_LOOKUP_TABLE[trackCodec]['extension']}"]
return commandTokens return commandTokens
@ -182,7 +189,7 @@ def unmux(ctx,
ctx.obj['logger'].warning(f"Skipping file {fp.getFilename()}: Label set but no indicator recognized") ctx.obj['logger'].warning(f"Skipping file {fp.getFilename()}: Label set but no indicator recognized")
continue continue
else: else:
ctx.obj['logger'].debug(f"\nUnmuxing file {fp.getFilename()}\n") ctx.obj['logger'].info(f"\nUnmuxing file {fp.getFilename()}\n")
for trackDescriptor in sourceMediaDescriptor.getAllTrackDescriptors(): for trackDescriptor in sourceMediaDescriptor.getAllTrackDescriptors():
@ -195,7 +202,12 @@ def unmux(ctx,
if unmuxSequence: if unmuxSequence:
if not ctx.obj['dry_run']: if not ctx.obj['dry_run']:
#TODO #425: Codec Enum
ctx.obj['logger'].info(f"Unmuxing stream {trackDescriptor.getIndex()} into file {targetPrefix}.{CODEC_LOOKUP_TABLE[trackDescriptor.getCodec()]['extension']}")
ctx.obj['logger'].debug(f"Executing unmuxing sequence") ctx.obj['logger'].debug(f"Executing unmuxing sequence")
out, err, rc = executeProcess(unmuxSequence, context = ctx.obj) out, err, rc = executeProcess(unmuxSequence, context = ctx.obj)
if rc: if rc:
ctx.obj['logger'].error(f"Unmuxing of stream {trackDescriptor.getIndex()} failed with error ({rc}) {err}") ctx.obj['logger'].error(f"Unmuxing of stream {trackDescriptor.getIndex()} failed with error ({rc}) {err}")
@ -552,21 +564,14 @@ def convert(ctx,
#HINT: -1 if not set #HINT: -1 if not set
if 'tmdb' in cliOverrides.keys() and 'season' in cliOverrides['tmdb']: if 'tmdb' in cliOverrides.keys() and 'season' in cliOverrides['tmdb']:
sSeason = cliOverrides['tmdb']['season'] showSeason = cliOverrides['tmdb']['season']
else: else:
sSeason = mediaFileProperties.getSeason() showSeason = mediaFileProperties.getSeason()
if 'tmdb' in cliOverrides.keys() and 'episode' in cliOverrides['tmdb']: if 'tmdb' in cliOverrides.keys() and 'episode' in cliOverrides['tmdb']:
sEpisode = cliOverrides['tmdb']['episode'] showEpisode = cliOverrides['tmdb']['episode']
else:
sEpisode = mediaFileProperties.getEpisode()
if 'tmdb' not in cliOverrides.keys() and showId != -1:
showSeason, showEpisode = ssc.shiftSeason(showId, season=sSeason, episode=sEpisode)
else: else:
showSeason = sSeason showEpisode = mediaFileProperties.getEpisode()
showEpisode = sEpisode
ctx.obj['logger'].debug(f"Season={showSeason} Episode={showEpisode}") ctx.obj['logger'].debug(f"Season={showSeason} Episode={showEpisode}")
@ -624,13 +629,23 @@ def convert(ctx,
indicatorEpisodeDigits = currentShowDescriptor.getIndicatorEpisodeDigits() if not currentPattern is None else ShowDescriptor.DEFAULT_INDICATOR_EPISODE_DIGITS indicatorEpisodeDigits = currentShowDescriptor.getIndicatorEpisodeDigits() if not currentPattern is None else ShowDescriptor.DEFAULT_INDICATOR_EPISODE_DIGITS
# Shift season and episode if defined for this show
if ('tmdb' not in cliOverrides.keys() and showId != -1
and showSeason != -1 and showEpisode != -1):
shiftedShowSeason, shiftedShowEpisode = ssc.shiftSeason(showId,
season=showSeason,
episode=showEpisode)
else:
shiftedShowSeason = showSeason
shiftedShowEpisode = showEpisode
# Assemble target filename accordingly depending on TMDB lookup is enabled # Assemble target filename accordingly depending on TMDB lookup is enabled
#HINT: -1 if not set #HINT: -1 if not set
showId = cliOverrides['tmdb']['show'] if 'tmdb' in cliOverrides.keys() and 'show' in cliOverrides['tmdb'] else (-1 if currentShowDescriptor is None else currentShowDescriptor.getId()) showId = cliOverrides['tmdb']['show'] if 'tmdb' in cliOverrides.keys() and 'show' in cliOverrides['tmdb'] else (-1 if currentShowDescriptor is None else currentShowDescriptor.getId())
if context['use_tmdb'] and showId != -1 and showSeason != -1 and showEpisode != -1: if context['use_tmdb'] and showId != -1 and shiftedShowSeason != -1 and shiftedShowEpisode != -1:
ctx.obj['logger'].debug(f"Querying TMDB for show_id={showId} season={showSeason} episode{showEpisode}") ctx.obj['logger'].debug(f"Querying TMDB for show_id={showId} season={shiftedShowSeason} episode{shiftedShowEpisode}")
if currentPattern is None: if currentPattern is None:
sName, showYear = tc.getShowNameAndYear(showId) sName, showYear = tc.getShowNameAndYear(showId)
@ -639,7 +654,7 @@ def convert(ctx,
else: else:
showFilenamePrefix = currentShowDescriptor.getFilenamePrefix() showFilenamePrefix = currentShowDescriptor.getFilenamePrefix()
tmdbEpisodeResult = tc.queryEpisode(showId, showSeason, showEpisode) tmdbEpisodeResult = tc.queryEpisode(showId, shiftedShowSeason, shiftedShowEpisode)
ctx.obj['logger'].debug(f"tmdbEpisodeResult={tmdbEpisodeResult}") ctx.obj['logger'].debug(f"tmdbEpisodeResult={tmdbEpisodeResult}")
@ -647,19 +662,18 @@ def convert(ctx,
filteredEpisodeName = filterFilename(tmdbEpisodeResult['name']) filteredEpisodeName = filterFilename(tmdbEpisodeResult['name'])
sourceFileBasename = TmdbController.getEpisodeFileBasename(showFilenamePrefix, sourceFileBasename = TmdbController.getEpisodeFileBasename(showFilenamePrefix,
filteredEpisodeName, filteredEpisodeName,
showSeason, shiftedShowSeason,
showEpisode, shiftedShowEpisode,
indexSeasonDigits, indexSeasonDigits,
indexEpisodeDigits, indexEpisodeDigits,
indicatorSeasonDigits, indicatorSeasonDigits,
indicatorEpisodeDigits) indicatorEpisodeDigits)
if label: if label:
if showSeason > -1 and showEpisode > -1: if shiftedShowSeason > -1 and shiftedShowEpisode > -1:
targetSuffices['se'] = f"S{showSeason:0{indicatorSeasonDigits}d}E{showEpisode:0{indicatorEpisodeDigits}d}" targetSuffices['se'] = f"S{shiftedShowSeason:0{indicatorSeasonDigits}d}E{shiftedShowEpisode:0{indicatorEpisodeDigits}d}"
elif showEpisode > -1: elif shiftedShowEpisode > -1:
targetSuffices['se'] = f"E{showEpisode:0{indicatorEpisodeDigits}d}" targetSuffices['se'] = f"E{shiftedShowEpisode:0{indicatorEpisodeDigits}d}"
else: else:
if 'se' in targetSuffices.keys(): if 'se' in targetSuffices.keys():
del targetSuffices['se'] del targetSuffices['se']

@ -394,11 +394,16 @@ class MediaDescriptor:
importFileTokens = [] importFileTokens = []
td: TrackDescriptor
for td in self.__trackDescriptors: for td in self.__trackDescriptors:
importedFilePath = td.getExternalSourceFilePath() importedFilePath = td.getExternalSourceFilePath()
if importedFilePath: if importedFilePath:
self.__logger.info(f"Substituting subtitle stream {td.getSubIndex()} "
+ f"with import from file {td.getExternalSourceFilePath()}")
importFileTokens += [ importFileTokens += [
"-i", "-i",
importedFilePath, importedFilePath,

@ -205,13 +205,19 @@ class ShiftedSeasonController():
def shiftSeason(self, showId, season, episode): def shiftSeason(self, showId, season, episode):
shiftedSeason: ShiftedSeason shiftedSeasonEntry: ShiftedSeason
for shiftedSeason in self.getShiftedSeasonSiblings(showId): for shiftedSeasonEntry in self.getShiftedSeasonSiblings(showId):
if (season == shiftedSeason.getOriginalSeason() if (season == shiftedSeasonEntry.getOriginalSeason()
and (shiftedSeason.getFirstEpisode() == -1 or episode >= shiftedSeason.getFirstEpisode()) and (shiftedSeasonEntry.getFirstEpisode() == -1 or episode >= shiftedSeasonEntry.getFirstEpisode())
and (shiftedSeason.getLastEpisode() == -1 or episode <= shiftedSeason.getLastEpisode())): and (shiftedSeasonEntry.getLastEpisode() == -1 or episode <= shiftedSeasonEntry.getLastEpisode())):
return season + shiftedSeason.getSeasonOffset(), episode + shiftedSeason.getEpisodeOffset() shiftedSeason = season + shiftedSeasonEntry.getSeasonOffset()
shiftedEpisode = episode + shiftedSeasonEntry.getEpisodeOffset()
self.context['logger'].info(f"Shifting season: {season} episode: {episode} "
+f"-> season: {shiftedSeason} episode: {shiftedEpisode}")
return shiftedSeason, shiftedEpisode
return season, episode return season, episode

Loading…
Cancel
Save