From 95232b587e00018715178602ceafbce2d457d5ff Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Tue, 12 Mar 2019 09:15:34 +1100 Subject: [PATCH 1/3] Fix up a crash in search function with no year This seems to be an edge case in shoko when the year is not available --- Contents/Code/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index e120d0f..e69850e 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -79,7 +79,7 @@ def Search(self, results, media, lang, manual, movie): for result in prelimresults: #for result in group['series']: score = 100 if result['name'] == name else 85 # TODO: Improve this to respect synonyms./ - meta = MetadataSearchResult('%s' % result['id'], result['name'], result['year'], score, lang) + meta = MetadataSearchResult('%s' % result['id'], result['name'], try_get(result, 'year', None), score, lang) results.Append(meta) # results.Sort('score', descending=True) From d4bfa4f5ac1505dbc443dd1e46884ae9926029b2 Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Thu, 14 Mar 2019 10:27:07 +1100 Subject: [PATCH 2/3] Old changes that will be useful --- Contents/Code/__init__.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index e120d0f..f4f1fd2 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -215,14 +215,17 @@ def metadata_add(self, meta, images): valid = list() for art in images: - if 'support/plex_404.png' in art['url']: - continue - if ':' in art['url']: - urlparts = urllib.parse.urlparse(art['url']) - art['url'] = art['url'].replace("{scheme}://{host}:{port}/".format(scheme=urlparts.scheme, host=urlparts.hostname, port=urlparts.port), '') - Log("[metadata_add] :: Adding metadata %s (index %d)" % (art['url'], art['index'])) - meta[art['url']] = Proxy.Media(HTTP.Request("http://{host}:{port}{relativeURL}".format(host=Prefs['Hostname'], port=Prefs['Port'], relativeURL=art['url'])).content, art['index']) - valid.append(art['url']) + try: + if 'support/plex_404.png' in art['url']: + continue + if ':' in art['url']: + urlparts = urllib.parse.urlparse(art['url']) + art['url'] = art['url'].replace("{scheme}://{host}:{port}/".format(scheme=urlparts.scheme, host=urlparts.hostname, port=urlparts.port), '') + Log("[metadata_add] :: Adding metadata %s (index %d)" % (art['url'], art['index'])) + meta[art['url']] = Proxy.Media(HTTP.Request("http://{host}:{port}{relativeURL}".format(host=Prefs['Hostname'], port=Prefs['Port'], relativeURL=art['url'])).content, art['index']) + valid.append(art['url']) + except: + Log("[metadata_add] :: Invalid URL given (%s), skipping" % art['url']) meta.validate_keys(valid) From 6a94cb4326c34fc62dc1d18f973dc5ef348a4e52 Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Thu, 14 Mar 2019 10:34:18 +1100 Subject: [PATCH 3/3] Use a regex to hide anidb links. --- Contents/Code/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 718b9bf..bb727f0 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -15,7 +15,7 @@ #this is from https://github.com/plexinc-agents/PlexThemeMusic.bundle/blob/master/Contents/Code/__init__.py THEME_URL = 'http://tvthemes.plexapp.com/%s.mp3' - +LINK_REGEX = r"https?:\/\/\w+.\w+(?:\/?\w+)? \[([\w ]+)\]" def ValidatePrefs(): pass @@ -104,7 +104,7 @@ def Update(self, metadata, media, lang, force, movie): series = HttpReq("api/serie?id=%s&level=3&allpics=1&tagfilter=%d" % (aid, flags)) # build metadata on the TV show. - metadata.summary = try_get(series, 'summary') + metadata.summary = re.sub(LINK_REGEX, r'\1', try_get(series, 'summary')) metadata.title = series['name'] metadata.rating = float(series['rating']) year = try_get(series, "year", None)