|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import logging
|
|
|
|
|
import re, logging
|
|
|
|
|
|
|
|
|
|
from jinja2 import Environment, Undefined
|
|
|
|
|
from .constants import DEFAULT_OUTPUT_FILENAME_TEMPLATE
|
|
|
|
@ -78,10 +78,6 @@ def filterFilename(fileName: str) -> str:
|
|
|
|
|
"""This filter replaces charactes from TMDB responses with characters
|
|
|
|
|
less problemating when using in filenames or removes them"""
|
|
|
|
|
|
|
|
|
|
# This appears in TMDB episode names
|
|
|
|
|
fileName = str(fileName).replace(' (*)', '')
|
|
|
|
|
fileName = str(fileName).replace('(*)', '')
|
|
|
|
|
|
|
|
|
|
fileName = str(fileName).replace(':', ';')
|
|
|
|
|
fileName = str(fileName).replace('*', '')
|
|
|
|
|
fileName = str(fileName).replace("'", '')
|
|
|
|
@ -89,6 +85,27 @@ def filterFilename(fileName: str) -> str:
|
|
|
|
|
|
|
|
|
|
return fileName.strip()
|
|
|
|
|
|
|
|
|
|
def substituteTmdbFilename(fileName: str) -> str:
|
|
|
|
|
|
|
|
|
|
# This appears in TMDB episode names
|
|
|
|
|
fileName = str(fileName).replace(' (*)', '')
|
|
|
|
|
fileName = str(fileName).replace('(*)', '')
|
|
|
|
|
|
|
|
|
|
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}")
|
|
|
|
|
|
|
|
|
|
episodePartMatch = re.search("\\(([0-9]+)[-\\/]([0-9]+)\\)$", fileName)
|
|
|
|
|
if episodePartMatch is not None:
|
|
|
|
|
partSuffix = str(episodePartMatch.group(0))
|
|
|
|
|
partFirstIndex = episodePartMatch.groups()[0]
|
|
|
|
|
partLastIndex = episodePartMatch.groups()[1]
|
|
|
|
|
fileName = str(fileName).replace(partSuffix, f"Teil {partFirstIndex}-{partLastIndex}")
|
|
|
|
|
|
|
|
|
|
return fileName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getEpisodeFileBasename(showName,
|
|
|
|
|
episodeName,
|
|
|
|
|