Skip to content

Commit

Permalink
V 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Cazzar authored Aug 7, 2018
2 parents 7bfb2c9 + e3d6d8e commit ab2e594
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 26 deletions.
37 changes: 26 additions & 11 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -163,28 +173,31 @@ 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

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':
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)

Expand All @@ -202,6 +215,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), '')
Expand Down Expand Up @@ -236,7 +251,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)
Expand Down
18 changes: 15 additions & 3 deletions Contents/Resources/Movies/Shoko Movie Scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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&notag=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)
Expand Down
27 changes: 15 additions & 12 deletions Contents/Resources/Series/Shoko Series Scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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&notag=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)
Expand Down

0 comments on commit ab2e594

Please sign in to comment.