Skip to content

Commit e79af8d

Browse files
authored
Merge pull request #607 from pkscout/tmdb-tvshows-202
[metadata.tvshows.themoviedb.org.python] v.2.0.2
2 parents 48eb475 + 334fc13 commit e79af8d

7 files changed

Lines changed: 39 additions & 69 deletions

File tree

metadata.tvshows.themoviedb.org.python/.github/workflows/sync-addon-metadata-translations.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

metadata.tvshows.themoviedb.org.python/addon.xml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<addon id="metadata.tvshows.themoviedb.org.python"
33
name="TMDb TV Shows"
4-
version="2.0.1"
4+
version="2.0.2"
55
provider-name="Team Kodi">
66
<requires>
77
<import addon="xbmc.python" version="3.0.0"/>
@@ -10,13 +10,10 @@
1010
<extension point="xbmc.metadata.scraper.tvshows" library="main.py"/>
1111
<extension point="xbmc.addon.metadata">
1212
<reuselanguageinvoker>true</reuselanguageinvoker>
13-
<news>2.0.1
14-
- Season-aware artwork selection
15-
- Better artwork distribution across all art types
16-
- Fix Fanart.tv URLs with special characters
17-
- Fanart.tv source preference settings
18-
- Artwork scoring: language + resolution
19-
- Punctuation agnostic title matching, year filter fallback
13+
<news>2.0.2
14+
- Log Fanart.tv and Trakt 404s as info instead of error
15+
- Wipe in-memory caches after 15 min idle
16+
- updated Trakt access
2017
</news>
2118
<platform>all</platform>
2219
<license>GPL-3.0-or-later</license>

metadata.tvshows.themoviedb.org.python/changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2.0.2
2+
Log Fanart.tv and Trakt 404s as info instead of error
3+
Wipe in-memory caches after 15 min idle
4+
updated Trackt access
5+
16
2.0.1
27
ground up rewrite by MikeSiLVO
38
Season-aware artwork selection

metadata.tvshows.themoviedb.org.python/lib/api/fanarttv.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,9 @@ def _fetch(tvdb_id, client_key):
105105
with urlopen(req, timeout=10) as resp:
106106
return json.loads(resp.read().decode('utf-8'))
107107
except Exception as exc:
108-
log.error('Fanart.tv GET /tv/{} failed: {}'.format(tvdb_id, exc))
108+
from urllib.error import HTTPError
109+
if isinstance(exc, HTTPError) and exc.code == 404:
110+
log.info('Fanart.tv GET /tv/{}: not found'.format(tvdb_id))
111+
else:
112+
log.error('Fanart.tv GET /tv/{} failed: {}'.format(tvdb_id, exc))
109113
return None

metadata.tvshows.themoviedb.org.python/lib/api/trakt.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,9 @@ def _get(path, params=None):
103103
with urlopen(req, timeout=10) as resp:
104104
return json.loads(resp.read().decode('utf-8'))
105105
except Exception as exc:
106-
log.error('Trakt GET {} failed: {}'.format(path, exc))
106+
from urllib.error import HTTPError
107+
if isinstance(exc, HTTPError) and exc.code == 404:
108+
log.info('Trakt GET {}: not found'.format(path))
109+
else:
110+
log.error('Trakt GET {} failed: {}'.format(path, exc))
107111
return None

metadata.tvshows.themoviedb.org.python/lib/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
TMDB_API_KEY = 'af3a53eb387d57fc935e9128468b1899'
1919

20-
TRAKT_CLIENTID = '90901c6be3b2de5a4fa0edf9ab5c75e9a5a0fef2b4ee7373d8b63dcf61f95697'
20+
TRAKT_CLIENTID = '07b40ae3e7c2aa7be77053b27469bfc599aafca58dafda41597c721e1293dd01'
2121

2222
FANARTTV_BASE = 'https://webservice.fanart.tv/v3.2'
2323
FANARTTV_KEY = 'b018086af0e1478479adfc55634db97d'

metadata.tvshows.themoviedb.org.python/lib/scraper.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
import json
66
import re
7+
import time
78

89
import xbmc
910
import xbmcgui
1011
import xbmcplugin
1112

1213
from lib import art_cache, log
1314
from lib.artwork import set_artwork
15+
from lib.api import trakt
1416
from lib.api.fanarttv import merge_fanarttv_artwork
1517
from lib.api.tmdb import TmdbApi, get_image_base, _cache
1618
from lib.api.imdb import get_rating as imdb_rating, check_update as imdb_check
@@ -51,9 +53,25 @@
5153

5254
_active_show = ''
5355

56+
_IDLE_TTL = 15 * 60
57+
_last_activity = 0
58+
59+
60+
def _clear_in_memory_caches():
61+
_cache.clear()
62+
trakt._cached_shows.clear()
63+
trakt._episode_cache.clear()
64+
5465

5566
def run_action(handle, action, params):
5667
"""Dispatch a Kodi scraper action."""
68+
global _last_activity
69+
now = time.time()
70+
if _last_activity and now - _last_activity > _IDLE_TTL:
71+
log.debug('idle > {}s, wiping in-memory caches'.format(_IDLE_TTL))
72+
_clear_in_memory_caches()
73+
_last_activity = now
74+
5775
settings = get_settings()
5876
log.init(settings.get('verbose_log', False))
5977

0 commit comments

Comments
 (0)