From 548fe7d17b2e4dd24f1444bdce9ffab2958abf62 Mon Sep 17 00:00:00 2001 From: desimaniac <5501908+desimaniac@users.noreply.github.com> Date: Sun, 9 Feb 2020 13:15:16 -0600 Subject: [PATCH] Fiters: Blank languages list will not fallback to english anymore --- README.md | 12 ++++++++---- helpers/trakt.py | 14 ++++++++------ media/trakt.py | 10 ++++------ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index da6e768..e944110 100644 --- a/README.md +++ b/README.md @@ -603,7 +603,7 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi - Blank list (i.e. `[]`) - Add movies from any country. - - `ignore` (i.e. `["ignore"]`) Add movies from any country, including ones with no country specified. + - `ignore` (i.e. `["ignore"]`) - Add movies from any country, including ones with no country specified. `allowed_languages` - Only add movies with these languages. Listed as two-letter language codes. @@ -613,7 +613,9 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi - Special keywords: - - Blank list (i.e. `[]`) - Only add shows that are in English (`en`). + - Blank list (i.e. `[]`) - Add movies with any language. + + - `ignore` (i.e. `["ignore"]`) - Add movies with any language, including ones with no language specified. `blacklisted_genres` - Blacklist certain genres. @@ -729,7 +731,7 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi - Blank list (i.e. `[]`) - Add shows from any country. - - `ignore` (i.e. `["ignore"]`) Add shows from any country, including ones with no country specified. + - `ignore` (i.e. `["ignore"]`) - Add shows from any country, including ones with no country specified. `allowed_languages` - Only add shows with these languages. @@ -739,8 +741,10 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi - Special keywords: - - Blank list (i.e. `[]`) - Only add shows that are in English (`en`). + - Blank list (i.e. `[]`) - Add shows with any language. + - `ignore` (i.e. `["ignore"]`) - Add shows with any language, including ones with no language specified. + `blacklisted_genres` - Blacklist certain genres. - [List of available TV show genres](assets/list_of_tv_show_genres.md). diff --git a/helpers/trakt.py b/helpers/trakt.py index 1e88011..f4b9d31 100644 --- a/helpers/trakt.py +++ b/helpers/trakt.py @@ -122,9 +122,6 @@ def blacklisted_show_country(show, allowed_countries): def blacklisted_show_language(show, allowed_languages): blacklisted = False - # [] - add show items with 'en' language - if not allowed_languages: - allowed_languages = ['en'] try: # ["ignore"] - add show item even if it is missing a language if any('ignore' in s.lower() for s in allowed_languages): @@ -134,6 +131,10 @@ def blacklisted_show_language(show, allowed_languages): log.debug("\'%s\' | Blacklisted Languages Check | Blacklisted because it had no language specified.", show['show']['title']) blacklisted = True + # [] - add show item from any valid language + elif not allowed_languages: + log.debug("\'%s\' | Blacklisted Languages Check | Skipped.", + show['show']['title']) # List provided - skip adding show item if the language is blacklisted elif not any(show['show']['language'].lower() in c.lower() for c in allowed_languages): log.debug("\'%s\' | Blacklisted Languages Check | Blacklisted because it's in the language: %s", @@ -308,9 +309,6 @@ def blacklisted_movie_country(movie, allowed_countries): def blacklisted_movie_language(movie, allowed_languages): blacklisted = False - # [] - add movie items with 'en' language - if not allowed_languages: - allowed_languages = ['en'] try: # ["ignore"] - add movie item even if it is missing a language if any('ignore' in s.lower() for s in allowed_languages): @@ -321,6 +319,10 @@ def blacklisted_movie_language(movie, allowed_languages): log.debug("\'%s\' | Blacklisted Languages Check | Blacklisted because it had no language specified.", movie['movie']['title']) blacklisted = True + # [] - add movie item from any valid language + elif not allowed_languages: + log.debug("\'%s\' | Blacklisted Languages Check | Skipped.", + movie['movie']['title']) # List provided - skip adding movie item if the language is blacklisted elif not any(movie['movie']['language'].lower() in s.lower() for s in allowed_languages): log.debug("\'%s\' | Blacklisted Languages Check | Blacklisted because it's in the language: %s", diff --git a/media/trakt.py b/media/trakt.py index 578ede5..c8cf7e7 100644 --- a/media/trakt.py +++ b/media/trakt.py @@ -100,18 +100,16 @@ class Trakt: if payload is None: payload = {} - # languages list - if not languages: - languages = ['en'] - languages = ','.join(languages).lower() - payload = dict_merge(payload, { 'extended': 'full', 'limit': limit, 'page': 1, - 'languages': languages, }) + # languages list + if languages: + payload['languages'] = ','.join(languages).lower() + # years range if years: payload['years'] = years