Re-introduce dependency add-ons, part 1

We need them in order to keep the Kodi DB straight
This commit is contained in:
croneter 2018-02-21 20:24:31 +01:00
parent faacbc6108
commit be5c1e6b8a
5 changed files with 67 additions and 73 deletions

View file

@ -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>

View file

@ -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 = '''

View file

@ -53,69 +53,49 @@ 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 self.cursor.execute("select coalesce(max(idPath),0) from path")
# add the very root plugin://plugin.video.plexkodiconnect to paths path_id = self.cursor.fetchone()[0] + 1
self.cursor.execute("select coalesce(max(idPath),0) from path") query = '''
root_path_id = self.cursor.fetchone()[0] + 1 INSERT INTO path(idPath,
query = ''' strPath,
INSERT INTO path(idPath, strContent,
strPath, strScraper,
useFolderNames, useFolderNames,
noUpdate, noUpdate,
exclude) exclude)
VALUES (?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?)
''' '''
self.cursor.execute(query, (root_path_id, self.cursor.execute(query, (path_id,
'plugin://%s/' % v.ADDON_ID, 'plugin://%s.movies/' % v.ADDON_ID,
False, 'movies',
True, 'metadata.local',
True)) 0,
# Now add the root folders for movies 1,
self.cursor.execute("select coalesce(max(idPath),0) from path") 1))
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,
'plugin://%s/movies/' % v.ADDON_ID,
'movies',
'metadata.local',
False,
True,
True,
root_path_id))
# And TV shows # And TV shows
self.cursor.execute("select coalesce(max(idPath),0) from path") path_id = self.getPath('plugin://%s.tvshows/' % v.ADDON_ID)
path_id = self.cursor.fetchone()[0] + 1 if path_id is None:
query = ''' self.cursor.execute("select coalesce(max(idPath),0) from path")
INSERT INTO path(idPath, path_id = self.cursor.fetchone()[0] + 1
strPath, query = '''
strContent, INSERT INTO path(idPath,
strScraper, strPath,
useFolderNames, strContent,
noUpdate, strScraper,
exclude, useFolderNames,
idParentPath) noUpdate,
VALUES (?, ?, ?, ?, ?, ?, ?, ?) exclude)
''' VALUES (?, ?, ?, ?, ?, ?, ?)
self.cursor.execute(query, (path_id, '''
'plugin://%s/tvshows/' % v.ADDON_ID, self.cursor.execute(query, (path_id,
'tvshows', 'plugin://%s.tvshows/' % v.ADDON_ID,
'metadata.local', 'tvshows',
False, 'metadata.local',
True, 0,
True, 1,
root_path_id)) 1))
def getParentPathId(self, path): def getParentPathId(self, path):
""" """

View file

@ -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:

View file

@ -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',