Re-introduce dependency add-ons, part 1
We need them in order to keep the Kodi DB straight
This commit is contained in:
parent
faacbc6108
commit
be5c1e6b8a
5 changed files with 67 additions and 73 deletions
|
@ -3,6 +3,8 @@
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.1.0"/>
|
<import addon="xbmc.python" version="2.1.0"/>
|
||||||
<import addon="script.module.requests" version="2.3.0" />
|
<import addon="script.module.requests" version="2.3.0" />
|
||||||
|
<import addon="plugin.video.plexkodiconnect.movies" version="2.0.0" />
|
||||||
|
<import addon="plugin.video.plexkodiconnect.tvshows" version="2.0.0" />
|
||||||
</requires>
|
</requires>
|
||||||
<extension point="xbmc.python.pluginsource" library="default.py">
|
<extension point="xbmc.python.pluginsource" library="default.py">
|
||||||
<provides>video audio image</provides>
|
<provides>video audio image</provides>
|
||||||
|
|
|
@ -259,7 +259,7 @@ class Movies(Items):
|
||||||
|
|
||||||
trailer = api.trailer_id()
|
trailer = api.trailer_id()
|
||||||
if trailer:
|
if trailer:
|
||||||
trailer = ('plugin://%s/movies/?plex_id=%s&plex_type=%s&mode=play'
|
trailer = ('plugin://%s.movies/?plex_id=%s&plex_type=%s&mode=play'
|
||||||
% (v.ADDON_ID, trailer, v.PLEX_TYPE_CLIP))
|
% (v.ADDON_ID, trailer, v.PLEX_TYPE_CLIP))
|
||||||
|
|
||||||
# GET THE FILE AND PATH #####
|
# GET THE FILE AND PATH #####
|
||||||
|
@ -283,7 +283,7 @@ class Movies(Items):
|
||||||
path = playurl.replace(filename, "")
|
path = playurl.replace(filename, "")
|
||||||
if do_indirect:
|
if do_indirect:
|
||||||
# Set plugin path and media flags using real filename
|
# Set plugin path and media flags using real filename
|
||||||
path = 'plugin://%s/movies/' % v.ADDON_ID
|
path = 'plugin://%s.movies/' % v.ADDON_ID
|
||||||
params = {
|
params = {
|
||||||
'mode': 'play',
|
'mode': 'play',
|
||||||
'plex_id': itemid,
|
'plex_id': itemid,
|
||||||
|
@ -588,7 +588,7 @@ class TVShows(Items):
|
||||||
toplevelpath = "%s/" % dirname(dirname(path))
|
toplevelpath = "%s/" % dirname(dirname(path))
|
||||||
if do_indirect:
|
if do_indirect:
|
||||||
# Set plugin path
|
# Set plugin path
|
||||||
toplevelpath = "plugin://%s/tvshows/" % v.ADDON_ID
|
toplevelpath = "plugin://%s.tvshows/" % v.ADDON_ID
|
||||||
path = "%s%s/" % (toplevelpath, itemid)
|
path = "%s%s/" % (toplevelpath, itemid)
|
||||||
|
|
||||||
# Add top path
|
# Add top path
|
||||||
|
@ -910,7 +910,7 @@ class TVShows(Items):
|
||||||
filename = playurl.rsplit('/', 1)[1]
|
filename = playurl.rsplit('/', 1)[1]
|
||||||
else:
|
else:
|
||||||
filename = 'file_not_found.mkv'
|
filename = 'file_not_found.mkv'
|
||||||
path = 'plugin://%s/tvshows/%s/' % (v.ADDON_ID, series_id)
|
path = 'plugin://%s.tvshows/%s/' % (v.ADDON_ID, series_id)
|
||||||
params = {
|
params = {
|
||||||
'plex_id': itemid,
|
'plex_id': itemid,
|
||||||
'plex_type': v.PLEX_TYPE_EPISODE,
|
'plex_type': v.PLEX_TYPE_EPISODE,
|
||||||
|
@ -918,7 +918,7 @@ class TVShows(Items):
|
||||||
}
|
}
|
||||||
filename = "%s?%s" % (path, urlencode(params))
|
filename = "%s?%s" % (path, urlencode(params))
|
||||||
playurl = filename
|
playurl = filename
|
||||||
parent_path_id = self.kodi_db.addPath('plugin://%s/tvshows/'
|
parent_path_id = self.kodi_db.addPath('plugin://%s.tvshows/'
|
||||||
% v.ADDON_ID)
|
% v.ADDON_ID)
|
||||||
|
|
||||||
# add/retrieve pathid and fileid
|
# add/retrieve pathid and fileid
|
||||||
|
@ -1101,7 +1101,7 @@ class TVShows(Items):
|
||||||
if not state.DIRECT_PATHS and resume:
|
if not state.DIRECT_PATHS and resume:
|
||||||
# Create additional entry for widgets. This is only required for
|
# Create additional entry for widgets. This is only required for
|
||||||
# plugin/episode.
|
# plugin/episode.
|
||||||
temppathid = self.kodi_db.getPath('plugin://%s/tvshows/'
|
temppathid = self.kodi_db.getPath('plugin://%s.tvshows/'
|
||||||
% v.ADDON_ID)
|
% v.ADDON_ID)
|
||||||
tempfileid = self.kodi_db.addFile(filename, temppathid)
|
tempfileid = self.kodi_db.addFile(filename, temppathid)
|
||||||
query = '''
|
query = '''
|
||||||
|
|
|
@ -53,48 +53,30 @@ class Kodidb_Functions():
|
||||||
For some reason, Kodi ignores this if done via itemtypes while e.g.
|
For some reason, Kodi ignores this if done via itemtypes while e.g.
|
||||||
adding or updating items. (addPath method does NOT work)
|
adding or updating items. (addPath method does NOT work)
|
||||||
"""
|
"""
|
||||||
root_path_id = self.getPath('plugin://%s/' % v.ADDON_ID)
|
path_id = self.getPath('plugin://%s.movies/' % v.ADDON_ID)
|
||||||
if root_path_id is not None:
|
if path_id is None:
|
||||||
return
|
|
||||||
# add the very root plugin://plugin.video.plexkodiconnect to paths
|
|
||||||
self.cursor.execute("select coalesce(max(idPath),0) from path")
|
self.cursor.execute("select coalesce(max(idPath),0) from path")
|
||||||
root_path_id = self.cursor.fetchone()[0] + 1
|
path_id = self.cursor.fetchone()[0] + 1
|
||||||
query = '''
|
query = '''
|
||||||
INSERT INTO path(idPath,
|
INSERT INTO path(idPath,
|
||||||
strPath,
|
strPath,
|
||||||
|
strContent,
|
||||||
|
strScraper,
|
||||||
useFolderNames,
|
useFolderNames,
|
||||||
noUpdate,
|
noUpdate,
|
||||||
exclude)
|
exclude)
|
||||||
VALUES (?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
'''
|
|
||||||
self.cursor.execute(query, (root_path_id,
|
|
||||||
'plugin://%s/' % v.ADDON_ID,
|
|
||||||
False,
|
|
||||||
True,
|
|
||||||
True))
|
|
||||||
# Now add the root folders for movies
|
|
||||||
self.cursor.execute("select coalesce(max(idPath),0) from path")
|
|
||||||
path_id = self.cursor.fetchone()[0] + 1
|
|
||||||
query = '''
|
|
||||||
INSERT INTO path(idPath,
|
|
||||||
strPath,
|
|
||||||
strContent,
|
|
||||||
strScraper,
|
|
||||||
useFolderNames,
|
|
||||||
noUpdate,
|
|
||||||
exclude,
|
|
||||||
idParentPath)
|
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
||||||
'''
|
'''
|
||||||
self.cursor.execute(query, (path_id,
|
self.cursor.execute(query, (path_id,
|
||||||
'plugin://%s/movies/' % v.ADDON_ID,
|
'plugin://%s.movies/' % v.ADDON_ID,
|
||||||
'movies',
|
'movies',
|
||||||
'metadata.local',
|
'metadata.local',
|
||||||
False,
|
0,
|
||||||
True,
|
1,
|
||||||
True,
|
1))
|
||||||
root_path_id))
|
|
||||||
# And TV shows
|
# And TV shows
|
||||||
|
path_id = self.getPath('plugin://%s.tvshows/' % v.ADDON_ID)
|
||||||
|
if path_id is None:
|
||||||
self.cursor.execute("select coalesce(max(idPath),0) from path")
|
self.cursor.execute("select coalesce(max(idPath),0) from path")
|
||||||
path_id = self.cursor.fetchone()[0] + 1
|
path_id = self.cursor.fetchone()[0] + 1
|
||||||
query = '''
|
query = '''
|
||||||
|
@ -104,18 +86,16 @@ class Kodidb_Functions():
|
||||||
strScraper,
|
strScraper,
|
||||||
useFolderNames,
|
useFolderNames,
|
||||||
noUpdate,
|
noUpdate,
|
||||||
exclude,
|
exclude)
|
||||||
idParentPath)
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
||||||
'''
|
'''
|
||||||
self.cursor.execute(query, (path_id,
|
self.cursor.execute(query, (path_id,
|
||||||
'plugin://%s/tvshows/' % v.ADDON_ID,
|
'plugin://%s.tvshows/' % v.ADDON_ID,
|
||||||
'tvshows',
|
'tvshows',
|
||||||
'metadata.local',
|
'metadata.local',
|
||||||
False,
|
0,
|
||||||
True,
|
1,
|
||||||
True,
|
1))
|
||||||
root_path_id))
|
|
||||||
|
|
||||||
def getParentPathId(self, path):
|
def getParentPathId(self, path):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -164,8 +164,15 @@ def _prep_playlist_stack(xml):
|
||||||
'plex_id': api.plex_id(),
|
'plex_id': api.plex_id(),
|
||||||
'plex_type': api.plex_type()
|
'plex_type': api.plex_type()
|
||||||
}
|
}
|
||||||
path = ('plugin://plugin.video.plexkodiconnect?%s'
|
if api.plex_type() == v.PLEX_TYPE_EPISODE:
|
||||||
% urlencode(params))
|
path = ('plugin://%s/%s/?%s'
|
||||||
|
% (v.ADDON_TYPE[api.plex_type()],
|
||||||
|
api.grandparent_id(),
|
||||||
|
urlencode(params)))
|
||||||
|
else:
|
||||||
|
path = ('plugin://%s/?%s'
|
||||||
|
% (v.ADDON_TYPE[api.plex_type()],
|
||||||
|
urlencode(params)))
|
||||||
listitem = api.create_listitem()
|
listitem = api.create_listitem()
|
||||||
listitem.setPath(try_encode(path))
|
listitem.setPath(try_encode(path))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -171,9 +171,6 @@ KODI_TYPE_MUSICVIDEO = 'musicvideo'
|
||||||
|
|
||||||
KODI_TYPE_PHOTO = 'photo'
|
KODI_TYPE_PHOTO = 'photo'
|
||||||
|
|
||||||
|
|
||||||
# Translation tables
|
|
||||||
|
|
||||||
KODI_VIDEOTYPES = (
|
KODI_VIDEOTYPES = (
|
||||||
KODI_TYPE_VIDEO,
|
KODI_TYPE_VIDEO,
|
||||||
KODI_TYPE_MOVIE,
|
KODI_TYPE_MOVIE,
|
||||||
|
@ -189,6 +186,14 @@ KODI_AUDIOTYPES = (
|
||||||
KODI_TYPE_ARTIST,
|
KODI_TYPE_ARTIST,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Translation tables
|
||||||
|
|
||||||
|
ADDON_TYPE = {
|
||||||
|
PLEX_TYPE_MOVIE: 'plugin.video.plexkodiconnect.movies',
|
||||||
|
PLEX_TYPE_CLIP: 'plugin.video.plexkodiconnect.movies',
|
||||||
|
PLEX_TYPE_EPISODE: 'plugin.video.plexkodiconnect.tvshows'
|
||||||
|
}
|
||||||
|
|
||||||
ITEMTYPE_FROM_PLEXTYPE = {
|
ITEMTYPE_FROM_PLEXTYPE = {
|
||||||
PLEX_TYPE_MOVIE: 'Movies',
|
PLEX_TYPE_MOVIE: 'Movies',
|
||||||
PLEX_TYPE_SEASON: 'TVShows',
|
PLEX_TYPE_SEASON: 'TVShows',
|
||||||
|
|
Loading…
Reference in a new issue