From f8ba0b11a7a6da54932e59546bda0bfc9b2f9583 Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Mon, 12 Feb 2018 16:09:53 +1100 Subject: [PATCH 1/4] Fix episode thumbnail linking, and ignore "plex_404.png" --- Contents/Code/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 4ac5505..ddd3f88 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -175,16 +175,13 @@ def Update(self, metadata, media, lang, force, movie): episodeObj = metadata.seasons[season].episodes[ep['epnumber']] episodeObj.title = ep['name'] episodeObj.summary = ep['summary'] + Log("" + str(ep['epnumber']) + ": " + ep['summary']) if ep['air'] != '1/01/0001 12:00:00 AM' and ep['air'] != '0001-01-01': episodeObj.originally_available_at = datetime.strptime(ep['air'], "%Y-%m-%d").date() - if len(series['art']['thumb']) and Prefs['customThumbs']: - for art in series['art']['thumb']: - 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), '') - episodeObj.thumbs[art['url']] = Proxy.Media(HTTP.Request("http://{host}:{port}{relativeURL}".format(host=Prefs['Hostname'], port=Prefs['Port'], relativeURL=art['url'])).content, art['index']) + if len(ep['art']['thumb']) and Prefs['customThumbs']: + self.metadata_add(episodeObj.thumbs, ep['art']['thumb']) links = HttpReq("api/links/serie?id=%s" % aid) @@ -202,6 +199,8 @@ 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), '') From e3c91771484413ced16bf3262587a3ec10654576 Mon Sep 17 00:00:00 2001 From: Andrew Huertas Date: Thu, 15 Feb 2018 04:38:57 -0800 Subject: [PATCH 2/4] Trailers and ShokoMovies Extras as ShokoTV (#25) * Fix season number parse error due to season being an int or string. Added trailers as season -2 to prevent Plex thinking it is a multiple file. * Fix encoding and ShokoMovies support same languages as ShokoTV * Move ShokeMovies' trailers, specials, and credits to ShokoTV. * special fix * give trailer and credits metadata info --- Contents/Code/__init__.py | 13 ++++++--- .../Resources/Movies/Shoko Movie Scanner.py | 18 ++++++++++--- .../Resources/Series/Shoko Series Scanner.py | 27 ++++++++++--------- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index ddd3f88..6e360f7 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -74,7 +74,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=%d" % (urllib.quote(name), 1, Prefs['Fuzzy'])) + prelimresults = HttpReq("api/serie/search?query=%s&level=%d&fuzzy=%d" % (urllib.quote(name.encode('utf8')), 1, Prefs['Fuzzy'])) for result in prelimresults: #for result in group['series']: @@ -163,12 +163,17 @@ def Update(self, metadata, media, lang, force, movie): if not movie: for ep in series['eps']: - if ep['eptype'] != "Episode": + if ep['eptype'] not in ["Episode", "Special", "Credits", "Trailer"]: continue - season = 1 + if ep['eptype'] == "Episode": season = 1 + elif ep['eptype'] == "Special": season = 0 + elif ep['eptype'] == "Credits": season = -1 + elif ep['eptype'] == "Trailer": season = -2; try: season = int(ep['season'].split('x')[0]) + if season <= 0 and ep['eptype'] == 'Episode': season = 1 + elif season > 0 and ep['eptype'] == 'Special': season = 0 except: pass @@ -235,7 +240,7 @@ def update(self, metadata, media, lang, force): self.Update(metadata, media, lan class ShokoMovieAgent(Agent.Movies, ShokoCommonAgent): name, primary_provider, fallback_agent, contributes_to, languages, accepts_from = ( - 'ShokoMovies', True, False, ['com.plexapp.agents.hama'], [Locale.Language.English, ], + 'ShokoMovies', True, False, ['com.plexapp.agents.hama'], [Locale.Language.English, 'fr', 'zh', 'sv', 'no', 'da', 'fi', 'nl', 'de', 'it', 'es', 'pl', 'hu', 'el', 'tr', 'ru', 'he', 'ja', 'pt', 'cs', 'ko', 'sl', 'hr'], ['com.plexapp.agents.localmedia']) # , 'com.plexapp.agents.opensubtitles' def search(self, results, media, lang, manual): self.Search(results, media, lang, manual, True) diff --git a/Contents/Resources/Movies/Shoko Movie Scanner.py b/Contents/Resources/Movies/Shoko Movie Scanner.py index 70f683f..4517498 100644 --- a/Contents/Resources/Movies/Shoko Movie Scanner.py +++ b/Contents/Resources/Movies/Shoko Movie Scanner.py @@ -79,14 +79,26 @@ def Scan(path, files, mediaList, subdirs, language=None, root=None): if (try_get(episode_data, "code", 200) == 404): break series_data = HttpReq("api/serie/fromep?id=%d&nocast=1¬ag=1" % episode_data['id']) - if (series_data["ismovie"] == 0): - continue showTitle = series_data['name'].encode("utf-8") #no idea why I need to do this. log('Scan', 'show title: %s', showTitle) seasonYear = episode_data['year'] log('Scan', 'season year: %s', seasonYear) - + seasonNumber = 0 + seasonStr = try_get(episode_data, 'season', None) + if episode_data['eptype'] == 'Credits': seasonNumber = -1 #season -1 for OP/ED + elif episode_data['eptype'] == 'Trailer': seasonNumber = -2 #season -2 for Trailer + elif seasonStr == None: + if episode_data['eptype'] == 'Episode': seasonNumber = 1 + elif episode_data['eptype'] == 'Special': seasonNumber = 0 + else: + seasonNumber = int(seasonStr.split('x')[0]) + if seasonNumber <= 0 and episode_data['eptype'] == 'Episode': seasonNumber = 1 + + if seasonNumber <= 0 and Prefs['IncludeOther'] == False: continue #Ignore this by choice. + + if (series_data["ismovie"] == 0 or seasonNumber <= 0): + continue vid = Media.Movie(showTitle, int(seasonYear)) log('Scan', 'vid: %s', vid) vid.parts.append(file) diff --git a/Contents/Resources/Series/Shoko Series Scanner.py b/Contents/Resources/Series/Shoko Series Scanner.py index 076a376..eb9ef1e 100644 --- a/Contents/Resources/Series/Shoko Series Scanner.py +++ b/Contents/Resources/Series/Shoko Series Scanner.py @@ -109,30 +109,33 @@ def Scan(path, files, mediaList, subdirs, language=None, root=None): # 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?filename=%s" % (urllib.quote(os.path.basename(file)))) - if len(episode_data) == 0: break - if (try_get(episode_data, "code", 200) == 404): break + if len(episode_data) == 0: continue + if (try_get(episode_data, "code", 200) == 404): continue series_data = HttpReq("api/serie/fromep?id=%d&nocast=1¬ag=1" % episode_data['id']) - if (series_data["ismovie"] == 1): break # Ignore movies in preference for Shoko Movie Scanner showTitle = series_data['name'].encode("utf-8") #no idea why I need to do this. Log.info('show title: %s', showTitle) seasonNumber = 0 seasonStr = try_get(episode_data, 'season', None) - if seasonStr == None: + if episode_data['eptype'] == 'Credits': seasonNumber = -1 #season -1 for OP/ED + elif episode_data['eptype'] == 'Trailer': seasonNumber = -2 #season -2 for Trailer + elif seasonStr == None: if episode_data['eptype'] == 'Episode': seasonNumber = 1 - if episode_data['eptype'] == 'Credits': seasonNumber = -1 #season -1 for OP/ED + elif episode_data['eptype'] == 'Special': seasonNumber = 0 else: - seasonNumber = seasonStr.split('x')[0] - - if seasonNumber <= 0 and Prefs['IncludeOther'] == False: break #Ignore this by choice. - - + seasonNumber = int(seasonStr.split('x')[0]) + if seasonNumber <= 0 and episode_data['eptype'] == 'Episode': seasonNumber = 1 + elif seasonNumber > 0 and episode_data['eptype'] == 'Special': seasonNumber = 0 + + if seasonNumber <= 0 and Prefs['IncludeOther'] == False: continue #Ignore this by choice. + + if (series_data["ismovie"] == 1 and seasonNumber >= 1): continue # Ignore movies in preference for Shoko Movie Scanner, but keep specials as Plex sees specials as duplicate Log.info('season number: %s', seasonNumber) episodeNumber = int(episode_data['epnumber']) Log.info('episode number: %s', episodeNumber) - - vid = Media.Episode(showTitle, int(seasonNumber), episodeNumber) + + vid = Media.Episode(showTitle, seasonNumber, episodeNumber) Log.info('vid: %s', vid) vid.parts.append(file) mediaList.append(vid) From 451b11cb184406cf6dba66352a37a61e17447634 Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Mon, 19 Feb 2018 19:25:33 +1100 Subject: [PATCH 3/4] Add support for collections --- Contents/Code/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 6e360f7..7768f86 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -122,6 +122,16 @@ def Update(self, metadata, media, lang, force, movie): self.metadata_add(metadata.posters, series['art']['thumb']) self.metadata_add(metadata.art, series['art']['fanart']) + groupinfo = HttpReq("api/serie/groups?id=%s&level=2" % aid); + collections = [] + for group in groupinfo: + if (len(group['series']) > 1): + collections.append(group['name']) + + metadata.collections = collections + + + ### Generate general content ratings. ### VERY rough approximation to: https://www.healthychildren.org/English/family-life/Media/Pages/TV-Ratings-A-Guide-for-Parents.aspx From e3d6d8e25165d02a1541cc1a0ca640660c47a6a7 Mon Sep 17 00:00:00 2001 From: Cayde Dixon Date: Thu, 22 Feb 2018 15:02:40 +1100 Subject: [PATCH 4/4] Ignore "Episode Overview not Available" --- Contents/Code/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 7768f86..e120d0f 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -189,7 +189,8 @@ def Update(self, metadata, media, lang, force, movie): episodeObj = metadata.seasons[season].episodes[ep['epnumber']] episodeObj.title = ep['name'] - episodeObj.summary = ep['summary'] + if (ep['summary'] != "Episode Overview not Available"): + episodeObj.summary = ep['summary'] Log("" + str(ep['epnumber']) + ": " + ep['summary']) if ep['air'] != '1/01/0001 12:00:00 AM' and ep['air'] != '0001-01-01':