Skip to content

Commit

Permalink
Merge pull request #6 from Cazzar/devel
Browse files Browse the repository at this point in the history
1.0.1
  • Loading branch information
Cazzar authored Mar 12, 2017
2 parents 67a250c + 266702b commit 790a8e8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 246 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tags"]
path = Contents/Code/tags
url = https://github.com/bigretromike/nakamori.tags.git
231 changes: 0 additions & 231 deletions Contents/Code/TagBlacklist.py

This file was deleted.

23 changes: 13 additions & 10 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os, re, time, string, thread, threading, urllib, copy
from lxml import etree
from datetime import datetime
import TagBlacklist
import tags as TagBlacklist

API_KEY = ''
PLEX_HOST = ''
Expand Down Expand Up @@ -74,15 +74,22 @@ def Update(self, metadata, media, lang, force, movie):
series = HttpReq("api/serie?id=%s&level=3" % aid)

# build metadata on the TV show.
metadata.summary = series['summary']
metadata.summary = try_get(series, 'summary')
metadata.title = series['name']
metadata.rating = float(series['rating'])

tags = []
for tag in series['tags']:
tags.append(tag['tag'])

TagBlacklist.processTags(tags)
flags = 0
flags = flags | Prefs['hideMiscTags'] << 0 #0b00001 : Hide AniDB Internal Tags
flags = flags | Prefs['hideArtTags'] << 1 #0b00010 : Hide Art Style Tags
flags = flags | Prefs['hideSourceTags'] << 2 #0b00100 : Hide Source Work Tags
flags = flags | Prefs['hideUsefulMiscTags'] << 3 #0b01000 : Hide Useful Miscellaneous Tags
flags = flags | Prefs['hideSpoilerTags'] << 4 #0b10000 : Hide Plot Spoiler Tags

TagBlacklist.processTags(flags, tags)

metadata.genres = tags

Expand Down Expand Up @@ -125,10 +132,6 @@ 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' and t['language'] == 'ja'):
metadata.original_title = t['title']


if not movie:
for ep in series['eps']:
Expand All @@ -153,11 +156,11 @@ def Update(self, metadata, media, lang, force, movie):
episodeObj.thumbs[art['url']] = Proxy.Media(HTTP.Request(art['url']).content, art['index'])


def try_to_remove(arr, val):
def try_get(arr, idx, default=""):
try:
arr.remove(val)
return arr[idx]
except:
pass
return default


class ShokoTVAgent(Agent.TV_Shows, ShokoCommonAgent):
Expand Down
1 change: 1 addition & 0 deletions Contents/Code/tags
Submodule tags added at fdac0c
2 changes: 1 addition & 1 deletion Contents/DefaultPrefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"id": "Fuzzy",
"label": "Use fuzzy searching in Shoko for matching the titles.",
"type": "bool",
"default": false
"default": true
},

{
Expand Down
17 changes: 13 additions & 4 deletions Contents/Resources/Series/Shoko Series Scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,19 @@ def Scan(path, files, mediaList, subdirs, language=None, root=None):

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

series_data = HttpReq("api/serie/fromep?id=%d&nocast=1&notag=1" % episode_data['id'])
showTitle = str(series_data['name']) #no idea why I need to do this.
showTitle = series_data['name'].encode("utf-8") #no idea why I need to do this.
log('Scan', 'show title: %s', showTitle)

seasonNumber = 0
if episode_data['season'] == None:
seasonStr = try_get(episode_data, 'season', None)
if seasonStr == None:
if episode_data['eptype'] == 'Episode': seasonNumber = 1
if episode_data['eptype'] == 'Credits': seasonNumber = -1 #season -1 for OP/ED
else:
seasonNumber = episode_data['season'].split('x')[0]
seasonNumber = seasonStr.split('x')[0]

if seasonNumber <= 0 and Prefs['IncludeOther'] == False: break #Ignore this by choice.

Expand All @@ -102,7 +104,7 @@ def Scan(path, files, mediaList, subdirs, language=None, root=None):

log('Scan', 'episode number: %s', episodeNumber)

episodeTitle = str(episode_data['name'])
episodeTitle = episode_data['name'].encode("utf-8")
log('Scan', 'episode title: %s', episodeTitle)

vid = Media.Episode(showTitle, int(seasonNumber), episodeNumber , episodeTitle, int(seasonYear))
Expand All @@ -113,3 +115,10 @@ def Scan(path, files, mediaList, subdirs, language=None, root=None):
log('Scan', 'stack media')
Stack.Scan(path, files, mediaList, subdirs)
log('Scan', 'media list %s', mediaList)


def try_get(arr, idx, default=""):
try:
return arr[idx]
except:
return default

0 comments on commit 790a8e8

Please sign in to comment.