Fix potential time sync problems
This commit is contained in:
parent
2c0312a035
commit
8dee81c6a2
2 changed files with 34 additions and 9 deletions
|
@ -152,17 +152,37 @@ class Embydb_Functions():
|
||||||
))
|
))
|
||||||
self.embycursor.execute(query, (viewid,))
|
self.embycursor.execute(query, (viewid,))
|
||||||
|
|
||||||
def getItem_byFileId(self, fileId):
|
def getItem_byFileId(self, fileId, kodiType):
|
||||||
"""
|
"""
|
||||||
Returns the Plex itemId by using the Kodi fileId
|
Returns the Plex itemId by using the Kodi fileId. VIDEO ONLY
|
||||||
|
|
||||||
|
kodiType: 'movie', 'episode', ...
|
||||||
"""
|
"""
|
||||||
query = ' '.join((
|
query = ' '.join((
|
||||||
"SELECT emby_id",
|
"SELECT emby_id",
|
||||||
"FROM emby",
|
"FROM emby",
|
||||||
"WHERE kodi_fileid = ?"
|
"WHERE kodi_fileid = ? AND media_type = ?"
|
||||||
))
|
))
|
||||||
try:
|
try:
|
||||||
self.embycursor.execute(query, (fileId,))
|
self.embycursor.execute(query, (fileId, kodiType))
|
||||||
|
item = self.embycursor.fetchone()[0]
|
||||||
|
return item
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def getMusicItem_byFileId(self, fileId, kodiType):
|
||||||
|
"""
|
||||||
|
Returns the Plex itemId by using the Kodi fileId. MUSIC ONLY
|
||||||
|
|
||||||
|
kodiType: 'song'
|
||||||
|
"""
|
||||||
|
query = ' '.join((
|
||||||
|
"SELECT emby_id",
|
||||||
|
"FROM emby",
|
||||||
|
"WHERE kodi_id = ? AND media_type = ?"
|
||||||
|
))
|
||||||
|
try:
|
||||||
|
self.embycursor.execute(query, (fileId, kodiType))
|
||||||
item = self.embycursor.fetchone()[0]
|
item = self.embycursor.fetchone()[0]
|
||||||
return item
|
return item
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -293,10 +293,15 @@ class LibrarySync(Thread):
|
||||||
self.logMsg('Found kodiId: %s' % kodiId, 1)
|
self.logMsg('Found kodiId: %s' % kodiId, 1)
|
||||||
# Get Plex ID using the Kodi ID
|
# Get Plex ID using the Kodi ID
|
||||||
with embydb.GetEmbyDB() as emby_db:
|
with embydb.GetEmbyDB() as emby_db:
|
||||||
plexId = emby_db.getItem_byFileId(kodiId)
|
plexId = emby_db.getItem_byFileId(kodiId, 'movie')
|
||||||
if plexId:
|
if plexId:
|
||||||
self.logMsg('Found plexId: %s' % plexId, 1)
|
self.logMsg('Found movie plexId: %s' % plexId, 1)
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
plexId = emby_db.getItem_byFileId(kodiId, 'episode')
|
||||||
|
if plexId:
|
||||||
|
self.logMsg('Found episode plexId: %s' % plexId, 1)
|
||||||
|
break
|
||||||
|
|
||||||
# Try getting a music item if we did not find a video item
|
# Try getting a music item if we did not find a video item
|
||||||
if not plexId:
|
if not plexId:
|
||||||
|
@ -310,7 +315,7 @@ class LibrarySync(Thread):
|
||||||
self.logMsg('Found kodiId: %s' % kodiId, 1)
|
self.logMsg('Found kodiId: %s' % kodiId, 1)
|
||||||
# Get Plex ID using the Kodi ID
|
# Get Plex ID using the Kodi ID
|
||||||
with embydb.GetEmbyDB() as emby_db:
|
with embydb.GetEmbyDB() as emby_db:
|
||||||
plexId = emby_db.getItem_byFileId(kodiId)
|
plexId = emby_db.getMusicItem_byFileId(kodiId, 'song')
|
||||||
if plexId:
|
if plexId:
|
||||||
self.logMsg('Found plexId: %s' % plexId, 1)
|
self.logMsg('Found plexId: %s' % plexId, 1)
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue