You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
4.9 KiB
Python
107 lines
4.9 KiB
Python
import logging
|
|
|
|
|
|
class ShowDescriptor():
|
|
"""This class represents the structural content of a media file including streams and metadata"""
|
|
|
|
CONTEXT_KEY = 'context'
|
|
|
|
ID_KEY = 'id'
|
|
NAME_KEY = 'name'
|
|
YEAR_KEY = 'year'
|
|
|
|
INDEX_SEASON_DIGITS_KEY = 'index_season_digits'
|
|
INDEX_EPISODE_DIGITS_KEY = 'index_episode_digits'
|
|
INDICATOR_SEASON_DIGITS_KEY = 'indicator_season_digits'
|
|
INDICATOR_EPISODE_DIGITS_KEY = 'indicator_episode_digits'
|
|
|
|
DEFAULT_INDEX_SEASON_DIGITS = 2
|
|
DEFAULT_INDEX_EPISODE_DIGITS = 2
|
|
DEFAULT_INDICATOR_SEASON_DIGITS = 2
|
|
DEFAULT_INDICATOR_EPISODE_DIGITS = 2
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
if ShowDescriptor.CONTEXT_KEY in kwargs.keys():
|
|
if type(kwargs[ShowDescriptor.CONTEXT_KEY]) is not dict:
|
|
raise TypeError(
|
|
f"ShowDescriptor.__init__(): Argument {ShowDescriptor.CONTEXT_KEY} is required to be of type dict"
|
|
)
|
|
self.__context = kwargs[ShowDescriptor.CONTEXT_KEY]
|
|
self.__logger = self.__context['logger']
|
|
else:
|
|
self.__context = {}
|
|
self.__logger = logging.getLogger('FFX')
|
|
self.__logger.addHandler(logging.NullHandler())
|
|
|
|
if ShowDescriptor.ID_KEY in kwargs.keys():
|
|
if type(kwargs[ShowDescriptor.ID_KEY]) is not int:
|
|
raise TypeError(f"ShowDescriptor.__init__(): Argument {ShowDescriptor.ID_KEY} is required to be of type int")
|
|
self.__showId = kwargs[ShowDescriptor.ID_KEY]
|
|
else:
|
|
self.__showId = -1
|
|
|
|
if ShowDescriptor.NAME_KEY in kwargs.keys():
|
|
if type(kwargs[ShowDescriptor.NAME_KEY]) is not str:
|
|
raise TypeError(f"ShowDescriptor.__init__(): Argument {ShowDescriptor.NAME_KEY} is required to be of type str")
|
|
self.__showName = kwargs[ShowDescriptor.NAME_KEY]
|
|
else:
|
|
self.__showName = ''
|
|
|
|
if ShowDescriptor.YEAR_KEY in kwargs.keys():
|
|
if type(kwargs[ShowDescriptor.YEAR_KEY]) is not int:
|
|
raise TypeError(f"ShowDescriptor.__init__(): Argument {ShowDescriptor.YEAR_KEY} is required to be of type int")
|
|
self.__showYear = kwargs[ShowDescriptor.YEAR_KEY]
|
|
else:
|
|
self.__showYear = -1
|
|
|
|
|
|
if ShowDescriptor.INDEX_SEASON_DIGITS_KEY in kwargs.keys():
|
|
if type(kwargs[ShowDescriptor.INDEX_SEASON_DIGITS_KEY]) is not int:
|
|
raise TypeError(f"ShowDescriptor.__init__(): Argument {ShowDescriptor.INDEX_SEASON_DIGITS_KEY} is required to be of type int")
|
|
self.__indexSeasonDigits = kwargs[ShowDescriptor.INDEX_SEASON_DIGITS_KEY]
|
|
else:
|
|
self.__indexSeasonDigits = ShowDescriptor.DEFAULT_INDEX_SEASON_DIGITS
|
|
|
|
if ShowDescriptor.INDEX_EPISODE_DIGITS_KEY in kwargs.keys():
|
|
if type(kwargs[ShowDescriptor.INDEX_EPISODE_DIGITS_KEY]) is not int:
|
|
raise TypeError(f"ShowDescriptor.__init__(): Argument {ShowDescriptor.INDEX_EPISODE_DIGITS_KEY} is required to be of type int")
|
|
self.__indexEpisodeDigits = kwargs[ShowDescriptor.INDEX_EPISODE_DIGITS_KEY]
|
|
else:
|
|
self.__indexEpisodeDigits = ShowDescriptor.DEFAULT_INDEX_EPISODE_DIGITS
|
|
|
|
if ShowDescriptor.INDICATOR_SEASON_DIGITS_KEY in kwargs.keys():
|
|
if type(kwargs[ShowDescriptor.INDICATOR_SEASON_DIGITS_KEY]) is not int:
|
|
raise TypeError(f"ShowDescriptor.__init__(): Argument {ShowDescriptor.INDICATOR_SEASON_DIGITS_KEY} is required to be of type int")
|
|
self.__indicatorSeasonDigits = kwargs[ShowDescriptor.INDICATOR_SEASON_DIGITS_KEY]
|
|
else:
|
|
self.__indicatorSeasonDigits = ShowDescriptor.DEFAULT_INDICATOR_SEASON_DIGITS
|
|
|
|
if ShowDescriptor.INDICATOR_EPISODE_DIGITS_KEY in kwargs.keys():
|
|
if type(kwargs[ShowDescriptor.INDICATOR_EPISODE_DIGITS_KEY]) is not int:
|
|
raise TypeError(f"ShowDescriptor.__init__(): Argument {ShowDescriptor.INDICATOR_EPISODE_DIGITS_KEY} is required to be of type int")
|
|
self.__indicatorEpisodeDigits = kwargs[ShowDescriptor.INDICATOR_EPISODE_DIGITS_KEY]
|
|
else:
|
|
self.__indicatorEpisodeDigits = ShowDescriptor.DEFAULT_INDICATOR_EPISODE_DIGITS
|
|
|
|
|
|
def getId(self):
|
|
return self.__showId
|
|
def getName(self):
|
|
return self.__showName
|
|
def getYear(self):
|
|
return self.__showYear
|
|
|
|
def getIndexSeasonDigits(self):
|
|
return self.__indexSeasonDigits
|
|
def getIndexEpisodeDigits(self):
|
|
return self.__indexEpisodeDigits
|
|
def getIndicatorSeasonDigits(self):
|
|
return self.__indicatorSeasonDigits
|
|
def getIndicatorEpisodeDigits(self):
|
|
return self.__indicatorEpisodeDigits
|
|
|
|
def getFilenamePrefix(self):
|
|
return f"{self.__showName} ({str(self.__showYear)})"
|