hf fix tmdb filename filters
This commit is contained in:
@@ -653,7 +653,7 @@ def convert(ctx,
|
||||
ctx.obj['logger'].debug(f"tmdbEpisodeResult={tmdbEpisodeResult}")
|
||||
|
||||
if tmdbEpisodeResult:
|
||||
substitutedEpisodeName = substituteTmdbFilename(filterFilename(tmdbEpisodeResult['name']))
|
||||
substitutedEpisodeName = filterFilename(substituteTmdbFilename(tmdbEpisodeResult['name']))
|
||||
sourceFileBasename = getEpisodeFileBasename(showFilenamePrefix,
|
||||
substitutedEpisodeName,
|
||||
shiftedShowSeason,
|
||||
|
||||
@@ -78,6 +78,7 @@ def filterFilename(fileName: str) -> str:
|
||||
"""This filter replaces charactes from TMDB responses with characters
|
||||
less problemating when using in filenames or removes them"""
|
||||
|
||||
fileName = str(fileName).replace('/', '-')
|
||||
fileName = str(fileName).replace(':', ';')
|
||||
fileName = str(fileName).replace('*', '')
|
||||
fileName = str(fileName).replace("'", '')
|
||||
@@ -86,17 +87,20 @@ def filterFilename(fileName: str) -> str:
|
||||
return fileName.strip()
|
||||
|
||||
def substituteTmdbFilename(fileName: str) -> str:
|
||||
"""If chaining this method with filterFilename use this one first as the latter will destroy some patterns"""
|
||||
|
||||
# This appears in TMDB episode names
|
||||
# This indicates filler episodes in TMDB episode names
|
||||
fileName = str(fileName).replace(' (*)', '')
|
||||
fileName = str(fileName).replace('(*)', '')
|
||||
|
||||
# This indicates the index of multi-episode files
|
||||
episodePartMatch = re.search("\\(([0-9]+)\\)$", fileName)
|
||||
if episodePartMatch is not None:
|
||||
partSuffix = str(episodePartMatch.group(0))
|
||||
partIndex = episodePartMatch.groups()[0]
|
||||
fileName = str(fileName).replace(partSuffix, f"Teil {partIndex}")
|
||||
|
||||
# Also multi-episodes with first and last episode index
|
||||
episodePartMatch = re.search("\\(([0-9]+)[-\\/]([0-9]+)\\)$", fileName)
|
||||
if episodePartMatch is not None:
|
||||
partSuffix = str(episodePartMatch.group(0))
|
||||
|
||||
Reference in New Issue
Block a user