mirror of
https://github.com/SinTan1729/TvTimeToTrakt.git
synced 2025-04-19 17:40:01 -05:00
Remove use of Exodus class
This commit is contained in:
parent
5a219b8485
commit
b6ebbc07e5
1 changed files with 31 additions and 22 deletions
|
@ -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:
|
||||||
|
# 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_value = year_search.group(1)
|
||||||
|
# Then, get the title without the year value included
|
||||||
|
title_value = title.split("(")[0].strip()
|
||||||
|
# Put this together into an object
|
||||||
|
self.full_title = title
|
||||||
|
self.without_year = title_value
|
||||||
|
self.titleWithoutYear = title_value
|
||||||
|
self.year = int(year_value)
|
||||||
|
self.yearValue = int(year_value)
|
||||||
|
except Exception:
|
||||||
|
# If the above failed, then the title doesn't include a year
|
||||||
|
# so return the object as is.
|
||||||
|
self.full_title = title
|
||||||
|
self.without_year = title
|
||||||
|
self.titleWithoutYear = title
|
||||||
|
self.year = -1
|
||||||
|
self.yearValue = -1
|
||||||
|
|
||||||
try:
|
|
||||||
# Use a regex expression to get the value within the brackets e.g The Americans (2017)
|
def get_year_from_title(title) -> Title:
|
||||||
year_search = re.search(r"\(([A-Za-z0-9_]+)\)", title)
|
return Title(title)
|
||||||
year_value = year_search.group(1)
|
|
||||||
# Then, get the title without the year value included
|
|
||||||
title_value = title.split("(")[0].strip()
|
|
||||||
# Put this together into an object
|
|
||||||
ex.titleWithoutYear = title_value
|
|
||||||
ex.yearValue = int(year_value)
|
|
||||||
return ex
|
|
||||||
except Exception:
|
|
||||||
# If the above failed, then the title doesn't include a year
|
|
||||||
# so return the object as is.
|
|
||||||
ex.titleWithoutYear = title
|
|
||||||
ex.yearValue = -1
|
|
||||||
return ex
|
|
||||||
|
|
||||||
|
|
||||||
# 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,
|
||||||
|
|
Loading…
Reference in a new issue