mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-06-18 06:06:14 +00:00
first work on the transition to use kodi db for all actions
This commit is contained in:
parent
fdff2cefb7
commit
8a990ba217
6 changed files with 464 additions and 1310 deletions
|
@ -30,71 +30,38 @@ class ReadKodiDB():
|
|||
movies = result['movies']
|
||||
movie = movies[0]
|
||||
for item in movies:
|
||||
if item["imdbnumber"] == id:
|
||||
if id in item["file"]:
|
||||
movie = item
|
||||
break
|
||||
return movie
|
||||
|
||||
def getEmbyIdByKodiId(self, kodiid, type):
|
||||
#returns the emby id by search on kodi id
|
||||
xbmc.sleep(sleepVal)
|
||||
|
||||
embyId = None
|
||||
json_response = None
|
||||
connection = utils.KodiSQL()
|
||||
cursor = connection.cursor()
|
||||
|
||||
if type == "movie":
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": { "movieid": %d, "properties" : ["imdbnumber","file"] }, "id": "libMovies"}' %kodiid)
|
||||
cursor.execute("SELECT embyId as embyId FROM movie WHERE idMovie = ?",(kodiid,))
|
||||
if type == "episode":
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodeDetails", "params": {"episodeid": %d, "properties": ["file","uniqueid"]}, "id": 1}' %kodiid)
|
||||
cursor.execute("SELECT embyId as embyId FROM episode WHERE idEpisode = ?",(kodiid,))
|
||||
if type == "musicvideo":
|
||||
connection = utils.KodiSQL()
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT c23 as MBid FROM musicvideo WHERE idMVideo = ?",(kodiid,))
|
||||
result = cursor.fetchone()
|
||||
cursor.close()
|
||||
if result != None:
|
||||
embyId = result[0]
|
||||
cursor.execute("SELECT embyId as embyId FROM musicvideo WHERE idMVideo = ?",(kodiid,))
|
||||
if type == "tvshow":
|
||||
cursor.execute("SELECT embyId as embyId FROM tvshow WHERE idShow = ?",(kodiid,))
|
||||
|
||||
if json_response != None:
|
||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||
if(jsonobject.has_key('result')):
|
||||
result = jsonobject['result']
|
||||
resulttype = type + "details"
|
||||
if(result.has_key(resulttype)):
|
||||
item = result[resulttype]
|
||||
if type == "movie":
|
||||
if item.has_key('imdbnumber'):
|
||||
embyId = item['imdbnumber']
|
||||
if type == "episode":
|
||||
if item.has_key('uniqueid'):
|
||||
if item['uniqueid'].has_key('unknown'):
|
||||
embyId = item["uniqueid"]["unknown"]
|
||||
result = cursor.fetchone()
|
||||
cursor.close()
|
||||
if result != None:
|
||||
embyId = result[0]
|
||||
|
||||
return embyId
|
||||
|
||||
def getKodiMovies(self,fullInfo = False):
|
||||
def getKodiMovies(self, connection, cursor):
|
||||
#returns all movies in Kodi db
|
||||
xbmc.sleep(sleepVal)
|
||||
if fullInfo:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "properties" : ["art", "rating", "thumbnail", "fanart", "resume", "runtime", "year", "genre", "cast", "trailer", "country", "lastplayed", "studio", "set", "imdbnumber", "mpaa", "tagline", "plotoutline","plot", "sorttitle", "director", "writer", "playcount", "tag", "file"] }, "id": "libMovies"}')
|
||||
else:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "properties" : ["resume", "playcount", "imdbnumber", "lastplayed", "file"] }, "id": "libMovies"}')
|
||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||
movies = None
|
||||
|
||||
if(jsonobject.has_key('result')):
|
||||
result = jsonobject['result']
|
||||
if(result.has_key('movies')):
|
||||
movies = result['movies']
|
||||
|
||||
kodiMovieMap = None
|
||||
if(movies != None and len(movies) > 0):
|
||||
kodiMovieMap = {}
|
||||
for kodimovie in movies:
|
||||
key = kodimovie["imdbnumber"] #extract the id from the imdbnumber
|
||||
kodiMovieMap[key] = kodimovie
|
||||
|
||||
return kodiMovieMap
|
||||
cursor.execute("SELECT idMovie, embyId, c00 FROM movie")
|
||||
allmovies = cursor.fetchall()
|
||||
#this will return a list with tuples of all items returned from the database
|
||||
return allmovies
|
||||
|
||||
def getKodiMoviesIds(self,returnMB3Ids = False):
|
||||
# returns a list of movieIds or MB3 Id's from all movies currently in the Kodi library
|
||||
|
@ -132,29 +99,11 @@ class ReadKodiDB():
|
|||
|
||||
return allKodiTvShowsIds
|
||||
|
||||
def getKodiTvShows(self,fullInfo = False):
|
||||
#returns all tvshows in Kodi db inserted by MB
|
||||
xbmc.sleep(sleepVal)
|
||||
if fullInfo:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "properties": ["art", "genre", "plot", "mpaa", "cast", "studio", "sorttitle", "title", "originaltitle", "imdbnumber", "year", "premiered", "rating", "thumbnail", "playcount", "lastplayed", "file", "fanart", "tag"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
|
||||
else:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "properties": ["sorttitle", "title", "playcount", "lastplayed", "imdbnumber", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libTvShows"}')
|
||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||
tvshows = None
|
||||
|
||||
if(jsonobject.has_key('result')):
|
||||
result = jsonobject['result']
|
||||
if(result.has_key('tvshows')):
|
||||
tvshows = result['tvshows']
|
||||
|
||||
kodiShowMap = None
|
||||
if(tvshows != None and len(tvshows) > 0):
|
||||
kodiShowMap = {}
|
||||
for kodishow in tvshows:
|
||||
key = kodishow["imdbnumber"] #extract the id from the imdb number
|
||||
kodiShowMap[key] = kodishow
|
||||
|
||||
return kodiShowMap
|
||||
def getKodiTvShows(self, connection, cursor):
|
||||
cursor.execute("SELECT idShow, embyId, c00 FROM tvshow")
|
||||
allshows = cursor.fetchall()
|
||||
#this will return a list with tuples of all items returned from the database
|
||||
return allshows
|
||||
|
||||
def getKodiTVShow(self, id):
|
||||
xbmc.sleep(sleepVal)
|
||||
|
@ -171,28 +120,11 @@ class ReadKodiDB():
|
|||
break
|
||||
return tvshow
|
||||
|
||||
def getKodiEpisodes(self, KodiTvShowId, fullInfo = True, returnmap = True):
|
||||
xbmc.sleep(sleepVal)
|
||||
episodes = None
|
||||
if fullInfo:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, "properties": ["title", "playcount", "plot", "season", "episode", "showtitle", "file", "lastplayed", "rating", "resume", "art", "streamdetails", "firstaired", "runtime", "writer", "cast", "director", "dateadded", "uniqueid", "thumbnail", "fanart"], "sort": {"method": "episode"}}, "id": 1}' %KodiTvShowId)
|
||||
else:
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, "properties": ["title", "playcount", "season", "episode", "lastplayed", "resume","file","uniqueid"], "sort": {"method": "episode"}}, "id": 1}' %KodiTvShowId)
|
||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||
episodes = None
|
||||
if(jsonobject.has_key('result')):
|
||||
result = jsonobject['result']
|
||||
if(result.has_key('episodes')):
|
||||
episodes = result['episodes']
|
||||
if returnmap:
|
||||
episodeMap = None
|
||||
if(episodes != None):
|
||||
episodeMap = {}
|
||||
for KodiItem in episodes:
|
||||
episodeMap[KodiItem["uniqueid"]["unknown"]] = KodiItem
|
||||
return episodeMap
|
||||
else:
|
||||
return episodes
|
||||
def getKodiEpisodes(self, connection, cursor, showid):
|
||||
cursor.execute("SELECT idEpisode, embyId, c00 FROM episode WHERE idShow = ?", (showid,))
|
||||
allepisodes = cursor.fetchall()
|
||||
#this will return a list with tuples of all items returned from the database
|
||||
return allepisodes
|
||||
|
||||
def getKodiEpisodeByMbItem(self, episodeid, tvshowid):
|
||||
episode = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue