diff options
author | Vitiko <[email protected]> | 2022-11-08 22:15:48 -0400 |
---|---|---|
committer | Vitiko <[email protected]> | 2022-11-08 22:15:48 -0400 |
commit | 1ba94041299ecdd054e19c1ee4178dde115af076 (patch) | |
tree | 42a773b905edadc30aebb9310249ecdf6fe89e1e | |
parent | 4f060207ab8b638d0497bdef8e1f4e5445aab232 (diff) | |
download | bazarr-1ba94041299ecdd054e19c1ee4178dde115af076.tar.gz bazarr-1ba94041299ecdd054e19c1ee4178dde115af076.zip |
Update database refiner
-rw-r--r-- | bazarr/subtitles/refiners/database.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/bazarr/subtitles/refiners/database.py b/bazarr/subtitles/refiners/database.py index e67e38312..8f10884b9 100644 --- a/bazarr/subtitles/refiners/database.py +++ b/bazarr/subtitles/refiners/database.py @@ -12,6 +12,9 @@ from app.database import TableShows, TableEpisodes, TableMovies from .utils import convert_to_guessit +_TITLE_RE = re.compile(r'\s(\(\d{4}\))') + + def refine_from_db(path, video): if isinstance(video, Episode): data = TableEpisodes.select(TableShows.title.alias('seriesTitle'), @@ -33,13 +36,15 @@ def refine_from_db(path, video): if len(data): data = data[0] - video.series = re.sub(r'\s(\(\d\d\d\d\))', '', data['seriesTitle']) + video.series = _TITLE_RE.sub('', data['seriesTitle']) video.season = int(data['season']) video.episode = int(data['episode']) video.title = data['episodeTitle'] - # Commented out because Sonarr provided so much bad year - # if data['year']: - # if int(data['year']) > 0: video.year = int(data['year']) + + # Only refine year as a fallback + if not video.year and data['year']: + if int(data['year']) > 0: video.year = int(data['year']) + video.series_tvdb_id = int(data['tvdbId']) video.alternative_series = ast.literal_eval(data['alternateTitles']) if data['imdbId'] and not video.series_imdb_id: @@ -68,10 +73,12 @@ def refine_from_db(path, video): if len(data): data = data[0] - video.title = re.sub(r'\s(\(\d\d\d\d\))', '', data['title']) - # Commented out because Radarr provided so much bad year - # if data['year']: - # if int(data['year']) > 0: video.year = int(data['year']) + video.title = _TITLE_RE.sub('', data['title']) + + # Only refine year as a fallback + if not video.year and data['year']: + if int(data['year']) > 0: video.year = int(data['year']) + if data['imdbId'] and not video.imdb_id: video.imdb_id = data['imdbId'] video.alternative_titles = ast.literal_eval(data['alternativeTitles']) |