videonodes v0.1
This commit is contained in:
parent
388e8e36e9
commit
c854ee621e
4 changed files with 53 additions and 74 deletions
|
@ -1594,12 +1594,16 @@ class API():
|
||||||
"""
|
"""
|
||||||
item = self.item
|
item = self.item
|
||||||
item = item[self.child].attrib
|
item = item[self.child].attrib
|
||||||
regex = re.compile(r'''com.plexapp.agents.(.+)$''')
|
try:
|
||||||
|
item = item['guid']
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
provider = regex.findall(item['guid'])
|
regex = re.compile(r'''com\.plexapp\.agents\.(.+)$''')
|
||||||
|
provider = regex.findall(item)
|
||||||
try:
|
try:
|
||||||
provider = provider[0]
|
provider = provider[0]
|
||||||
except KeyError:
|
except IndexError:
|
||||||
provider = None
|
provider = None
|
||||||
return provider
|
return provider
|
||||||
|
|
||||||
|
@ -1662,7 +1666,7 @@ class API():
|
||||||
item = item[self.child].attrib
|
item = item[self.child].attrib
|
||||||
try:
|
try:
|
||||||
rating = item['audienceRating']
|
rating = item['audienceRating']
|
||||||
except:
|
except KeyError:
|
||||||
rating = None
|
rating = None
|
||||||
return rating
|
return rating
|
||||||
|
|
||||||
|
@ -1674,7 +1678,7 @@ class API():
|
||||||
item = item[self.child].attrib
|
item = item[self.child].attrib
|
||||||
try:
|
try:
|
||||||
year = item['year']
|
year = item['year']
|
||||||
except:
|
except KeyError:
|
||||||
year = None
|
year = None
|
||||||
return year
|
return year
|
||||||
|
|
||||||
|
|
|
@ -333,6 +333,7 @@ class Movies(Items):
|
||||||
shortplot = None
|
shortplot = None
|
||||||
tagline = API.getTagline()
|
tagline = API.getTagline()
|
||||||
votecount = None
|
votecount = None
|
||||||
|
|
||||||
rating = API.getAudienceRating()
|
rating = API.getAudienceRating()
|
||||||
year = API.getYear()
|
year = API.getYear()
|
||||||
imdb = API.getProvider('Imdb')
|
imdb = API.getProvider('Imdb')
|
||||||
|
@ -346,9 +347,11 @@ class Movies(Items):
|
||||||
studio = studios[0]
|
studio = studios[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
studio = None
|
studio = None
|
||||||
|
self.logMsg("Retrieved metadata for %s" % itemid, 2)
|
||||||
|
|
||||||
# TODO: trailers
|
# TODO: trailers
|
||||||
trailer = None
|
trailer = None
|
||||||
|
self.logMsg("Retrieved trailer for %s" % itemid, 2)
|
||||||
|
|
||||||
##### GET THE FILE AND PATH #####
|
##### GET THE FILE AND PATH #####
|
||||||
playurl = API.getFilePath()
|
playurl = API.getFilePath()
|
||||||
|
|
|
@ -346,10 +346,11 @@ class LibrarySync(threading.Thread):
|
||||||
|
|
||||||
starttotal = datetime.now()
|
starttotal = datetime.now()
|
||||||
|
|
||||||
# Set views
|
# Ensure that DBs exist if called for very first time
|
||||||
# self.maintainViews(embycursor, kodicursor)
|
|
||||||
# embyconn.commit()
|
|
||||||
self.initializeDBs()
|
self.initializeDBs()
|
||||||
|
# Set views
|
||||||
|
self.maintainViews()
|
||||||
|
|
||||||
# Sync video library
|
# Sync video library
|
||||||
# process = {
|
# process = {
|
||||||
|
|
||||||
|
@ -362,7 +363,6 @@ class LibrarySync(threading.Thread):
|
||||||
process = {
|
process = {
|
||||||
'movies': self.PlexMovies,
|
'movies': self.PlexMovies,
|
||||||
'tvshows': self.PlexTVShows
|
'tvshows': self.PlexTVShows
|
||||||
# 'tvshows': self.PlexTVShows
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for itemtype in process:
|
for itemtype in process:
|
||||||
|
@ -420,79 +420,46 @@ class LibrarySync(threading.Thread):
|
||||||
sound=False)
|
sound=False)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def maintainViews(self):
|
||||||
def refreshViews(self):
|
|
||||||
|
|
||||||
embyconn = utils.kodiSQL('emby')
|
|
||||||
embycursor = embyconn.cursor()
|
|
||||||
kodiconn = utils.kodiSQL('video')
|
|
||||||
kodicursor = kodiconn.cursor()
|
|
||||||
|
|
||||||
# Compare views, assign correct tags to items
|
|
||||||
self.maintainViews(embycursor, kodicursor)
|
|
||||||
|
|
||||||
self.dbCommit(kodiconn)
|
|
||||||
kodicursor.close()
|
|
||||||
|
|
||||||
embyconn.commit()
|
|
||||||
embycursor.close()
|
|
||||||
|
|
||||||
def maintainViews(self, embycursor, kodicursor):
|
|
||||||
"""
|
"""
|
||||||
Reverse engineering:
|
Compare the views to Plex
|
||||||
|
|
||||||
Input:
|
|
||||||
embycursor
|
|
||||||
kodicursor
|
|
||||||
Output:
|
Output:
|
||||||
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype)
|
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype)
|
||||||
kodi_db.createTag(foldername)
|
kodi_db.createTag(foldername)
|
||||||
kodi_db.updateTag(current_tagid, tagid, item[0],Current_viewtype[:-1])
|
kodi_db.updateTag(current_tagid, tagid, item[0],Current_viewtype[:-1])
|
||||||
"""
|
"""
|
||||||
# Compare the views to emby
|
# Open DB links
|
||||||
|
embyconn = utils.kodiSQL('emby')
|
||||||
|
embycursor = embyconn.cursor()
|
||||||
|
kodiconn = utils.kodiSQL('video')
|
||||||
|
kodicursor = kodiconn.cursor()
|
||||||
|
|
||||||
emby_db = embydb.Embydb_Functions(embycursor)
|
emby_db = embydb.Embydb_Functions(embycursor)
|
||||||
kodi_db = kodidb.Kodidb_Functions(kodicursor)
|
kodi_db = kodidb.Kodidb_Functions(kodicursor)
|
||||||
doUtils = self.doUtils
|
doUtils = self.doUtils
|
||||||
vnodes = self.vnodes
|
vnodes = self.vnodes
|
||||||
|
|
||||||
# Get views
|
|
||||||
url = "{server}/emby/Users/{UserId}/Views?format=json"
|
|
||||||
result = doUtils.downloadUrl(url)
|
|
||||||
grouped_views = result['Items']
|
|
||||||
|
|
||||||
try:
|
# Get views
|
||||||
groupedFolders = self.user.userSettings['Configuration']['GroupedFolders']
|
url = "{server}/library/sections"
|
||||||
except TypeError:
|
result = doUtils.downloadUrl(url)
|
||||||
url = "{server}/emby/Users/{UserId}?format=json"
|
result = result['_children']
|
||||||
result = doUtils.downloadUrl(url)
|
|
||||||
groupedFolders = result['Configuration']['GroupedFolders']
|
|
||||||
|
|
||||||
# total nodes for window properties
|
# total nodes for window properties
|
||||||
vnodes.clearProperties()
|
vnodes.clearProperties()
|
||||||
totalnodes = 0
|
totalnodes = 0
|
||||||
|
|
||||||
# Set views for supported media type
|
# Set views for supported media type
|
||||||
mediatypes = ['movies', 'tvshows', 'musicvideos', 'homevideos', 'music']
|
mediatypes = [
|
||||||
for mediatype in mediatypes:
|
'movie',
|
||||||
|
'show'
|
||||||
# Get media folders from server
|
]
|
||||||
folders = self.emby.getViews(mediatype, root=True)
|
for folder in result:
|
||||||
for folder in folders:
|
mediatype = folder['type']
|
||||||
|
if mediatype in mediatypes:
|
||||||
folderid = folder['id']
|
folderid = folder['key']
|
||||||
foldername = folder['name']
|
foldername = folder['title']
|
||||||
viewtype = folder['type']
|
viewtype = folder['type']
|
||||||
|
|
||||||
if folderid in groupedFolders:
|
|
||||||
# Media folders are grouped into userview
|
|
||||||
for grouped_view in grouped_views:
|
|
||||||
# This is only reserved for the detection of grouped views
|
|
||||||
if (grouped_view['Type'] == "UserView" and
|
|
||||||
grouped_view.get('CollectionType') == mediatype and
|
|
||||||
grouped_view['Id'] not in grouped_view.get('Path', "")):
|
|
||||||
# Take the name of the userview
|
|
||||||
foldername = grouped_view['Name']
|
|
||||||
break
|
|
||||||
|
|
||||||
# Get current media folders from emby database
|
# Get current media folders from emby database
|
||||||
view = emby_db.getView_byId(folderid)
|
view = emby_db.getView_byId(folderid)
|
||||||
|
@ -567,14 +534,19 @@ class LibrarySync(threading.Thread):
|
||||||
totalnodes += 1
|
totalnodes += 1
|
||||||
else:
|
else:
|
||||||
# Add video nodes listings
|
# Add video nodes listings
|
||||||
vnodes.singleNode(totalnodes, "Favorite movies", "movies", "favourites")
|
# vnodes.singleNode(totalnodes, "Favorite movies", "movies", "favourites")
|
||||||
totalnodes += 1
|
# totalnodes += 1
|
||||||
vnodes.singleNode(totalnodes, "Favorite tvshows", "tvshows", "favourites")
|
# vnodes.singleNode(totalnodes, "Favorite tvshows", "tvshows", "favourites")
|
||||||
totalnodes += 1
|
# totalnodes += 1
|
||||||
vnodes.singleNode(totalnodes, "channels", "movies", "channels")
|
# vnodes.singleNode(totalnodes, "channels", "movies", "channels")
|
||||||
totalnodes += 1
|
# totalnodes += 1
|
||||||
# Save total
|
# Save total
|
||||||
utils.window('Emby.nodes.total', str(totalnodes))
|
utils.window('Emby.nodes.total', str(totalnodes))
|
||||||
|
# commit changes to DB
|
||||||
|
embyconn.commit()
|
||||||
|
kodiconn.commit()
|
||||||
|
embyconn.close()
|
||||||
|
kodiconn.close()
|
||||||
|
|
||||||
def GetUpdatelist(self, elementList, itemType, method, viewName, viewId):
|
def GetUpdatelist(self, elementList, itemType, method, viewName, viewId):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -93,7 +93,7 @@ class VideoNodes(object):
|
||||||
# Create index entry
|
# Create index entry
|
||||||
nodeXML = "%sindex.xml" % nodepath
|
nodeXML = "%sindex.xml" % nodepath
|
||||||
# Set windows property
|
# Set windows property
|
||||||
path = "library://video/Emby - %s/" % dirname
|
path = "library://video/plexkodiconnect - %s/" % dirname
|
||||||
for i in range(1, indexnumber):
|
for i in range(1, indexnumber):
|
||||||
# Verify to make sure we don't create duplicates
|
# Verify to make sure we don't create duplicates
|
||||||
if utils.window('Emby.nodes.%s.index' % i) == path:
|
if utils.window('Emby.nodes.%s.index' % i) == path:
|
||||||
|
@ -124,7 +124,7 @@ class VideoNodes(object):
|
||||||
}
|
}
|
||||||
mediatypes = {
|
mediatypes = {
|
||||||
# label according to nodetype per mediatype
|
# label according to nodetype per mediatype
|
||||||
'movies': {
|
'movie': {
|
||||||
'1': tagname,
|
'1': tagname,
|
||||||
'2': 30174,
|
'2': 30174,
|
||||||
'4': 30177,
|
'4': 30177,
|
||||||
|
@ -134,7 +134,7 @@ class VideoNodes(object):
|
||||||
'10': 30229,
|
'10': 30229,
|
||||||
'11': 30230},
|
'11': 30230},
|
||||||
|
|
||||||
'tvshows': {
|
'show': {
|
||||||
'1': tagname,
|
'1': tagname,
|
||||||
'2': 30170,
|
'2': 30170,
|
||||||
'3': 30175,
|
'3': 30175,
|
||||||
|
@ -171,7 +171,7 @@ class VideoNodes(object):
|
||||||
# Custom query
|
# Custom query
|
||||||
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=inprogressepisodes&limit=25"% tagname
|
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=inprogressepisodes&limit=25"% tagname
|
||||||
else:
|
else:
|
||||||
path = "library://video/Emby - %s/%s_%s.xml" % (dirname, cleantagname, nodetype)
|
path = "library://video/plexkodiconnect - %s/%s_%s.xml" % (dirname, cleantagname, nodetype)
|
||||||
windowpath = "ActivateWindow(Video,%s,return)" % path
|
windowpath = "ActivateWindow(Video,%s,return)" % path
|
||||||
|
|
||||||
if nodetype == "all":
|
if nodetype == "all":
|
||||||
|
@ -276,7 +276,7 @@ class VideoNodes(object):
|
||||||
cleantagname = utils.normalize_nodes(tagname)
|
cleantagname = utils.normalize_nodes(tagname)
|
||||||
nodepath = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
|
nodepath = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
|
||||||
nodeXML = "%semby_%s.xml" % (nodepath, cleantagname)
|
nodeXML = "%semby_%s.xml" % (nodepath, cleantagname)
|
||||||
path = "library://video/emby_%s.xml" % (cleantagname)
|
path = "library://video/plexkodiconnect_%s.xml" % (cleantagname)
|
||||||
windowpath = "ActivateWindow(Video,%s,return)" % path
|
windowpath = "ActivateWindow(Video,%s,return)" % path
|
||||||
|
|
||||||
# Create the video node directory
|
# Create the video node directory
|
||||||
|
|
Loading…
Reference in a new issue