PlexKodiConnect/resources/lib/ReadKodiDB.py

56 lines
1.9 KiB
Python
Raw Normal View History

2015-03-18 05:41:26 +11:00
#################################################################################################
# ReadKodiDB
#################################################################################################
import xbmc
import xbmcgui
import xbmcaddon
import json
import os
import Utils as utils
2015-03-18 05:41:26 +11:00
#sleepval is used to throttle the calls to the xbmc json API
sleepVal = 15
2015-03-18 05:41:26 +11:00
class ReadKodiDB():
2015-05-02 10:26:06 +10:00
def getKodiMovies(self, connection, cursor):
#returns all movies in Kodi db
2015-05-02 10:26:06 +10:00
cursor.execute("SELECT kodi_id, emby_id, checksum FROM emby WHERE media_type='movie'")
allmovies = cursor.fetchall()
#this will return a list with tuples of all items returned from the database
return allmovies
def getKodiTvShows(self, connection, cursor):
2015-05-02 10:26:06 +10:00
cursor.execute("SELECT kodi_id, emby_id, checksum FROM emby WHERE media_type='tvshow'")
allshows = cursor.fetchall()
#this will return a list with tuples of all items returned from the database
return allshows
2015-03-22 00:31:30 +11:00
2015-05-02 10:26:06 +10:00
def getKodiEpisodes(self, connection, cursor, showid=None):
2015-03-22 00:31:30 +11:00
2015-05-02 10:26:06 +10:00
if showid == None:
cursor.execute("SELECT kodi_id, emby_id, checksum FROM emby WHERE media_type=?",("episode",))
2015-03-22 00:31:30 +11:00
else:
2015-05-02 10:26:06 +10:00
cursor.execute("SELECT kodi_id, emby_id, checksum FROM emby WHERE media_type=? AND parent_id=?",("episode", showid))
2015-05-02 22:57:43 +10:00
2015-05-02 10:26:06 +10:00
allepisodes = cursor.fetchall()
#this will return a list with tuples of all items returned from the database
return allepisodes
2015-03-22 00:31:30 +11:00
2015-05-03 00:49:47 +10:00
def getEmbyIdByKodiId(self, id, type, connection=None, cursor=None):
if not connection:
connection = utils.KodiSQL()
cursor = connection.cursor()
cursor.execute("SELECT emby_id FROM emby WHERE media_type=? AND kodi_id=?",(type,id))
result = cursor.fetchone()
if result:
return result[0]
else:
return None