From f23c40ba88aaf6b525d61bd4518f82d701114925 Mon Sep 17 00:00:00 2001 From: JackDandy Date: Sat, 1 Oct 2016 00:59:52 +0100 Subject: [PATCH] Change locally cache "Add from Trakt" show posters, first run takes more time but is faster thereafter. --- CHANGES.md | 1 + sickbeard/webserve.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index bfa1e324..f747457d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -169,6 +169,7 @@ * Fix status reset of a snatched, downloaded, or archived episode when its date is set to never (no date) on the info source and there is no media file * Change only show unaired episodes on Manage/Backlog Overview and Manage/Episode Status Management where relevant +* Change locally cache "Add from Trakt" show posters, first run takes more time but is faster thereafter [develop changelog] * Change send nzb data to NZBGet for Anizb instead of url diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 29b025e6..c33b412e 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -3063,6 +3063,18 @@ class NewHomeAddShows(Home): if dt_ordinal > newest_dt: newest_dt = dt_ordinal newest = dt_string + + img_uri = item.get('show', {}).get('images', {}).get('poster', {}).get('thumb', {}) or '' + if img_uri: + path = ek.ek(os.path.abspath, ek.ek( + os.path.join, sickbeard.CACHE_DIR, 'images', 'trakt', 'poster', 'thumb')) + helpers.make_dirs(path) + file_name = ek.ek(os.path.basename, img_uri) + cached_name = ek.ek(os.path.join, path, file_name) + if not ek.ek(os.path.isfile, cached_name): + helpers.download_file(img_uri, cached_name) + images = dict(poster=dict(thumb='cache/images/trakt/poster/thumb/%s' % file_name)) + filtered.append(dict( premiered=dt_ordinal, premiered_str=dt_string, @@ -3074,7 +3086,7 @@ class NewHomeAddShows(Home): genres=('' if 'genres' not in item['show'] else ', '.join(['%s' % v for v in item['show']['genres']])), ids=item['show']['ids'], - images='' if 'images' not in item['show'] else item['show']['images'], + images='' if not img_uri else images, overview=('' if 'overview' not in item['show'] or None is item['show']['overview'] else self.encode_html(item['show']['overview'][:250:].strip())), rating=0 < item['show'].get('rating', 0) and