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,))
|
||||
|
||||
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((
|
||||
"SELECT emby_id",
|
||||
"FROM emby",
|
||||
"WHERE kodi_fileid = ?"
|
||||
"WHERE kodi_fileid = ? AND media_type = ?"
|
||||
))
|
||||
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]
|
||||
return item
|
||||
except:
|
||||
|
|
|
@ -293,10 +293,15 @@ class LibrarySync(Thread):
|
|||
self.logMsg('Found kodiId: %s' % kodiId, 1)
|
||||
# Get Plex ID using the Kodi ID
|
||||
with embydb.GetEmbyDB() as emby_db:
|
||||
plexId = emby_db.getItem_byFileId(kodiId)
|
||||
if plexId:
|
||||
self.logMsg('Found plexId: %s' % plexId, 1)
|
||||
break
|
||||
plexId = emby_db.getItem_byFileId(kodiId, 'movie')
|
||||
if plexId:
|
||||
self.logMsg('Found movie plexId: %s' % plexId, 1)
|
||||
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
|
||||
if not plexId:
|
||||
|
@ -310,7 +315,7 @@ class LibrarySync(Thread):
|
|||
self.logMsg('Found kodiId: %s' % kodiId, 1)
|
||||
# Get Plex ID using the Kodi ID
|
||||
with embydb.GetEmbyDB() as emby_db:
|
||||
plexId = emby_db.getItem_byFileId(kodiId)
|
||||
plexId = emby_db.getMusicItem_byFileId(kodiId, 'song')
|
||||
if plexId:
|
||||
self.logMsg('Found plexId: %s' % plexId, 1)
|
||||
break
|
||||
|
|
Loading…
Reference in a new issue