Remove use of Exodus class

This commit is contained in:
Markus Nyman 2023-01-12 14:57:45 +02:00
parent 5a219b8485
commit b6ebbc07e5

View file

@ -34,10 +34,6 @@ syncedMoviesTable = database.table("SyncedMovies")
userMatchedMoviesTable = database.table("TvTimeTraktUserMatchedMovies") userMatchedMoviesTable = database.table("TvTimeTraktUserMatchedMovies")
class Expando(object):
pass
@dataclass @dataclass
class Config: class Config:
trakt_username: str trakt_username: str
@ -102,26 +98,39 @@ def init_trakt_auth():
# and then return this value, with the title and year removed to improve # and then return this value, with the title and year removed to improve
# the accuracy of Trakt results. # the accuracy of Trakt results.
@dataclass
class Title:
full_title: str
without_year: str
year: int
titleWithoutYear: str
yearValue: int
def get_year_from_title(title): def __init__(self, title: str):
ex = Expando()
try: try:
# Use a regex expression to get the value within the brackets e.g The Americans (2017) # Use a regex expression to get the value within the brackets e.g. The Americans (2017)
year_search = re.search(r"\(([A-Za-z0-9_]+)\)", title) year_search = re.search(r"\(([A-Za-z0-9_]+)\)", title)
year_value = year_search.group(1) year_value = year_search.group(1)
# Then, get the title without the year value included # Then, get the title without the year value included
title_value = title.split("(")[0].strip() title_value = title.split("(")[0].strip()
# Put this together into an object # Put this together into an object
ex.titleWithoutYear = title_value self.full_title = title
ex.yearValue = int(year_value) self.without_year = title_value
return ex self.titleWithoutYear = title_value
self.year = int(year_value)
self.yearValue = int(year_value)
except Exception: except Exception:
# If the above failed, then the title doesn't include a year # If the above failed, then the title doesn't include a year
# so return the object as is. # so return the object as is.
ex.titleWithoutYear = title self.full_title = title
ex.yearValue = -1 self.without_year = title
return ex self.titleWithoutYear = title
self.year = -1
self.yearValue = -1
def get_year_from_title(title) -> Title:
return Title(title)
# Shows in TV Time are often different to Trakt.TV - in order to improve results and automation, # Shows in TV Time are often different to Trakt.TV - in order to improve results and automation,