From 6f559fb440ce6ec55c759dd559ef6898eeca519a Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Tue, 31 Jul 2018 01:52:07 +0100 Subject: [PATCH] Change TVDB data parsing for gueststars, writers and genre. Change map gueststars to string (gueststars_list field contains original list). Change convert writers to writer string. Change keep genre original list in genre_list. Change don't add/delete keys dict during iteritems. --- CHANGES.md | 7 ++++++- lib/tvdb_api/tvdb_api.py | 24 +++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 190e5285..15286106 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,9 @@ -### 0.16.21 (2018-07-28 14:15:00 UTC) +### 0.16.22 (2018-08-18 12:30:00 UTC) + +* Change TVDB data parsing for gueststars, writers and genre + + +### 0.16.21 (2018-07-28 14:15:00 UTC) * Change TorrentDay * Change TVDB API 2 to version 2.2.0 diff --git a/lib/tvdb_api/tvdb_api.py b/lib/tvdb_api/tvdb_api.py index faf00a41..7040db25 100644 --- a/lib/tvdb_api/tvdb_api.py +++ b/lib/tvdb_api/tvdb_api.py @@ -609,9 +609,13 @@ class Tvdb: except (StandardError, Exception): raise tvdb_error - map_show = {'airstime': 'airs_time', 'airsdayofweek': 'airs_dayofweek', 'imdbid': 'imdb_id'} + map_show = {'airstime': 'airs_time', 'airsdayofweek': 'airs_dayofweek', 'imdbid': 'imdb_id', + 'writers': 'writer'} def map_show_keys(data): + keep_data = {} + del_keys = [] + new_data = {} for k, v in data.iteritems(): k_org = k k = k.lower() @@ -619,6 +623,13 @@ class Tvdb: if k in ['banner', 'fanart', 'poster'] and v: v = self.config['url_artworkPrefix'] % v elif 'genre' == k: + keep_data['genre_list'] = v + v = '|%s|' % '|'.join([self._clean_data(c) for c in v if isinstance(c, basestring)]) + elif 'gueststars' == k: + keep_data['gueststars_list'] = v + v = '|%s|' % '|'.join([self._clean_data(c) for c in v if isinstance(c, basestring)]) + elif 'writers' == k: + keep_data[k] = v v = '|%s|' % '|'.join([self._clean_data(c) for c in v if isinstance(c, basestring)]) elif 'firstaired' == k: if v: @@ -633,8 +644,15 @@ class Tvdb: if k in map_show: k = map_show[k] if k_org is not k: - del(data[k_org]) - data[k] = v + del_keys.append(k_org) + new_data[k] = v + else: + data[k] = v + for d in del_keys: + del(data[d]) + if isinstance(data, dict): + data.update(new_data) + data.update(keep_data) return data if resp: