mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
fixed some small issues
This commit is contained in:
parent
42c7256f54
commit
6d191fef1d
2 changed files with 27 additions and 21 deletions
|
@ -49,11 +49,10 @@ class LibrarySync():
|
|||
connection = utils.KodiSQL()
|
||||
cursor = connection.cursor()
|
||||
|
||||
#TEMP --> add new columns
|
||||
try:
|
||||
#Add the special emby table
|
||||
if not startupDone:
|
||||
cursor.execute("CREATE TABLE IF NOT EXISTS emby(emby_id TEXT, kodi_id INTEGER, media_type TEXT, checksum TEXT, parent_id INTEGER)")
|
||||
connection.commit()
|
||||
except: pass
|
||||
|
||||
# sync movies
|
||||
self.MoviesSync(connection,cursor,True)
|
||||
|
@ -90,6 +89,9 @@ class LibrarySync():
|
|||
allMB3Movies = ReadEmbyDB().getMovies(view.get('id'))
|
||||
allKodiMovies = ReadKodiDB().getKodiMovies(connection, cursor)
|
||||
|
||||
for kodimovie in allKodiMovies:
|
||||
allKodiMovieIds.append(kodimovie[1])
|
||||
|
||||
#### PROCESS ADDS AND UPDATES ###
|
||||
for item in allMB3Movies:
|
||||
|
||||
|
@ -98,12 +100,10 @@ class LibrarySync():
|
|||
|
||||
kodiMovie = None
|
||||
for kodimovie in allKodiMovies:
|
||||
allKodiMovieIds.append(kodimovie[1])
|
||||
if kodimovie[1] == item["Id"]:
|
||||
kodiMovie = kodimovie
|
||||
|
||||
if kodiMovie == None:
|
||||
allKodiMovieIds.append(item["Id"])
|
||||
WriteKodiDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
|
||||
else:
|
||||
if kodiMovie[2] != API().getChecksum(item) or item["Id"] in itemList:
|
||||
|
@ -134,6 +134,10 @@ class LibrarySync():
|
|||
allEmbyTvShows = ReadEmbyDB().getTvShows(view.get('id'))
|
||||
allKodiTvShows = ReadKodiDB().getKodiTvShows(connection, cursor)
|
||||
|
||||
for kodishow in allKodiTvShows:
|
||||
allKodiTvShowIds.append(kodishow[1])
|
||||
|
||||
|
||||
#### TVSHOW: PROCESS ADDS AND UPDATES ###
|
||||
for item in allEmbyTvShows:
|
||||
|
||||
|
@ -143,13 +147,11 @@ class LibrarySync():
|
|||
#build a list with all Id's and get the existing entry (if exists) in Kodi DB
|
||||
kodiShow = None
|
||||
for kodishow in allKodiTvShows:
|
||||
allKodiTvShowIds.append(kodishow[1])
|
||||
if kodishow[1] == item["Id"]:
|
||||
kodiShow = kodishow
|
||||
|
||||
if kodiShow == None:
|
||||
# Tv show doesn't exist in Kodi yet so proceed and add it
|
||||
allKodiTvShowIds.append(item["Id"])
|
||||
kodiId = WriteKodiDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
|
||||
else:
|
||||
kodiId = kodishow[0]
|
||||
|
@ -181,21 +183,22 @@ class LibrarySync():
|
|||
allEmbyEpisodes = ReadEmbyDB().getEpisodes(embyShowId)
|
||||
allKodiEpisodes = ReadKodiDB().getKodiEpisodes(connection, cursor, kodiShowId)
|
||||
|
||||
for kodiepisode in allKodiEpisodes:
|
||||
allKodiEpisodeIds.append(kodiepisode[1])
|
||||
|
||||
#### EPISODES: PROCESS ADDS AND UPDATES ###
|
||||
for item in allEmbyEpisodes:
|
||||
|
||||
allEmbyEpisodeIds.append(item["Id"])
|
||||
|
||||
#build a list with all Id's and get the existing entry (if exists) in Kodi DB
|
||||
#get the existing entry (if exists) in Kodi DB
|
||||
kodiEpisode = None
|
||||
for kodiepisode in allKodiEpisodes:
|
||||
allKodiEpisodeIds.append(kodiepisode[1])
|
||||
if kodiepisode[1] == item["Id"]:
|
||||
kodiEpisode = kodiepisode
|
||||
|
||||
if kodiEpisode == None:
|
||||
# Episode doesn't exist in Kodi yet so proceed and add it
|
||||
allKodiEpisodeIds.append(item["Id"])
|
||||
WriteKodiDB().addOrUpdateEpisodeToKodiLibrary(item["Id"], kodiShowId, connection, cursor)
|
||||
else:
|
||||
# If there are changes to the item, perform a full sync of the item
|
||||
|
@ -204,10 +207,8 @@ class LibrarySync():
|
|||
|
||||
#### EPISODES: PROCESS DELETES #####
|
||||
allEmbyEpisodeIds = set(allEmbyEpisodeIds)
|
||||
print allEmbyEpisodeIds
|
||||
for kodiId in allKodiEpisodeIds:
|
||||
print "kodiId-->" + kodiId
|
||||
if not kodiId in allEmbyEpisodeIds:
|
||||
if (not kodiId in allEmbyEpisodeIds):
|
||||
WINDOW.setProperty(kodiId,"deleted")
|
||||
WriteKodiDB().deleteEpisodeFromKodiLibrary(kodiId, connection, cursor)
|
||||
|
||||
|
|
|
@ -26,17 +26,22 @@ class WriteKodiDB():
|
|||
|
||||
def updatePlayCountFromKodi(self, id, type, playcount=0):
|
||||
#when user marks item watched from kodi interface update this in MB3
|
||||
xbmc.sleep(sleepVal)
|
||||
|
||||
utils.logMsg("Emby", "updatePlayCountFromKodi Called")
|
||||
connection = utils.KodiSQL()
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT emby_id FROM emby WHERE media_type=? AND kodi_id=?",(type,id))
|
||||
|
||||
mb3Id = ReadKodiDB().getEmbyIdByKodiId(id, type)
|
||||
emby_id = cursor.fetchone()[0]
|
||||
cursor.close
|
||||
|
||||
if(mb3Id != None):
|
||||
if(emby_id != None):
|
||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||
|
||||
downloadUtils = DownloadUtils()
|
||||
|
||||
watchedurl = "{server}/mediabrowser/Users/{UserId}/PlayedItems/%s" % mb3Id
|
||||
#FIXME --> This is no longer working ??!!
|
||||
watchedurl = "{server}/mediabrowser/Users/{UserId}/PlayedItems/%s" % emby_id
|
||||
utils.logMsg("Emby","watchedurl -->" + watchedurl)
|
||||
if playcount != 0:
|
||||
downloadUtils.downloadUrl(watchedurl, postBody="", type="POST")
|
||||
|
@ -162,7 +167,7 @@ class WriteKodiDB():
|
|||
|
||||
#### UPDATE THE MOVIE #####
|
||||
else:
|
||||
pathsql="update movie SET c00 = ?, c01 = ?, c02 = ?, c05 = ?, c06 = ?, c07 = ?, c09 = ? c10 = ?, c11 = ?, c12 = ?, c14 = ?, c15 = ?, c16 = ?, c18 = ?, c19 = ? WHERE idMovie = ?"
|
||||
pathsql="update movie SET c00 = ?, c01 = ?, c02 = ?, c05 = ?, c06 = ?, c07 = ?, c09 = ?, c10 = ?, c11 = ?, c12 = ?, c14 = ?, c15 = ?, c16 = ?, c18 = ?, c19 = ? WHERE idMovie = ?"
|
||||
cursor.execute(pathsql, (title, plot, shortplot, rating, writer, year, imdb, sorttitle, runtime, mpaa, genre, director, title, studio, trailerUrl, movieid))
|
||||
|
||||
#update the checksum in emby table
|
||||
|
|
Loading…
Reference in a new issue