From c521792c3d14354b5368337ac1c105138d4ffedc Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Fri, 10 Feb 2023 14:57:47 +0000 Subject: [PATCH] Fix TMDB language caching. --- CHANGES.md | 8 +++++++- lib/api_tmdb/tmdb_api.py | 33 +++++++++++++++++---------------- lib/tvinfo_base/base.py | 4 ++-- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 466694d1..e60e7b34 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,10 @@ -### 3.27.0 (2023-02-09 15:00:00 UTC) +### 3.27.1 (2023-02-10 15:25:00 UTC) + +* Change display show status in Change show header +* Fix TMDB language caching + + +### 3.27.0 (2023-02-09 15:00:00 UTC) * Update Apprise 0.8.5 (55a2edc) to 1.2.1 (3d07004) * Update attr 20.3.0 (f3762ba) to 22.2.0 (a9960de) diff --git a/lib/api_tmdb/tmdb_api.py b/lib/api_tmdb/tmdb_api.py index 593e55f4..824cd7d3 100644 --- a/lib/api_tmdb/tmdb_api.py +++ b/lib/api_tmdb/tmdb_api.py @@ -76,7 +76,7 @@ def get_tmdb_constants(): # type: (...) -> Dict """return tmdbsimple Configuration().info() or cached copy""" global _TMDB_CONSTANTS_CACHE - # only retrieve info data if older then 3 days + # only retrieve info data if older than 3 days if 3 < (datetime.datetime.now() - _TMDB_CONSTANTS_CACHE['date']).days or not _TMDB_CONSTANTS_CACHE['data']: try: tv_genres = {g['id']: g['name'] for g in tmdbsimple.Genres().tv_list()['genres']} @@ -520,10 +520,10 @@ class TmdbIndexer(TVInfoBase): number of votes, genres, the network they aired on and air dates. Discover also supports a nice list of sort options. See below for all - of the available options. + the available options. Also note that a number of filters support being comma (,) or pipe (|) - separated. Comma's are treated like an AND and query while pipe's are + separated. Commas are treated like an AND query while pipe's are an OR. Some examples of what can be done with discover can be found at @@ -539,23 +539,23 @@ class TmdbIndexer(TVInfoBase): popularity.desc, popularity.asc Default: popularity.desc air_date.gte: (optional) Filter and only include TV shows that have - a air date (by looking at all episodes) that is greater or + an air date (by looking at all episodes) that is greater or equal to the specified value. air_date.lte: (optional) Filter and only include TV shows that have - a air date (by looking at all episodes) that is less than or + an air date (by looking at all episodes) that is less than or equal to the specified value. first_air_date.gte: (optional) Filter and only include TV shows - that have a original air date that is greater or equal to the + that have an original air date that is greater or equal to the specified value. Can be used in conjunction with the "include_null_first_air_dates" filter if you want to include items with no air date. first_air_date.lte: (optional) Filter and only include TV shows - that have a original air date that is less than or equal to the + that have an original air date that is less than or equal to the specified value. Can be used in conjunction with the "include_null_first_air_dates" filter if you want to include items with no air date. first_air_date_year: (optional) Filter and only include TV shows - that have a original air date year that equal to the specified + that have an original air date year that equal to the specified value. Can be used in conjunction with the "include_null_first_air_dates" filter if you want to include items with no air date. @@ -760,9 +760,9 @@ class TmdbIndexer(TVInfoBase): @property def _tmdb_supported_lang_list(self): - if None is self._tmdb_lang_list: + if not TmdbIndexer._tmdb_lang_list: self._get_languages() - return self._tmdb_lang_list + return TmdbIndexer._tmdb_lang_list def _get_languages(self): # type: (...) -> None @@ -772,10 +772,11 @@ class TmdbIndexer(TVInfoBase): except (BaseException, Exception): lang_data = None if lang_data: - self._supported_languages = [{'id': clean_data(a['iso_639_1']), 'name': clean_data(a['english_name']), - 'nativeName': clean_data(a['name']), - 'shortCode': None, 'sg_lang': clean_data(a['iso_639_1'])} - for a in sorted(lang_data, key=lambda b: b['iso_639_1'])] - self._tmdb_lang_list = [a['id'] for a in self._supported_languages] + TmdbIndexer._supported_languages = [{ + 'id': clean_data(a['iso_639_1']), 'name': clean_data(a['english_name']), + 'nativeName': clean_data(a['name']), 'shortCode': None, 'sg_lang': clean_data(a['iso_639_1']) + } for a in sorted(lang_data, key=lambda b: b['iso_639_1'])] + TmdbIndexer._tmdb_lang_list = [a['id'] for a in self._supported_languages] else: - self._supported_languages = [] + TmdbIndexer._supported_languages = [] + TmdbIndexer._tmdb_lang_list = [] diff --git a/lib/tvinfo_base/base.py b/lib/tvinfo_base/base.py index a3af64b1..32914381 100644 --- a/lib/tvinfo_base/base.py +++ b/lib/tvinfo_base/base.py @@ -1347,9 +1347,9 @@ class TVInfoBase(object): get all supported languages as list of dicts [{'id': 'lang code', 'name': 'english name', 'nativeName': 'native name', 'sg_lang': 'sg lang code'}] """ - if None is self._supported_languages: + if not self._supported_languages: self._get_languages() - return self._supported_languages + return self._supported_languages or [] def __str__(self): return '' % (self.__class__.__name__, text_type(self.shows))