diff --git a/bazarr/api.py b/bazarr/api.py index 61da3c415..e15d7d2da 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -318,7 +318,10 @@ class Badges(Resource): episodes_conditions = [(TableEpisodes.missing_subtitles is not None), (TableEpisodes.missing_subtitles != '[]')] episodes_conditions += get_exclusion_clause('series') - missing_episodes = TableEpisodes.select().where(reduce(operator.and_, episodes_conditions)).count() + missing_episodes = TableEpisodes.select(TableShows.tags, TableShows.seriesType)\ + .join(TableShows, on=(TableEpisodes.sonarrSeriesId == TableShows.sonarrSeriesId))\ + .where(reduce(operator.and_, episodes_conditions))\ + .count() movies_conditions = [(TableMovies.missing_subtitles is not None), (TableMovies.missing_subtitles != '[]')] @@ -636,14 +639,11 @@ class Series(Resource): item.update({"episodeMissingCount": episodeMissingCount}) # Add episode count - episodes_count_conditions = [(TableEpisodes.sonarrSeriesId == item['sonarrSeriesId'])] - episodes_count_conditions += get_exclusion_clause('series') - episodeFileCount = TableEpisodes.select(TableShows.tags, TableEpisodes.monitored, TableShows.seriesType)\ .join(TableShows, on=(TableEpisodes.sonarrSeriesId == TableShows.sonarrSeriesId))\ - .where(reduce(operator.and_, episodes_count_conditions))\ + .where(TableEpisodes.sonarrSeriesId == item['sonarrSeriesId'])\ .count() item.update({"episodeFileCount": episodeFileCount}) diff --git a/bazarr/database.py b/bazarr/database.py index 0619773d2..1d308ab0a 100644 --- a/bazarr/database.py +++ b/bazarr/database.py @@ -294,11 +294,11 @@ def get_exclusion_clause(exclusion_type): if exclusion_type == 'series': tagsList = ast.literal_eval(settings.sonarr.excluded_tags) for tag in tagsList: - where_clause.append(~(TableShows.tags ** tag)) + where_clause.append(~(TableShows.tags.contains("\'"+tag+"\'"))) else: tagsList = ast.literal_eval(settings.radarr.excluded_tags) for tag in tagsList: - where_clause.append(~(TableMovies.tags ** tag)) + where_clause.append(~(TableMovies.tags.contains("\'"+tag+"\'"))) if exclusion_type == 'series': monitoredOnly = settings.sonarr.getboolean('only_monitored') diff --git a/bazarr/get_movies.py b/bazarr/get_movies.py index 3dff42bbb..df75a1225 100644 --- a/bazarr/get_movies.py +++ b/bazarr/get_movies.py @@ -161,20 +161,6 @@ def update_movies(send_event=True): logging.debug('BAZARR All movies synced from Radarr into database.') - # Search for desired subtitles if no more than 5 movies have been added. - if len(altered_movies) <= 5: - logging.debug("BAZARR No more than 5 movies were added during this sync then we'll search for subtitles.") - for altered_movie in altered_movies: - conditions = [(TableMovies.radarrId == altered_movie[2])] - conditions += get_exclusion_clause('movie') - data = TableMovies.get(reduce(operator.and_, conditions)) - if data: - movies_download_subtitles(data['radarrId']) - else: - logging.debug("BAZARR skipping download for this movie as it is excluded.") - else: - logging.debug("BAZARR More than 5 movies were added during this sync then we wont search for subtitles.") - def update_one_movie(movie_id, action): logging.debug('BAZARR syncing this specific movie from Radarr: {}'.format(movie_id))