From c9561ac3f0e8133f8d08b361e8878fba9afa1b1d Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Fri, 3 Feb 2017 02:19:37 +1100 Subject: [PATCH 1/6] Update to work with latest (dev) shoko server. --- Contents/Code/__init__.py | 16 ++++++++-------- .../Resources/Series/Shoko Series Scanner.py | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index c7749cb..d4583cd 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -54,13 +54,13 @@ def Search(self, results, media, lang, manual, movie): # http://127.0.0.1:8111/api/serie/search?query=Clannad&level=1&apikey=d422dfd2-bdc3-4219-b3bb-08b85aa65579 - prelimresults = HttpReq("api/serie/search?query=%s&level=%d&fuzzy=1" % (urllib.quote(name), 0)) + prelimresults = HttpReq("api/serie/search?query=%s&level=%d&fuzzy=1" % (urllib.quote(name), 1)) - for group in prelimresults['groups']: - for result in group['series']: - score = 100 if result['title'] == name else 85 # TODO: Improve this to respect synonyms./ - meta = MetadataSearchResult('%s' % result['id'], result['title'], result['year'], score, lang) - results.Append(meta) + 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) + results.Append(meta) # results.Sort('score', descending=True) @@ -75,7 +75,7 @@ def Update(self, metadata, media, lang, force, movie): # build metadata on the TV show. metadata.summary = series['summary'] - metadata.title = series['title'] + metadata.title = series['name'] metadata.rating = float(series['rating']) tags = [] @@ -137,7 +137,7 @@ def Update(self, metadata, media, lang, force, movie): pass episodeObj = metadata.seasons[season].episodes[ep['epnumber']] - episodeObj.title = ep['title'] + episodeObj.title = ep['name'] episodeObj.summary = ep['summary'] if ep['air'] != '1/01/0001 12:00:00 AM': diff --git a/Contents/Resources/Series/Shoko Series Scanner.py b/Contents/Resources/Series/Shoko Series Scanner.py index f8a8d2c..5f33f1d 100644 --- a/Contents/Resources/Series/Shoko Series Scanner.py +++ b/Contents/Resources/Series/Shoko Series Scanner.py @@ -78,7 +78,7 @@ def Scan(path, files, mediaList, subdirs, language=None, root=None): if len(episode_data) == 0: break series_data = HttpReq("api/serie/fromep?id=%d&nocast=1¬ag=1" % episode_data['id']) - showTitle = str(series_data['title']) #no idea why I need to do this. + showTitle = str(series_data['name']) #no idea why I need to do this. log('Scan', 'show title: %s', showTitle) seasonNumber = 0 @@ -102,7 +102,7 @@ def Scan(path, files, mediaList, subdirs, language=None, root=None): log('Scan', 'episode number: %s', episodeNumber) - episodeTitle = str(episode_data['title']) + episodeTitle = str(episode_data['name']) log('Scan', 'episode title: %s', episodeTitle) vid = Media.Episode(showTitle, int(seasonNumber), episodeNumber , episodeTitle, int(seasonYear)) From dd4839e6daa4076be04db1df51de8eebcd598201 Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Sun, 5 Feb 2017 16:11:28 +1100 Subject: [PATCH 2/6] Update HTTP call to /api/serie?id=... to increase the level. --- 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 d4583cd..0dd74e7 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -71,7 +71,7 @@ def Update(self, metadata, media, lang, force, movie): # http://127.0.0.1:8111/api/ep/getbyfilename?apikey=d422dfd2-bdc3-4219-b3bb-08b85aa65579&filename=%5Bjoseole99%5D%20Clannad%20-%2001%20(1280x720%20Blu-ray%20H264)%20%5B8E128DF5%5D.mkv # episode_data = HttpReq("api/ep/getbyfilename?apikey=%s&filename=%s" % (GetApiKey(), urllib.quote(media.filename))) - series = HttpReq("api/serie?id=%s" % aid) + series = HttpReq("api/serie?id=%s&level=3" % aid) # build metadata on the TV show. metadata.summary = series['summary'] From 013acff44c4504d937202aaafc1b2554726bcc82 Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Sun, 5 Feb 2017 22:37:34 +1100 Subject: [PATCH 3/6] Add the option for Fuzzy searching on matching (default enabled) As when using things like Shoko Series Scanner the names will be exact matches instead of approximations by plex --- Contents/Code/__init__.py | 2 +- Contents/DefaultPrefs.json | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 0dd74e7..0e52eff 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -54,7 +54,7 @@ def Search(self, results, media, lang, manual, movie): # http://127.0.0.1:8111/api/serie/search?query=Clannad&level=1&apikey=d422dfd2-bdc3-4219-b3bb-08b85aa65579 - prelimresults = HttpReq("api/serie/search?query=%s&level=%d&fuzzy=1" % (urllib.quote(name), 1)) + prelimresults = HttpReq("api/serie/search?query=%s&level=%d&fuzzy=%d" % (urllib.quote(name), 1, Prefs['Fuzzy'])) for result in prelimresults: #for result in group['series']: diff --git a/Contents/DefaultPrefs.json b/Contents/DefaultPrefs.json index 9f9ed5b..1762047 100644 --- a/Contents/DefaultPrefs.json +++ b/Contents/DefaultPrefs.json @@ -29,6 +29,13 @@ "default": "8111" }, + { + "id": "Fuzzy", + "label": "Use fuzzy searching in Shoko for matching the titles.", + "type": "bool", + "default": false + }, + { "id": "Ratings", "label": "Enable using the \"assumed\" ratings portion of the code", From 724d341dc0d7ff49d83b8a8baef0b6d3f5ac3432 Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Mon, 6 Feb 2017 12:42:21 +1100 Subject: [PATCH 4/6] Add the original title where the title is {type: 'official', language: 'ja'} --- Contents/Code/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 0e52eff..d242790 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -125,6 +125,11 @@ def Update(self, metadata, media, lang, force, movie): Log('Assumed tv rating to be: %s' % metadata.content_rating) + for t in series['titles']: + if (t['type'] == 'official' || t['language'] == 'ja'): + metadata.original_title = t['title'] + + if not movie: for ep in series['eps']: if ep['eptype'] != 1: From 700c40e79a7ec3ae00b2a80b089efd099d5ef858 Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Mon, 6 Feb 2017 13:48:27 +1100 Subject: [PATCH 5/6] I'm an idiot --- 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 d242790..b83fdb3 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -126,7 +126,7 @@ def Update(self, metadata, media, lang, force, movie): Log('Assumed tv rating to be: %s' % metadata.content_rating) for t in series['titles']: - if (t['type'] == 'official' || t['language'] == 'ja'): + if (t['type'] == 'official' or t['language'] == 'ja'): metadata.original_title = t['title'] From 08293c2afcd1253c450f004582aad526bf94fada Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Mon, 6 Feb 2017 13:51:27 +1100 Subject: [PATCH 6/6] I swear, I know boolean logic. --- 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 b83fdb3..596ff57 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -126,7 +126,7 @@ def Update(self, metadata, media, lang, force, movie): Log('Assumed tv rating to be: %s' % metadata.content_rating) for t in series['titles']: - if (t['type'] == 'official' or t['language'] == 'ja'): + if (t['type'] == 'official' and t['language'] == 'ja'): metadata.original_title = t['title']