Remove emby references

This commit is contained in:
tomkat83 2016-05-31 08:06:42 +02:00
parent f3afa8dab1
commit a92146abc2
23 changed files with 208 additions and 207 deletions

View file

@ -54,26 +54,26 @@ if __name__ == '__main__':
emby = embyserver.Read_EmbyServer() emby = embyserver.Read_EmbyServer()
embyid = "" plexid = ""
if not itemtype and xbmc.getCondVisibility("Container.Content(albums)"): itemtype = "album" if not itemtype and xbmc.getCondVisibility("Container.Content(albums)"): itemtype = "album"
if not itemtype and xbmc.getCondVisibility("Container.Content(artists)"): itemtype = "artist" if not itemtype and xbmc.getCondVisibility("Container.Content(artists)"): itemtype = "artist"
if not itemtype and xbmc.getCondVisibility("Container.Content(songs)"): itemtype = "song" if not itemtype and xbmc.getCondVisibility("Container.Content(songs)"): itemtype = "song"
if not itemtype and xbmc.getCondVisibility("Container.Content(pictures)"): itemtype = "picture" if not itemtype and xbmc.getCondVisibility("Container.Content(pictures)"): itemtype = "picture"
if (not itemid or itemid == "-1") and xbmc.getInfoLabel("ListItem.Property(embyid)"): if (not itemid or itemid == "-1") and xbmc.getInfoLabel("ListItem.Property(plexid)"):
embyid = xbmc.getInfoLabel("ListItem.Property(embyid)") plexid = xbmc.getInfoLabel("ListItem.Property(plexid)")
else: else:
with embydb.GetEmbyDB() as emby_db: with embydb.GetEmbyDB() as emby_db:
item = emby_db.getItem_byKodiId(itemid, itemtype) item = emby_db.getItem_byKodiId(itemid, itemtype)
if item: if item:
embyid = item[0] plexid = item[0]
logMsg("Contextmenu opened for embyid: %s - itemtype: %s" %(embyid,itemtype)) logMsg("Contextmenu opened for plexid: %s - itemtype: %s" %(plexid,itemtype))
if embyid: if plexid:
item = PF.GetPlexMetadata(embyid) item = PF.GetPlexMetadata(plexid)
if item is None or item == 401: if item is None or item == 401:
logMsg('Could not get item metadata for item %s' % embyid, -1) logMsg('Could not get item metadata for item %s' % plexid, -1)
return return
API = PlexAPI.API(item[0]) API = PlexAPI.API(item[0])
userdata = API.getUserData() userdata = API.getUserData()
@ -111,15 +111,15 @@ if __name__ == '__main__':
ret = xbmcgui.Dialog().select(header, options) ret = xbmcgui.Dialog().select(header, options)
if ret != -1: if ret != -1:
if options[ret] == utils.language(30402): if options[ret] == utils.language(30402):
emby.updateUserRating(embyid, deletelike=True) emby.updateUserRating(plexid, deletelike=True)
if options[ret] == utils.language(30403): if options[ret] == utils.language(30403):
emby.updateUserRating(embyid, like=True) emby.updateUserRating(plexid, like=True)
if options[ret] == utils.language(30404): if options[ret] == utils.language(30404):
emby.updateUserRating(embyid, like=False) emby.updateUserRating(plexid, like=False)
if options[ret] == utils.language(30405): if options[ret] == utils.language(30405):
emby.updateUserRating(embyid, favourite=True) emby.updateUserRating(plexid, favourite=True)
if options[ret] == utils.language(30406): if options[ret] == utils.language(30406):
emby.updateUserRating(embyid, favourite=False) emby.updateUserRating(plexid, favourite=False)
if options[ret] == utils.language(30407): if options[ret] == utils.language(30407):
kodiconn = utils.kodiSQL('music') kodiconn = utils.kodiSQL('music')
kodicursor = kodiconn.cursor() kodicursor = kodiconn.cursor()
@ -134,7 +134,7 @@ if __name__ == '__main__':
musicutils.updateRatingToFile(newvalue, API.getFilePath()) musicutils.updateRatingToFile(newvalue, API.getFilePath())
if utils.settings('enableExportSongRating') == "true": if utils.settings('enableExportSongRating') == "true":
like, favourite, deletelike = musicutils.getEmbyRatingFromKodiRating(newvalue) like, favourite, deletelike = musicutils.getEmbyRatingFromKodiRating(newvalue)
emby.updateUserRating(embyid, like, favourite, deletelike) emby.updateUserRating(plexid, like, favourite, deletelike)
query = ' '.join(( "UPDATE song","SET rating = ?", "WHERE idSong = ?" )) query = ' '.join(( "UPDATE song","SET rating = ?", "WHERE idSong = ?" ))
kodicursor.execute(query, (newvalue,itemid,)) kodicursor.execute(query, (newvalue,itemid,))
kodiconn.commit() kodiconn.commit()
@ -152,14 +152,14 @@ if __name__ == '__main__':
line1=("Delete file from Emby Server? This will " line1=("Delete file from Emby Server? This will "
"also delete the file(s) from disk!")) "also delete the file(s) from disk!"))
if not resp: if not resp:
logMsg("User skipped deletion for: %s." % embyid, 1) logMsg("User skipped deletion for: %s." % plexid, 1)
delete = False delete = False
if delete: if delete:
import downloadutils import downloadutils
doUtils = downloadutils.DownloadUtils() doUtils = downloadutils.DownloadUtils()
url = "{server}/emby/Items/%s?format=json" % embyid url = "{server}/emby/Items/%s?format=json" % plexid
logMsg("Deleting request: %s" % embyid, 0) logMsg("Deleting request: %s" % plexid, 0)
doUtils.downloadUrl(url, action_type="DELETE") doUtils.downloadUrl(url, action_type="DELETE")
'''if utils.settings('skipContextMenu') != "true": '''if utils.settings('skipContextMenu') != "true":
@ -169,7 +169,7 @@ if __name__ == '__main__':
"also delete the file(s) from disk!")): "also delete the file(s) from disk!")):
import downloadutils import downloadutils
doUtils = downloadutils.DownloadUtils() doUtils = downloadutils.DownloadUtils()
doUtils.downloadUrl("{server}/emby/Items/%s?format=json" % embyid, action_type="DELETE")''' doUtils.downloadUrl("{server}/emby/Items/%s?format=json" % plexid, action_type="DELETE")'''
xbmc.sleep(500) xbmc.sleep(500)
xbmc.executebuiltin("Container.Update") xbmc.executebuiltin("Container.Update")

View file

@ -89,9 +89,9 @@ class Main:
} }
if "/extrafanart" in sys.argv[0]: if "/extrafanart" in sys.argv[0]:
embypath = sys.argv[2][1:] plexpath = sys.argv[2][1:]
embyid = params.get('id',[""])[0] plexid = params.get('id', [""])[0]
entrypoint.getExtraFanArt(embyid,embypath) entrypoint.getExtraFanArt(plexid, plexpath)
# Called by e.g. 3rd party plugin video extras # Called by e.g. 3rd party plugin video extras
if ("/Extras" in sys.argv[0] or "/VideoFiles" in sys.argv[0] or if ("/Extras" in sys.argv[0] or "/VideoFiles" in sys.argv[0] or
@ -141,7 +141,7 @@ class Main:
if mode == "settings": if mode == "settings":
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)') xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)')
elif mode in ("manualsync", "repair"): elif mode in ("manualsync", "repair"):
if utils.window('emby_online') != "true": if utils.window('plex_online') != "true":
# Server is not online, do not run the sync # Server is not online, do not run the sync
xbmcgui.Dialog().ok( xbmcgui.Dialog().ok(
"PlexKodiConnect", "PlexKodiConnect",

View file

@ -2300,7 +2300,7 @@ class API():
listItem.setProperty('resumetime', str(userdata['Resume'])) listItem.setProperty('resumetime', str(userdata['Resume']))
listItem.setProperty('totaltime', str(userdata['Runtime'])) listItem.setProperty('totaltime', str(userdata['Runtime']))
plexId = self.getRatingKey() plexId = self.getRatingKey()
listItem.setProperty('embyid', plexId) listItem.setProperty('plexid', plexId)
with embydb.GetEmbyDB() as emby_db: with embydb.GetEmbyDB() as emby_db:
try: try:
listItem.setProperty('dbid', listItem.setProperty('dbid',
@ -2364,7 +2364,7 @@ class API():
elif utils.window('replaceSMB') == 'true': elif utils.window('replaceSMB') == 'true':
if path.startswith('\\\\'): if path.startswith('\\\\'):
path = 'smb:' + path.replace('\\', '/') path = 'smb:' + path.replace('\\', '/')
if utils.window('emby_pathverified') == 'true' and forceCheck is False: if utils.window('plex_pathverified') == 'true' and forceCheck is False:
return path return path
# exist() needs a / or \ at the end to work for directories # exist() needs a / or \ at the end to work for directories
@ -2383,16 +2383,16 @@ class API():
if forceCheck is False: if forceCheck is False:
# Validate the path is correct with user intervention # Validate the path is correct with user intervention
if self.askToValidate(path): if self.askToValidate(path):
utils.window('emby_shouldStop', value="true") utils.window('plex_shouldStop', value="true")
path = None path = None
utils.window('emby_pathverified', value='true') utils.window('plex_pathverified', value='true')
utils.settings('emby_pathverified', value='true') utils.settings('plex_pathverified', value='true')
else: else:
path = None path = None
elif forceCheck is False: elif forceCheck is False:
if utils.window('emby_pathverified') != 'true': if utils.window('plex_pathverified') != 'true':
utils.window('emby_pathverified', value='true') utils.window('plex_pathverified', value='true')
utils.settings('emby_pathverified', value='true') utils.settings('plex_pathverified', value='true')
return path return path
def askToValidate(self, url): def askToValidate(self, url):

View file

@ -11,7 +11,7 @@ from plexbmchelper import listener, plexgdm, subscribers, functions, \
@utils.logging @utils.logging
@utils.ThreadMethodsAdditionalSuspend('emby_serverStatus') @utils.ThreadMethodsAdditionalSuspend('plex_serverStatus')
@utils.ThreadMethods @utils.ThreadMethods
class PlexCompanion(threading.Thread): class PlexCompanion(threading.Thread):
def __init__(self): def __init__(self):

View file

@ -173,7 +173,7 @@ class Artwork():
self.logMsg("Doing Image Cache Sync", 1) self.logMsg("Doing Image Cache Sync", 1)
dialog = xbmcgui.DialogProgress() dialog = xbmcgui.DialogProgress()
dialog.create("Emby for Kodi", "Image Cache Sync") dialog.create("PlexKodiConnect", "Image Cache Sync")
# ask to rest all existing or not # ask to rest all existing or not
if xbmcgui.Dialog().yesno( if xbmcgui.Dialog().yesno(
@ -414,7 +414,7 @@ class Artwork():
cacheimage = True cacheimage = True
# Only for the main backdrop, poster # Only for the main backdrop, poster
if (utils.window('emby_initialScan') != "true" and if (utils.window('plex_initialScan') != "true" and
imageType in ("fanart", "poster")): imageType in ("fanart", "poster")):
# Delete current entry before updating with the new one # Delete current entry before updating with the new one
self.deleteCachedArtwork(url) self.deleteCachedArtwork(url)

View file

@ -272,11 +272,11 @@ class DownloadUtils():
self.unauthorizedAttempts): self.unauthorizedAttempts):
self.logMsg('We seem to be truly unauthorized for PMS' self.logMsg('We seem to be truly unauthorized for PMS'
' %s ' % url, -1) ' %s ' % url, -1)
if window('emby_serverStatus') not in ('401', 'Auth'): if window('plex_serverStatus') not in ('401', 'Auth'):
# Tell userclient token has been revoked. # Tell userclient token has been revoked.
self.logMsg('Setting PMS server status to ' self.logMsg('Setting PMS server status to '
'unauthorized', 0) 'unauthorized', 0)
window('emby_serverStatus', value="401") window('plex_serverStatus', value="401")
xbmcgui.Dialog().notification( xbmcgui.Dialog().notification(
self.addonName, self.addonName,
"Unauthorized for PMS", "Unauthorized for PMS",
@ -331,7 +331,7 @@ class DownloadUtils():
if int(window('countError')) >= self.connectionAttempts: if int(window('countError')) >= self.connectionAttempts:
self.logMsg('Failed to connect to %s too many times. ' self.logMsg('Failed to connect to %s too many times. '
'Declare PMS dead' % url, -1) 'Declare PMS dead' % url, -1)
window('emby_online', value="false") window('plex_online', value="false")
except: except:
# 'countError' not yet set # 'countError' not yet set
pass pass

View file

@ -118,7 +118,7 @@ class Embydb_Functions():
return view return view
def addView(self, embyid, name, mediatype, tagid): def addView(self, plexid, name, mediatype, tagid):
query = ( query = (
''' '''
@ -128,7 +128,7 @@ class Embydb_Functions():
VALUES (?, ?, ?, ?) VALUES (?, ?, ?, ?)
''' '''
) )
self.embycursor.execute(query, (embyid, name, mediatype, tagid)) self.embycursor.execute(query, (plexid, name, mediatype, tagid))
def updateView(self, name, tagid, mediafolderid): def updateView(self, name, tagid, mediafolderid):
@ -185,7 +185,7 @@ class Embydb_Functions():
except: except:
return None return None
def getItem_byId(self, embyid): def getItem_byId(self, plexid):
query = ' '.join(( query = ' '.join((
@ -194,12 +194,12 @@ class Embydb_Functions():
"WHERE emby_id = ?" "WHERE emby_id = ?"
)) ))
try: try:
self.embycursor.execute(query, (embyid,)) self.embycursor.execute(query, (plexid,))
item = self.embycursor.fetchone() item = self.embycursor.fetchone()
return item return item
except: return None except: return None
def getItem_byWildId(self, embyid): def getItem_byWildId(self, plexid):
query = ' '.join(( query = ' '.join((
@ -207,7 +207,7 @@ class Embydb_Functions():
"FROM emby", "FROM emby",
"WHERE emby_id LIKE ?" "WHERE emby_id LIKE ?"
)) ))
self.embycursor.execute(query, (embyid+"%",)) self.embycursor.execute(query, (plexid+"%",))
return self.embycursor.fetchall() return self.embycursor.fetchall()
def getItem_byView(self, mediafolderid): def getItem_byView(self, mediafolderid):
@ -285,7 +285,7 @@ class Embydb_Functions():
self.embycursor.execute(query, (mediatype,)) self.embycursor.execute(query, (mediatype,))
return self.embycursor.fetchall() return self.embycursor.fetchall()
def getMediaType_byId(self, embyid): def getMediaType_byId(self, plexid):
query = ' '.join(( query = ' '.join((
@ -293,7 +293,7 @@ class Embydb_Functions():
"FROM emby", "FROM emby",
"WHERE emby_id = ?" "WHERE emby_id = ?"
)) ))
self.embycursor.execute(query, (embyid,)) self.embycursor.execute(query, (plexid,))
try: try:
itemtype = self.embycursor.fetchone()[0] itemtype = self.embycursor.fetchone()[0]
@ -315,7 +315,7 @@ class Embydb_Functions():
return sorted_items return sorted_items
def addReference(self, embyid, kodiid, embytype, mediatype, fileid=None, pathid=None, def addReference(self, plexid, kodiid, embytype, mediatype, fileid=None, pathid=None,
parentid=None, checksum=None, mediafolderid=None): parentid=None, checksum=None, mediafolderid=None):
query = ( query = (
''' '''
@ -326,18 +326,18 @@ class Embydb_Functions():
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
''' '''
) )
self.embycursor.execute(query, (embyid, kodiid, fileid, pathid, embytype, mediatype, self.embycursor.execute(query, (plexid, kodiid, fileid, pathid, embytype, mediatype,
parentid, checksum, mediafolderid)) parentid, checksum, mediafolderid))
def updateReference(self, embyid, checksum): def updateReference(self, plexid, checksum):
query = "UPDATE emby SET checksum = ? WHERE emby_id = ?" query = "UPDATE emby SET checksum = ? WHERE emby_id = ?"
self.embycursor.execute(query, (checksum, embyid)) self.embycursor.execute(query, (checksum, plexid))
def updateParentId(self, embyid, parent_kodiid): def updateParentId(self, plexid, parent_kodiid):
query = "UPDATE emby SET parent_id = ? WHERE emby_id = ?" query = "UPDATE emby SET parent_id = ? WHERE emby_id = ?"
self.embycursor.execute(query, (parent_kodiid, embyid)) self.embycursor.execute(query, (parent_kodiid, plexid))
def removeItems_byParentId(self, parent_kodiid, mediatype): def removeItems_byParentId(self, parent_kodiid, mediatype):
@ -359,13 +359,13 @@ class Embydb_Functions():
)) ))
self.embycursor.execute(query, (kodiid, mediatype,)) self.embycursor.execute(query, (kodiid, mediatype,))
def removeItem(self, embyid): def removeItem(self, plexid):
query = "DELETE FROM emby WHERE emby_id = ?" query = "DELETE FROM emby WHERE emby_id = ?"
self.embycursor.execute(query, (embyid,)) self.embycursor.execute(query, (plexid,))
def removeWildItem(self, embyid): def removeWildItem(self, plexid):
query = "DELETE FROM emby WHERE emby_id LIKE ?" query = "DELETE FROM emby WHERE emby_id LIKE ?"
self.embycursor.execute(query, (embyid+"%",)) self.embycursor.execute(query, (plexid+"%",))

View file

@ -234,7 +234,7 @@ def resetAuth():
line1=string(39206)) line1=string(39206))
if resp == 1: if resp == 1:
utils.logMsg("PLEX", "Reset login attempts.", 1) utils.logMsg("PLEX", "Reset login attempts.", 1)
utils.window('emby_serverStatus', value="Auth") utils.window('plex_serverStatus', value="Auth")
else: else:
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)') xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)')
def addDirectoryItem(label, path, folder=True): def addDirectoryItem(label, path, folder=True):
@ -248,15 +248,15 @@ def doMainListing():
string = xbmcaddon.Addon().getLocalizedString string = xbmcaddon.Addon().getLocalizedString
xbmcplugin.setContent(int(sys.argv[1]), 'files') xbmcplugin.setContent(int(sys.argv[1]), 'files')
# Get emby nodes from the window props # Get emby nodes from the window props
embyprops = utils.window('Emby.nodes.total') plexprops = utils.window('Plex.nodes.total')
if embyprops: if plexprops:
totalnodes = int(embyprops) totalnodes = int(plexprops)
for i in range(totalnodes): for i in range(totalnodes):
path = utils.window('Emby.nodes.%s.index' % i) path = utils.window('Plex.nodes.%s.index' % i)
if not path: if not path:
path = utils.window('Emby.nodes.%s.content' % i) path = utils.window('Plex.nodes.%s.content' % i)
label = utils.window('Emby.nodes.%s.title' % i) label = utils.window('Plex.nodes.%s.title' % i)
node_type = utils.window('Emby.nodes.%s.type' % i) node_type = utils.window('Plex.nodes.%s.type' % i)
#because we do not use seperate entrypoints for each content type, we need to figure out which items to show in each listing. #because we do not use seperate entrypoints for each content type, we need to figure out which items to show in each listing.
#for now we just only show picture nodes in the picture library video nodes in the video library and all nodes in any other window #for now we just only show picture nodes in the picture library video nodes in the video library and all nodes in any other window
if path and xbmc.getCondVisibility("Window.IsActive(Pictures)") and node_type == "photos": if path and xbmc.getCondVisibility("Window.IsActive(Pictures)") and node_type == "photos":
@ -315,8 +315,8 @@ def resetDeviceId():
def deleteItem(): def deleteItem():
# Serves as a keymap action # Serves as a keymap action
if xbmc.getInfoLabel('ListItem.Property(embyid)'): # If we already have the embyid if xbmc.getInfoLabel('ListItem.Property(plexid)'): # If we already have the plexid
embyid = xbmc.getInfoLabel('ListItem.Property(embyid)') plexid = xbmc.getInfoLabel('ListItem.Property(plexid)')
else: else:
dbid = xbmc.getInfoLabel('ListItem.DBID') dbid = xbmc.getInfoLabel('ListItem.DBID')
itemtype = xbmc.getInfoLabel('ListItem.DBTYPE') itemtype = xbmc.getInfoLabel('ListItem.DBTYPE')
@ -342,9 +342,9 @@ def deleteItem():
embycursor.close() embycursor.close()
try: try:
embyid = item[0] plexid = item[0]
except TypeError: except TypeError:
utils.logMsg("EMBY delete", "Unknown embyId, unable to proceed.", 1) utils.logMsg("EMBY delete", "Unknown plexid, unable to proceed.", 1)
return return
if utils.settings('skipContextMenu') != "true": if utils.settings('skipContextMenu') != "true":
@ -353,12 +353,12 @@ def deleteItem():
line1=("Delete file from Emby Server? This will " line1=("Delete file from Emby Server? This will "
"also delete the file(s) from disk!")) "also delete the file(s) from disk!"))
if not resp: if not resp:
utils.logMsg("EMBY delete", "User skipped deletion for: %s." % embyid, 1) utils.logMsg("EMBY delete", "User skipped deletion for: %s." % plexid, 1)
return return
doUtils = downloadutils.DownloadUtils() doUtils = downloadutils.DownloadUtils()
url = "{server}/emby/Items/%s?format=json" % embyid url = "{server}/emby/Items/%s?format=json" % plexid
utils.logMsg("EMBY delete", "Deleting request: %s" % embyid, 0) utils.logMsg("EMBY delete", "Deleting request: %s" % plexid, 0)
doUtils.downloadUrl(url, action_type="DELETE") doUtils.downloadUrl(url, action_type="DELETE")
##### ADD ADDITIONAL USERS ##### ##### ADD ADDITIONAL USERS #####
@ -671,9 +671,9 @@ def refreshPlaylist():
def GetSubFolders(nodeindex): def GetSubFolders(nodeindex):
nodetypes = ["",".recent",".recentepisodes",".inprogress",".inprogressepisodes",".unwatched",".nextepisodes",".sets",".genres",".random",".recommended"] nodetypes = ["",".recent",".recentepisodes",".inprogress",".inprogressepisodes",".unwatched",".nextepisodes",".sets",".genres",".random",".recommended"]
for node in nodetypes: for node in nodetypes:
title = utils.window('Emby.nodes.%s%s.title' %(nodeindex,node)) title = utils.window('Plex.nodes.%s%s.title' %(nodeindex,node))
if title: if title:
path = utils.window('Emby.nodes.%s%s.content' %(nodeindex,node)) path = utils.window('Plex.nodes.%s%s.content' %(nodeindex,node))
addDirectoryItem(title, path) addDirectoryItem(title, path)
xbmcplugin.endOfDirectory(int(sys.argv[1])) xbmcplugin.endOfDirectory(int(sys.argv[1]))
@ -775,7 +775,7 @@ def createListItemFromEmbyItem(item,art=artwork.Artwork(),doUtils=downloadutils.
premieredatelst = premieredate.split('T')[0].split("-") premieredatelst = premieredate.split('T')[0].split("-")
premieredate = "%s.%s.%s" %(premieredatelst[2],premieredatelst[1],premieredatelst[0]) premieredate = "%s.%s.%s" %(premieredatelst[2],premieredatelst[1],premieredatelst[0])
li.setProperty("embyid",itemid) li.setProperty("plexid",itemid)
allart = art.getAllArtwork(item) allart = art.getAllArtwork(item)
@ -1274,7 +1274,7 @@ def getVideoFiles(plexId, params):
##### GET EXTRAFANART FOR LISTITEM ##### ##### GET EXTRAFANART FOR LISTITEM #####
def getExtraFanArt(embyId,embyPath): def getExtraFanArt(plexid,embyPath):
emby = embyserver.Read_EmbyServer() emby = embyserver.Read_EmbyServer()
art = artwork.Artwork() art = artwork.Artwork()
@ -1282,24 +1282,24 @@ def getExtraFanArt(embyId,embyPath):
# Get extrafanart for listitem # Get extrafanart for listitem
# will be called by skinhelper script to get the extrafanart # will be called by skinhelper script to get the extrafanart
try: try:
# for tvshows we get the embyid just from the path # for tvshows we get the plexid just from the path
if not embyId: if not plexid:
if "plugin.video.emby" in embyPath: if "plugin.video.emby" in embyPath:
embyId = embyPath.split("/")[-2] plexid = embyPath.split("/")[-2]
if embyId: if plexid:
#only proceed if we actually have a emby id #only proceed if we actually have a emby id
utils.logMsg("EMBY", "Requesting extrafanart for Id: %s" % embyId, 0) utils.logMsg("EMBY", "Requesting extrafanart for Id: %s" % plexid, 0)
# We need to store the images locally for this to work # We need to store the images locally for this to work
# because of the caching system in xbmc # because of the caching system in xbmc
fanartDir = utils.tryDecode(xbmc.translatePath( fanartDir = utils.tryDecode(xbmc.translatePath(
"special://thumbnails/emby/%s/" % embyId)) "special://thumbnails/emby/%s/" % plexid))
if not xbmcvfs.exists(fanartDir): if not xbmcvfs.exists(fanartDir):
# Download the images to the cache directory # Download the images to the cache directory
xbmcvfs.mkdirs(fanartDir) xbmcvfs.mkdirs(fanartDir)
item = emby.getItem(embyId) item = emby.getItem(plexid)
if item: if item:
backdrops = art.getAllArtwork(item)['Backdrop'] backdrops = art.getAllArtwork(item)['Backdrop']
tags = item['BackdropImageTags'] tags = item['BackdropImageTags']
@ -1339,7 +1339,7 @@ def getExtraFanArt(embyId,embyPath):
def RunLibScan(mode): def RunLibScan(mode):
if utils.window('emby_online') != "true": if utils.window('plex_online') != "true":
# Server is not online, do not run the sync # Server is not online, do not run the sync
string = xbmcaddon.Addon().getLocalizedString string = xbmcaddon.Addon().getLocalizedString
xbmcgui.Dialog().ok(heading=addonName, xbmcgui.Dialog().ok(heading=addonName,
@ -1708,7 +1708,7 @@ def __LogOut():
utils.window('suspend_LibraryThread', value='true') utils.window('suspend_LibraryThread', value='true')
# Wait max for 10 seconds for all lib scans to shutdown # Wait max for 10 seconds for all lib scans to shutdown
counter = 0 counter = 0
while utils.window('emby_dbScan') == 'true': while utils.window('plex_dbScan') == 'true':
if counter > 200: if counter > 200:
# Failed to reset PMS and plex.tv connects. Try to restart Kodi. # Failed to reset PMS and plex.tv connects. Try to restart Kodi.
dialog.ok(addonName, string(39208)) dialog.ok(addonName, string(39208))
@ -1721,10 +1721,10 @@ def __LogOut():
utils.logMsg(title, "Successfully stopped library sync", 1) utils.logMsg(title, "Successfully stopped library sync", 1)
# Log out currently signed in user: # Log out currently signed in user:
utils.window('emby_serverStatus', value="401") utils.window('plex_serverStatus', value="401")
# Above method needs to have run its course! Hence wait # Above method needs to have run its course! Hence wait
counter = 0 counter = 0
while utils.window('emby_serverStatus') == "401": while utils.window('plex_serverStatus') == "401":
if counter > 100: if counter > 100:
# 'Failed to reset PKC. Try to restart Kodi.' # 'Failed to reset PKC. Try to restart Kodi.'
dialog.ok(addonName, string(39208)) dialog.ok(addonName, string(39208))

View file

@ -482,7 +482,7 @@ class InitialSetup():
goToSettings = dialog.yesno(heading=self.addonName, goToSettings = dialog.yesno(heading=self.addonName,
line1=string(39017)) line1=string(39017))
if goToSettings: if goToSettings:
utils.window('emby_serverStatus', value="Stop") utils.window('plex_serverStatus', value="Stop")
xbmc.executebuiltin( xbmc.executebuiltin(
'Addon.OpenSettings(plugin.video.plexkodiconnect)') 'Addon.OpenSettings(plugin.video.plexkodiconnect)')
else: else:

View file

@ -564,11 +564,11 @@ class Movies(Items):
# Delete kodi boxset # Delete kodi boxset
boxset_movies = emby_db.getItem_byParentId(kodiid, "movie") boxset_movies = emby_db.getItem_byParentId(kodiid, "movie")
for movie in boxset_movies: for movie in boxset_movies:
embyid = movie[0] plexid = movie[0]
movieid = movie[1] movieid = movie[1]
self.kodi_db.removefromBoxset(movieid) self.kodi_db.removefromBoxset(movieid)
# Update emby reference # Update emby reference
emby_db.updateParentId(embyid, None) emby_db.updateParentId(plexid, None)
kodicursor.execute("DELETE FROM sets WHERE idSet = ?", (kodiid,)) kodicursor.execute("DELETE FROM sets WHERE idSet = ?", (kodiid,))
@ -635,7 +635,7 @@ class MusicVideos(Items):
if not viewtag or not viewid: if not viewtag or not viewid:
# Get view tag from emby # Get view tag from emby
viewtag, viewid, mediatype = self.emby.getView_embyId(itemid) viewtag, viewid, mediatype = self.emby.getView_plexid(itemid)
self.logMsg("View tag found: %s" % viewtag, 2) self.logMsg("View tag found: %s" % viewtag, 2)
# fileId information # fileId information
@ -672,7 +672,7 @@ class MusicVideos(Items):
if self.directpath: if self.directpath:
# Direct paths is set the Kodi way # Direct paths is set the Kodi way
if utils.window('emby_pathverified') != "true" and not xbmcvfs.exists(playurl): if utils.window('plex_pathverified') != "true" and not xbmcvfs.exists(playurl):
# Validate the path is correct with user intervention # Validate the path is correct with user intervention
resp = xbmcgui.Dialog().yesno( resp = xbmcgui.Dialog().yesno(
heading="Can't validate path", heading="Can't validate path",
@ -683,11 +683,11 @@ class MusicVideos(Items):
"to format your path correctly. Stop syncing?" "to format your path correctly. Stop syncing?"
% playurl)) % playurl))
if resp: if resp:
utils.window('emby_shouldStop', value="true") utils.window('plex_shouldStop', value="true")
return False return False
path = playurl.replace(filename, "") path = playurl.replace(filename, "")
utils.window('emby_pathverified', value="true") utils.window('plex_pathverified', value="true")
else: else:
# Set plugin path and media flags using real filename # Set plugin path and media flags using real filename
path = "plugin://plugin.video.plexkodiconnect.musicvideos/" path = "plugin://plugin.video.plexkodiconnect.musicvideos/"
@ -991,7 +991,7 @@ class TVShows(Items):
if viewtag is None or viewid is None: if viewtag is None or viewid is None:
# Get view tag from emby # Get view tag from emby
viewtag, viewid, mediatype = embyserver.getView_embyId(itemid) viewtag, viewid, mediatype = embyserver.getView_plexid(itemid)
self.logMsg("View tag found: %s" % viewtag, 2) self.logMsg("View tag found: %s" % viewtag, 2)
# fileId information # fileId information

View file

@ -30,22 +30,22 @@ class KodiMonitor(xbmc.Monitor):
def onScanStarted(self, library): def onScanStarted(self, library):
self.logMsg("Kodi library scan %s running." % library, 2) self.logMsg("Kodi library scan %s running." % library, 2)
if library == "video": if library == "video":
utils.window('emby_kodiScan', value="true") utils.window('plex_kodiScan', value="true")
def onScanFinished(self, library): def onScanFinished(self, library):
self.logMsg("Kodi library scan %s finished." % library, 2) self.logMsg("Kodi library scan %s finished." % library, 2)
if library == "video": if library == "video":
utils.window('emby_kodiScan', clear=True) utils.window('plex_kodiScan', clear=True)
def onSettingsChanged(self): def onSettingsChanged(self):
# Monitor emby settings # Monitor emby settings
# Review reset setting at a later time, need to be adjusted to account for initial setup # Review reset setting at a later time, need to be adjusted to account for initial setup
# changes. # changes.
'''currentPath = utils.settings('useDirectPaths') '''currentPath = utils.settings('useDirectPaths')
if utils.window('emby_pluginpath') != currentPath: if utils.window('plex_pluginpath') != currentPath:
# Plugin path value changed. Offer to reset # Plugin path value changed. Offer to reset
self.logMsg("Changed to playback mode detected", 1) self.logMsg("Changed to playback mode detected", 1)
utils.window('emby_pluginpath', value=currentPath) utils.window('plex_pluginpath', value=currentPath)
resp = xbmcgui.Dialog().yesno( resp = xbmcgui.Dialog().yesno(
heading="Playback mode change detected", heading="Playback mode change detected",
line1=( line1=(
@ -56,10 +56,10 @@ class KodiMonitor(xbmc.Monitor):
utils.reset()''' utils.reset()'''
currentLog = utils.settings('logLevel') currentLog = utils.settings('logLevel')
if utils.window('emby_logLevel') != currentLog: if utils.window('plex_logLevel') != currentLog:
# The log level changed, set new prop # The log level changed, set new prop
self.logMsg("New log level: %s" % currentLog, 1) self.logMsg("New log level: %s" % currentLog, 1)
utils.window('emby_logLevel', value=currentLog) utils.window('plex_logLevel', value=currentLog)
def onNotification(self, sender, method, data): def onNotification(self, sender, method, data):
if method not in ("Playlist.OnAdd"): if method not in ("Playlist.OnAdd"):
@ -144,7 +144,7 @@ class KodiMonitor(xbmc.Monitor):
elif method == "System.OnWake": elif method == "System.OnWake":
# Allow network to wake up # Allow network to wake up
xbmc.sleep(10000) xbmc.sleep(10000)
utils.window('emby_onWake', value="true") utils.window('plex_onWake', value="true")
elif method == "GUI.OnScreensaverDeactivated": elif method == "GUI.OnScreensaverDeactivated":
if utils.settings('dbSyncScreensaver') == "true": if utils.settings('dbSyncScreensaver') == "true":

View file

@ -255,7 +255,7 @@ class ThreadedShowSyncInfo(Thread):
@utils.logging @utils.logging
@utils.ThreadMethodsAdditionalSuspend('suspend_LibraryThread') @utils.ThreadMethodsAdditionalSuspend('suspend_LibraryThread')
@utils.ThreadMethodsAdditionalStop('emby_shouldStop') @utils.ThreadMethodsAdditionalStop('plex_shouldStop')
@utils.ThreadMethods @utils.ThreadMethods
class LibrarySync(Thread): class LibrarySync(Thread):
""" """
@ -298,8 +298,8 @@ class LibrarySync(Thread):
'enableBackgroundSync') == "true" else False 'enableBackgroundSync') == "true" else False
self.limitindex = int(utils.settings('limitindex')) self.limitindex = int(utils.settings('limitindex'))
if utils.settings('emby_pathverified') == 'true': if utils.settings('plex_pathverified') == 'true':
utils.window('emby_pathverified', value='true') utils.window('plex_pathverified', value='true')
# Just in case a time sync goes wrong # Just in case a time sync goes wrong
self.timeoffset = int(utils.settings('kodiplextimeoffset')) self.timeoffset = int(utils.settings('kodiplextimeoffset'))
@ -504,7 +504,7 @@ class LibrarySync(Thread):
if self.enableMusic: if self.enableMusic:
xbmc.executebuiltin('UpdateLibrary(music)') xbmc.executebuiltin('UpdateLibrary(music)')
utils.window('emby_initialScan', clear=True) utils.window('plex_initialScan', clear=True)
xbmc.executebuiltin('InhibitIdleShutdown(false)') xbmc.executebuiltin('InhibitIdleShutdown(false)')
utils.setScreensaver(value=screensaver) utils.setScreensaver(value=screensaver)
if utils.window('plex_scancrashed') == 'true': if utils.window('plex_scancrashed') == 'true':
@ -513,7 +513,7 @@ class LibrarySync(Thread):
utils.window('plex_scancrashed', clear=True) utils.window('plex_scancrashed', clear=True)
elif utils.window('plex_scancrashed') == '401': elif utils.window('plex_scancrashed') == '401':
utils.window('plex_scancrashed', clear=True) utils.window('plex_scancrashed', clear=True)
if utils.window('emby_serverStatus') not in ('401', 'Auth'): if utils.window('plex_serverStatus') not in ('401', 'Auth'):
# Plex server had too much and returned ERROR # Plex server had too much and returned ERROR
self.dialog.ok(self.addonName, self.__language__(39409)) self.dialog.ok(self.addonName, self.__language__(39409))
@ -730,7 +730,7 @@ class LibrarySync(Thread):
pass pass
# Save total # Save total
utils.window('Emby.nodes.total', str(totalnodes)) utils.window('Plex.nodes.total', str(totalnodes))
# Reopen DB connection to ensure that changes were commited before # Reopen DB connection to ensure that changes were commited before
with embydb.GetEmbyDB() as emby_db: with embydb.GetEmbyDB() as emby_db:
@ -1539,7 +1539,7 @@ class LibrarySync(Thread):
try: try:
self.run_internal() self.run_internal()
except Exception as e: except Exception as e:
utils.window('emby_dbScan', clear=True) utils.window('plex_dbScan', clear=True)
self.logMsg('LibrarySync thread crashed', -1) self.logMsg('LibrarySync thread crashed', -1)
self.logMsg('Error message: %s' % e, -1) self.logMsg('Error message: %s' % e, -1)
import traceback import traceback
@ -1595,10 +1595,10 @@ class LibrarySync(Thread):
return return
xbmc.sleep(1000) xbmc.sleep(1000)
if (window('emby_dbCheck') != "true" and installSyncDone): if (window('plex_dbCheck') != "true" and installSyncDone):
# Verify the validity of the database # Verify the validity of the database
currentVersion = settings('dbCreatedWithVersion') currentVersion = settings('dbCreatedWithVersion')
minVersion = window('emby_minDBVersion') minVersion = window('plex_minDBVersion')
if not self.compareDBVersion(currentVersion, minVersion): if not self.compareDBVersion(currentVersion, minVersion):
log("Db version out of date: %s minimum version required: " log("Db version out of date: %s minimum version required: "
@ -1615,7 +1615,7 @@ class LibrarySync(Thread):
utils.reset() utils.reset()
break break
window('emby_dbCheck', value="true") window('plex_dbCheck', value="true")
if not startupComplete: if not startupComplete:
# Also runs when first installed # Also runs when first installed
@ -1633,7 +1633,7 @@ class LibrarySync(Thread):
break break
# Run start up sync # Run start up sync
window('emby_dbScan', value="true") window('plex_dbScan', value="true")
log("Db version: %s" % settings('dbCreatedWithVersion'), 0) log("Db version: %s" % settings('dbCreatedWithVersion'), 0)
lastTimeSync = utils.getUnixTimestamp() lastTimeSync = utils.getUnixTimestamp()
self.syncPMStime() self.syncPMStime()
@ -1641,7 +1641,7 @@ class LibrarySync(Thread):
lastSync = utils.getUnixTimestamp() lastSync = utils.getUnixTimestamp()
librarySync = fullSync() librarySync = fullSync()
# Initialize time offset Kodi - PMS # Initialize time offset Kodi - PMS
window('emby_dbScan', clear=True) window('plex_dbScan', clear=True)
if librarySync: if librarySync:
log("Initial start-up full sync successful", 0) log("Initial start-up full sync successful", 0)
startupComplete = True startupComplete = True
@ -1661,23 +1661,23 @@ class LibrarySync(Thread):
break break
# Currently no db scan, so we can start a new scan # Currently no db scan, so we can start a new scan
elif window('emby_dbScan') != "true": elif window('plex_dbScan') != "true":
# Full scan was requested from somewhere else, e.g. userclient # Full scan was requested from somewhere else, e.g. userclient
if window('plex_runLibScan') in ("full", "repair"): if window('plex_runLibScan') in ("full", "repair"):
log('Full library scan requested, starting', 0) log('Full library scan requested, starting', 0)
window('emby_dbScan', value="true") window('plex_dbScan', value="true")
if window('plex_runLibScan') == "full": if window('plex_runLibScan') == "full":
fullSync() fullSync()
elif window('plex_runLibScan') == "repair": elif window('plex_runLibScan') == "repair":
fullSync(repair=True) fullSync(repair=True)
window('plex_runLibScan', clear=True) window('plex_runLibScan', clear=True)
window('emby_dbScan', clear=True) window('plex_dbScan', clear=True)
# Full library sync finished # Full library sync finished
self.showKodiNote(string(39407), forced=True) self.showKodiNote(string(39407), forced=True)
# Reset views was requested from somewhere else # Reset views was requested from somewhere else
elif window('plex_runLibScan') == "views": elif window('plex_runLibScan') == "views":
log('Refresh playlist and nodes requested, starting', 0) log('Refresh playlist and nodes requested, starting', 0)
window('emby_dbScan', value="true") window('plex_dbScan', value="true")
window('plex_runLibScan', clear=True) window('plex_runLibScan', clear=True)
# First remove playlists # First remove playlists
@ -1697,36 +1697,36 @@ class LibrarySync(Thread):
self.showKodiNote(string(39406), self.showKodiNote(string(39406),
forced=True, forced=True,
icon="error") icon="error")
window('emby_dbScan', clear=True) window('plex_dbScan', clear=True)
else: else:
now = utils.getUnixTimestamp() now = utils.getUnixTimestamp()
if (now - lastSync > fullSyncInterval and if (now - lastSync > fullSyncInterval and
not xbmcplayer.isPlaying()): not xbmcplayer.isPlaying()):
lastSync = now lastSync = now
log('Doing scheduled full library scan', 1) log('Doing scheduled full library scan', 1)
window('emby_dbScan', value="true") window('plex_dbScan', value="true")
if fullSync() is False and not threadStopped(): if fullSync() is False and not threadStopped():
log('Could not finish scheduled full sync', -1) log('Could not finish scheduled full sync', -1)
self.showKodiNote(string(39410), self.showKodiNote(string(39410),
forced=True, forced=True,
icon='error') icon='error')
window('emby_dbScan', clear=True) window('plex_dbScan', clear=True)
# Full library sync finished # Full library sync finished
self.showKodiNote(string(39407), forced=False) self.showKodiNote(string(39407), forced=False)
elif now - lastTimeSync > oneDay: elif now - lastTimeSync > oneDay:
lastTimeSync = now lastTimeSync = now
log('Starting daily time sync', 0) log('Starting daily time sync', 0)
window('emby_dbScan', value="true") window('plex_dbScan', value="true")
self.syncPMStime() self.syncPMStime()
window('emby_dbScan', clear=True) window('plex_dbScan', clear=True)
elif enableBackgroundSync: elif enableBackgroundSync:
# Check back whether we should process something # Check back whether we should process something
# Only do this once every 10 seconds # Only do this once every 10 seconds
if now - lastProcessing > 10: if now - lastProcessing > 10:
lastProcessing = now lastProcessing = now
window('emby_dbScan', value="true") window('plex_dbScan', value="true")
processItems() processItems()
window('emby_dbScan', clear=True) window('plex_dbScan', clear=True)
# See if there is a PMS message we need to handle # See if there is a PMS message we need to handle
try: try:
message = queue.get(block=False) message = queue.get(block=False)
@ -1735,10 +1735,10 @@ class LibrarySync(Thread):
continue continue
# Got a message from PMS; process it # Got a message from PMS; process it
else: else:
window('emby_dbScan', value="true") window('plex_dbScan', value="true")
processMessage(message) processMessage(message)
queue.task_done() queue.task_done()
window('emby_dbScan', clear=True) window('plex_dbScan', clear=True)
# NO sleep! # NO sleep!
continue continue
else: else:

View file

@ -65,14 +65,14 @@ def getEmbyRatingFromKodiRating(rating):
if (rating >= 5): favourite = True if (rating >= 5): favourite = True
return(like, favourite, deletelike) return(like, favourite, deletelike)
def getAdditionalSongTags(embyid, emby_rating, API, kodicursor, emby_db, enableimportsongrating, enableexportsongrating, enableupdatesongrating): def getAdditionalSongTags(plexid, plex_rating, API, kodicursor, emby_db, enableimportsongrating, enableexportsongrating, enableupdatesongrating):
emby = embyserver.Read_EmbyServer() emby = embyserver.Read_EmbyServer()
previous_values = None previous_values = None
filename = API.getFilePath() filename = API.getFilePath()
rating = 0 rating = 0
emby_rating = int(round(emby_rating, 0)) plex_rating = int(round(plex_rating, 0))
#get file rating and comment tag from file itself. #get file rating and comment tag from file itself.
if enableimportsongrating: if enableimportsongrating:
@ -83,7 +83,7 @@ def getAdditionalSongTags(embyid, emby_rating, API, kodicursor, emby_db, enablei
hasEmbeddedCover = False hasEmbeddedCover = False
emby_dbitem = emby_db.getItem_byId(embyid) emby_dbitem = emby_db.getItem_byId(plexid)
try: try:
kodiid = emby_dbitem[0] kodiid = emby_dbitem[0]
except TypeError: except TypeError:
@ -100,44 +100,44 @@ def getAdditionalSongTags(embyid, emby_rating, API, kodicursor, emby_db, enablei
if file_rating is None and currentvalue: if file_rating is None and currentvalue:
return (currentvalue, comment, False) return (currentvalue, comment, False)
elif file_rating is None and not currentvalue: elif file_rating is None and not currentvalue:
return (emby_rating, comment, False) return (plex_rating, comment, False)
logMsg("getAdditionalSongTags --> embyid: %s - emby_rating: %s - file_rating: %s - current rating in kodidb: %s" %(embyid, emby_rating, file_rating, currentvalue)) logMsg("getAdditionalSongTags --> plexid: %s - plex_rating: %s - file_rating: %s - current rating in kodidb: %s" %(plexid, plex_rating, file_rating, currentvalue))
updateFileRating = False updateFileRating = False
updateEmbyRating = False updateEmbyRating = False
if currentvalue != None: if currentvalue != None:
# we need to translate the emby values... # we need to translate the emby values...
if emby_rating == 1 and currentvalue == 2: if plex_rating == 1 and currentvalue == 2:
emby_rating = 2 plex_rating = 2
if emby_rating == 3 and currentvalue == 4: if plex_rating == 3 and currentvalue == 4:
emby_rating = 4 plex_rating = 4
#if updating rating into file is disabled, we ignore the rating in the file... #if updating rating into file is disabled, we ignore the rating in the file...
if not enableupdatesongrating: if not enableupdatesongrating:
file_rating = currentvalue file_rating = currentvalue
#if convert emby likes/favourites convert to song rating is disabled, we ignore the emby rating... #if convert emby likes/favourites convert to song rating is disabled, we ignore the emby rating...
if not enableexportsongrating: if not enableexportsongrating:
emby_rating = currentvalue plex_rating = currentvalue
if (emby_rating == file_rating) and (file_rating != currentvalue): if (plex_rating == file_rating) and (file_rating != currentvalue):
#the rating has been updated from kodi itself, update change to both emby ands file #the rating has been updated from kodi itself, update change to both emby ands file
rating = currentvalue rating = currentvalue
updateFileRating = True updateFileRating = True
updateEmbyRating = True updateEmbyRating = True
elif (emby_rating != currentvalue) and (file_rating == currentvalue): elif (plex_rating != currentvalue) and (file_rating == currentvalue):
#emby rating changed - update the file #emby rating changed - update the file
rating = emby_rating rating = plex_rating
updateFileRating = True updateFileRating = True
elif (file_rating != currentvalue) and (emby_rating == currentvalue): elif (file_rating != currentvalue) and (plex_rating == currentvalue):
#file rating was updated, sync change to emby #file rating was updated, sync change to emby
rating = file_rating rating = file_rating
updateEmbyRating = True updateEmbyRating = True
elif (emby_rating != currentvalue) and (file_rating != currentvalue): elif (plex_rating != currentvalue) and (file_rating != currentvalue):
#both ratings have changed (corner case) - the highest rating wins... #both ratings have changed (corner case) - the highest rating wins...
if emby_rating > file_rating: if plex_rating > file_rating:
rating = emby_rating rating = plex_rating
updateFileRating = True updateFileRating = True
else: else:
rating = file_rating rating = file_rating
@ -152,16 +152,16 @@ def getAdditionalSongTags(embyid, emby_rating, API, kodicursor, emby_db, enablei
rating = file_rating rating = file_rating
#determine if we should also send the rating to emby server #determine if we should also send the rating to emby server
if enableexportsongrating: if enableexportsongrating:
if emby_rating == 1 and file_rating == 2: if plex_rating == 1 and file_rating == 2:
emby_rating = 2 plex_rating = 2
if emby_rating == 3 and file_rating == 4: if plex_rating == 3 and file_rating == 4:
emby_rating = 4 plex_rating = 4
if emby_rating != file_rating: if plex_rating != file_rating:
updateEmbyRating = True updateEmbyRating = True
elif enableexportsongrating: elif enableexportsongrating:
#set the initial rating to emby value #set the initial rating to emby value
rating = emby_rating rating = plex_rating
if updateFileRating and enableupdatesongrating: if updateFileRating and enableupdatesongrating:
updateRatingToFile(rating, filename) updateRatingToFile(rating, filename)
@ -169,8 +169,8 @@ def getAdditionalSongTags(embyid, emby_rating, API, kodicursor, emby_db, enablei
if updateEmbyRating and enableexportsongrating: if updateEmbyRating and enableexportsongrating:
# sync details to emby server. Translation needed between ID3 rating and emby likes/favourites: # sync details to emby server. Translation needed between ID3 rating and emby likes/favourites:
like, favourite, deletelike = getEmbyRatingFromKodiRating(rating) like, favourite, deletelike = getEmbyRatingFromKodiRating(rating)
utils.window("ignore-update-%s" %embyid, "true") #set temp windows prop to ignore the update from webclient update utils.window("ignore-update-%s" %plexid, "true") #set temp windows prop to ignore the update from webclient update
emby.updateUserRating(embyid, like, favourite, deletelike) emby.updateUserRating(plexid, like, favourite, deletelike)
return (rating, comment, hasEmbeddedCover) return (rating, comment, hasEmbeddedCover)

View file

@ -96,7 +96,7 @@ class PlaybackUtils():
sizePlaylist = playlist.size() sizePlaylist = playlist.size()
self.currentPosition = startPos self.currentPosition = startPos
propertiesPlayback = window('emby_playbackProps') == "true" propertiesPlayback = window('plex_playbackProps') == "true"
introsPlaylist = False introsPlaylist = False
dummyPlaylist = False dummyPlaylist = False
@ -112,11 +112,11 @@ class PlaybackUtils():
# Otherwise we get a loop. # Otherwise we get a loop.
if not propertiesPlayback: if not propertiesPlayback:
window('emby_playbackProps', value="true") window('plex_playbackProps', value="true")
self.logMsg("Setting up properties in playlist.", 1) self.logMsg("Setting up properties in playlist.", 1)
if (not homeScreen and not seektime and if (not homeScreen and not seektime and
window('emby_customPlaylist') != "true"): window('plex_customplaylist') != "true"):
self.logMsg("Adding dummy file to playlist.", 2) self.logMsg("Adding dummy file to playlist.", 2)
dummyPlaylist = True dummyPlaylist = True
playlist.add(playurl, listitem, index=startPos) playlist.add(playurl, listitem, index=startPos)
@ -187,7 +187,7 @@ class PlaybackUtils():
# We just skipped adding properties. Reset flag for next time. # We just skipped adding properties. Reset flag for next time.
elif propertiesPlayback: elif propertiesPlayback:
self.logMsg("Resetting properties playback flag.", 2) self.logMsg("Resetting properties playback flag.", 2)
window('emby_playbackProps', clear=True) window('plex_playbackProps', clear=True)
#self.pl.verifyPlaylist() #self.pl.verifyPlaylist()
########## SETUP MAIN ITEM ########## ########## SETUP MAIN ITEM ##########
@ -204,12 +204,12 @@ class PlaybackUtils():
############### PLAYBACK ################ ############### PLAYBACK ################
if homeScreen and seektime and window('emby_customPlaylist') != "true": if homeScreen and seektime and window('plex_customplaylist') != "true":
self.logMsg("Play as a widget item.", 1) self.logMsg("Play as a widget item.", 1)
API.CreateListItemFromPlexItem(listitem) API.CreateListItemFromPlexItem(listitem)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
elif ((introsPlaylist and window('emby_customPlaylist') == "true") or elif ((introsPlaylist and window('plex_customplaylist') == "true") or
(homeScreen and not sizePlaylist)): (homeScreen and not sizePlaylist)):
# Playlist was created just now, play it. # Playlist was created just now, play it.
self.logMsg("Play playlist.", 1) self.logMsg("Play playlist.", 1)

View file

@ -104,12 +104,12 @@ class Player(xbmc.Player):
self.logMsg("Playing itemtype is: %s" % itemType, 1) self.logMsg("Playing itemtype is: %s" % itemType, 1)
customseek = window('emby_customPlaylist.seektime') customseek = window('plex_customplaylist.seektime')
if (window('emby_customPlaylist') == "true" and customseek): if (window('plex_customplaylist') == "true" and customseek):
# Start at, when using custom playlist (play to Kodi from webclient) # Start at, when using custom playlist (play to Kodi from webclient)
self.logMsg("Seeking to: %s" % customseek, 1) self.logMsg("Seeking to: %s" % customseek, 1)
self.xbmcplayer.seekTime(int(customseek)) self.xbmcplayer.seekTime(int(customseek))
window('emby_customPlaylist.seektime', clear=True) window('plex_customplaylist.seektime', clear=True)
seekTime = self.xbmcplayer.getTime() seekTime = self.xbmcplayer.getTime()
@ -452,9 +452,9 @@ class Player(xbmc.Player):
self.stopAll() self.stopAll()
window('Plex_currently_playing_itemid', clear=True) window('Plex_currently_playing_itemid', clear=True)
window('emby_customPlaylist', clear=True) window('plex_customplaylist', clear=True)
window('emby_customPlaylist.seektime', clear=True) window('plex_customplaylist.seektime', clear=True)
window('emby_customPlaylist.seektime', clear=True) window('plex_customplaylist.seektime', clear=True)
self.logMsg("Clear playlist properties.", 1) self.logMsg("Clear playlist properties.", 1)
def onPlayBackEnded(self): def onPlayBackEnded(self):

View file

@ -41,11 +41,11 @@ class Playlist():
self.logMsg("Items: %s and start at: %s" % (itemids, startat), 1) self.logMsg("Items: %s and start at: %s" % (itemids, startat), 1)
started = False started = False
window('emby_customplaylist', value="true") window('plex_customplaylist', value="true")
if startat != 0: if startat != 0:
# Seek to the starting position # Seek to the starting position
window('emby_customplaylist.seektime', str(startat)) window('plex_customplaylist.seektime', str(startat))
with embydb.GetEmbyDB() as emby_db: with embydb.GetEmbyDB() as emby_db:
for itemid in itemids: for itemid in itemids:

View file

@ -81,8 +81,8 @@ class Read_EmbyServer():
return items return items
def getView_embyId(self, itemid): def getView_plexid(self, itemid):
# Returns ancestors using embyId # Returns ancestors using plexid
viewId = None viewId = None
for view in self.doUtils("{server}/emby/Items/%s/Ancestors?UserId={UserId}&format=json" % itemid): for view in self.doUtils("{server}/emby/Items/%s/Ancestors?UserId={UserId}&format=json" % itemid):
@ -245,7 +245,7 @@ class Read_EmbyServer():
self.logMsg("Set jump limit to recover: %s" % jump, 2) self.logMsg("Set jump limit to recover: %s" % jump, 2)
retry = 0 retry = 0
while utils.window('emby_online') != "true": while utils.window('plex_online') != "true":
# Wait server to come back online # Wait server to come back online
if retry == 5: if retry == 5:
self.logMsg("Unable to reconnect to server. Abort process.", 1) self.logMsg("Unable to reconnect to server. Abort process.", 1)

View file

@ -131,14 +131,14 @@ class UserClient(threading.Thread):
log("Access is restricted.", 1) log("Access is restricted.", 1)
self.HasAccess = False self.HasAccess = False
elif window('emby_online') != "true": elif window('plex_online') != "true":
# Server connection failed # Server connection failed
pass pass
elif window('emby_serverStatus') == "restricted": elif window('plex_serverStatus') == "restricted":
log("Access is granted.", 1) log("Access is granted.", 1)
self.HasAccess = True self.HasAccess = True
window('emby_serverStatus', clear=True) window('plex_serverStatus', clear=True)
xbmcgui.Dialog().notification(self.addonName, xbmcgui.Dialog().notification(self.addonName,
utils.language(33007)) utils.language(33007))
@ -239,7 +239,7 @@ class UserClient(threading.Thread):
# Give attempts at entering password / selecting user # Give attempts at entering password / selecting user
if self.retry >= 2: if self.retry >= 2:
log("Too many retries to login.", -1) log("Too many retries to login.", -1)
window('emby_serverStatus', value="Stop") window('plex_serverStatus', value="Stop")
dialog.ok(lang(33001), dialog.ok(lang(33001),
lang(39023)) lang(39023))
xbmc.executebuiltin( xbmc.executebuiltin(
@ -358,7 +358,7 @@ class UserClient(threading.Thread):
break break
xbmc.sleep(1000) xbmc.sleep(1000)
status = window('emby_serverStatus') status = window('plex_serverStatus')
if status == "Stop": if status == "Stop":
xbmc.sleep(500) xbmc.sleep(500)
@ -371,7 +371,7 @@ class UserClient(threading.Thread):
elif status == "401": elif status == "401":
# Unauthorized access, revoke token # Unauthorized access, revoke token
window('emby_serverStatus', value="Auth") window('plex_serverStatus', value="Auth")
self.resetClient() self.resetClient()
xbmc.sleep(2000) xbmc.sleep(2000)
@ -389,7 +389,7 @@ class UserClient(threading.Thread):
log("Current accessToken: xxxx", 1) log("Current accessToken: xxxx", 1)
self.retry = 0 self.retry = 0
window('suspend_LibraryThread', clear=True) window('suspend_LibraryThread', clear=True)
window('emby_serverStatus', clear=True) window('plex_serverStatus', clear=True)
if not self.auth and (self.currUser is None): if not self.auth and (self.currUser is None):
# Loop if no server found # Loop if no server found

View file

@ -254,7 +254,7 @@ def getUnixTimestamp(secondsIntoTheFuture=None):
def logMsg(title, msg, level=1): def logMsg(title, msg, level=1):
# Get the logLevel set in UserClient # Get the logLevel set in UserClient
try: try:
logLevel = int(window('emby_logLevel')) logLevel = int(window('plex_logLevel'))
except ValueError: except ValueError:
logLevel = 0 logLevel = 0
kodiLevel = { kodiLevel = {
@ -414,9 +414,9 @@ def reset():
return return
# first stop any db sync # first stop any db sync
window('emby_shouldStop', value="true") window('plex_shouldStop', value="true")
count = 10 count = 10
while window('emby_dbScan') == "true": while window('plex_dbScan') == "true":
logMsg("PLEX", "Sync is running, will retry: %s..." % count) logMsg("PLEX", "Sync is running, will retry: %s..." % count)
count -= 1 count -= 1
if count == 0: if count == 0:

View file

@ -98,13 +98,13 @@ class VideoNodes(object):
path = "library://video/Plex-%s/" % dirname path = "library://video/Plex-%s/" % dirname
for i in range(1, indexnumber): for i in range(1, indexnumber):
# Verify to make sure we don't create duplicates # Verify to make sure we don't create duplicates
if window('Emby.nodes.%s.index' % i) == path: if window('Plex.nodes.%s.index' % i) == path:
return return
if mediatype == "photo": if mediatype == "photo":
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=getsubfolders" % indexnumber path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=getsubfolders" % indexnumber
window('Emby.nodes.%s.index' % indexnumber, value=path) window('Plex.nodes.%s.index' % indexnumber, value=path)
# Root # Root
if not mediatype == "photo": if not mediatype == "photo":
@ -259,13 +259,13 @@ class VideoNodes(object):
else: else:
templabel = label templabel = label
embynode = "Emby.nodes.%s" % indexnumber embynode = "Plex.nodes.%s" % indexnumber
window('%s.title' % embynode, value=templabel) window('%s.title' % embynode, value=templabel)
window('%s.path' % embynode, value=windowpath) window('%s.path' % embynode, value=windowpath)
window('%s.content' % embynode, value=path) window('%s.content' % embynode, value=path)
window('%s.type' % embynode, value=mediatype) window('%s.type' % embynode, value=mediatype)
else: else:
embynode = "Emby.nodes.%s.%s" % (indexnumber, nodetype) embynode = "Plex.nodes.%s.%s" % (indexnumber, nodetype)
window('%s.title' % embynode, value=label) window('%s.title' % embynode, value=label)
window('%s.path' % embynode, value=windowpath) window('%s.path' % embynode, value=windowpath)
window('%s.content' % embynode, value=path) window('%s.content' % embynode, value=path)
@ -389,7 +389,7 @@ class VideoNodes(object):
'channels': 30173 'channels': 30173
} }
label = utils.language(labels[tagname]) label = utils.language(labels[tagname])
embynode = "Emby.nodes.%s" % indexnumber embynode = "Plex.nodes.%s" % indexnumber
window('%s.title' % embynode, value=label) window('%s.title' % embynode, value=label)
window('%s.path' % embynode, value=windowpath) window('%s.path' % embynode, value=windowpath)
window('%s.content' % embynode, value=path) window('%s.content' % embynode, value=path)
@ -418,7 +418,7 @@ class VideoNodes(object):
window = utils.window window = utils.window
self.logMsg("Clearing nodes properties.", 1) self.logMsg("Clearing nodes properties.", 1)
embyprops = window('Emby.nodes.total') plexprops = window('Plex.nodes.total')
propnames = [ propnames = [
"index","path","title","content", "index","path","title","content",
@ -433,8 +433,8 @@ class VideoNodes(object):
"inprogressepisodes.content","inprogressepisodes.path" "inprogressepisodes.content","inprogressepisodes.path"
] ]
if embyprops: if plexprops:
totalnodes = int(embyprops) totalnodes = int(plexprops)
for i in range(totalnodes): for i in range(totalnodes):
for prop in propnames: for prop in propnames:
window('Emby.nodes.%s.%s' % (str(i), prop), clear=True) window('Plex.nodes.%s.%s' % (str(i), prop), clear=True)

View file

@ -138,7 +138,7 @@ class WebSocket(threading.Thread):
if counter > 10: if counter > 10:
log("Repeatedly could not connect to PMS, declaring " log("Repeatedly could not connect to PMS, declaring "
"the connection dead", -1) "the connection dead", -1)
utils.window('emby_online', value='false') utils.window('plex_online', value='false')
counter = 0 counter = 0
xbmc.sleep(1000) xbmc.sleep(1000)
except websocket.WebSocketTimeoutException: except websocket.WebSocketTimeoutException:

View file

@ -60,7 +60,7 @@
<setting id="enableExportSongRating" type="bool" label="30525" default="false" visible="false" /> <setting id="enableExportSongRating" type="bool" label="30525" default="false" visible="false" />
<setting id="kodiplextimeoffset" type="number" label="Time difference in seconds (Koditime - Plextime)" default="0" visible="false" option="int" /> <setting id="kodiplextimeoffset" type="number" label="Time difference in seconds (Koditime - Plextime)" default="0" visible="false" option="int" />
<setting id="enableUpdateSongRating" type="bool" label="30526" default="false" visible="false" /> <setting id="enableUpdateSongRating" type="bool" label="30526" default="false" visible="false" />
<setting id="emby_pathverified" type="bool" default="false" visible="false" /> <!-- If 'false': one single warning message pops up if PKC cannot verify direct paths --> <setting id="plex_pathverified" type="bool" default="false" visible="false" /> <!-- If 'false': one single warning message pops up if PKC cannot verify direct paths -->
<setting id="themoviedbAPIKey" type="text" default="ae06df54334aa653354e9a010f4b81cb" visible="false"/> <setting id="themoviedbAPIKey" type="text" default="ae06df54334aa653354e9a010f4b81cb" visible="false"/>
<setting id="FanArtTVAPIKey" type="text" default="639191cb0774661597f28a47e7e2bad5" visible="false"/> <setting id="FanArtTVAPIKey" type="text" default="639191cb0774661597f28a47e7e2bad5" visible="false"/>
</category> </category>

View file

@ -72,9 +72,9 @@ class Service():
logLevel = self.getLogLevel() logLevel = self.getLogLevel()
self.monitor = xbmc.Monitor() self.monitor = xbmc.Monitor()
window('emby_logLevel', value=str(logLevel)) window('plex_logLevel', value=str(logLevel))
window('emby_kodiProfile', value=xbmc.translatePath("special://profile")) window('plex_kodiProfile', value=xbmc.translatePath("special://profile"))
window('emby_pluginpath', value=utils.settings('useDirectPaths')) window('plex_pluginpath', value=utils.settings('useDirectPaths'))
# Initial logging # Initial logging
log("======== START %s ========" % self.addonName, 0) log("======== START %s ========" % self.addonName, 0)
@ -87,10 +87,10 @@ class Service():
# Reset window props for profile switch # Reset window props for profile switch
properties = [ properties = [
"emby_online", "emby_serverStatus", "emby_onWake", "plex_online", "plex_serverStatus", "plex_onWake",
"emby_syncRunning", "emby_dbCheck", "emby_kodiScan", "plex_dbCheck", "plex_kodiScan",
"emby_shouldStop", "currUserId", "emby_dbScan", "emby_sessionId", "plex_shouldStop", "currUserId", "plex_dbScan",
"emby_initialScan", "emby_customplaylist", "emby_playbackProps", "plex_initialScan", "plex_customplaylist", "plex_playbackProps",
"plex_runLibScan", "plex_username", "pms_token", "plex_token", "plex_runLibScan", "plex_username", "pms_token", "plex_token",
"pms_server", "plex_machineIdentifier", "plex_servername", "pms_server", "plex_machineIdentifier", "plex_servername",
"plex_authenticated", "PlexUserImage", "useDirectPaths", "plex_authenticated", "PlexUserImage", "useDirectPaths",
@ -106,7 +106,7 @@ class Service():
videonodes.VideoNodes().clearProperties() videonodes.VideoNodes().clearProperties()
# Set the minimum database version # Set the minimum database version
window('emby_minDBVersion', value="1.1.5") window('plex_minDBVersion', value="1.1.5")
def getLogLevel(self): def getLogLevel(self):
try: try:
@ -148,10 +148,11 @@ class Service():
counter = 0 counter = 0
while not monitor.abortRequested(): while not monitor.abortRequested():
if window('emby_kodiProfile') != kodiProfile: if window('plex_kodiProfile') != kodiProfile:
# Profile change happened, terminate this thread and others # Profile change happened, terminate this thread and others
log("Kodi profile was: %s and changed to: %s. Terminating old Emby thread." log("Kodi profile was: %s and changed to: %s. Terminating old "
% (kodiProfile, utils.window('emby_kodiProfile')), 1) "PlexKodiConnect thread."
% (kodiProfile, utils.window('plex_kodiProfile')), 1)
break break
@ -160,8 +161,8 @@ class Service():
# 2. User is set # 2. User is set
# 3. User has access to the server # 3. User has access to the server
if window('emby_online') == "true": if window('plex_online') == "true":
# Emby server is online # Plex server is online
# Verify if user is set and has access to the server # Verify if user is set and has access to the server
if (user.currUser is not None) and user.HasAccess: if (user.currUser is not None) and user.HasAccess:
# If an item is playing # If an item is playing
@ -179,15 +180,15 @@ class Service():
td = datetime.today() - lastProgressUpdate td = datetime.today() - lastProgressUpdate
secDiff = td.seconds secDiff = td.seconds
# Report progress to Emby server # Report progress to Plex server
if (secDiff > 3): if (secDiff > 3):
kplayer.reportPlayback() kplayer.reportPlayback()
lastProgressUpdate = datetime.today() lastProgressUpdate = datetime.today()
elif window('emby_command') == "true": elif window('plex_command') == "true":
# Received a remote control command that # Received a remote control command that
# requires updating immediately # requires updating immediately
window('emby_command', clear=True) window('plex_command', clear=True)
kplayer.reportPlayback() kplayer.reportPlayback()
lastProgressUpdate = datetime.today() lastProgressUpdate = datetime.today()
except Exception as e: except Exception as e:
@ -235,7 +236,7 @@ class Service():
# Verify access with an API call # Verify access with an API call
user.hasAccess() user.hasAccess()
if window('emby_online') != "true": if window('plex_online') != "true":
# Server went offline # Server went offline
break break
@ -256,7 +257,7 @@ class Service():
# Alert the user and suppress future warning # Alert the user and suppress future warning
if self.server_online: if self.server_online:
log("Server is offline.", -1) log("Server is offline.", -1)
window('emby_online', value="false") window('plex_online', value="false")
# Suspend threads # Suspend threads
window('suspend_LibraryThread', value='true') window('suspend_LibraryThread', value='true')
xbmcgui.Dialog().notification( xbmcgui.Dialog().notification(
@ -294,7 +295,7 @@ class Service():
sound=False) sound=False)
self.server_online = True self.server_online = True
log("Server %s is online and ready." % server, 1) log("Server %s is online and ready." % server, 1)
window('emby_online', value="true") window('plex_online', value="true")
if window('plex_authenticated') == 'true': if window('plex_authenticated') == 'true':
# Server got offline when we were authenticated. # Server got offline when we were authenticated.
# Hence resume threads # Hence resume threads
@ -353,6 +354,6 @@ delay = int(utils.settings('startupDelay'))
xbmc.log("Delaying Plex startup by: %s sec..." % delay) xbmc.log("Delaying Plex startup by: %s sec..." % delay)
if delay and xbmc.Monitor().waitForAbort(delay): if delay and xbmc.Monitor().waitForAbort(delay):
# Start the service # Start the service
xbmc.log("Abort requested while waiting. Emby for kodi not started.") xbmc.log("Abort requested while waiting. PKC not started.")
else: else:
Service().ServiceEntryPoint() Service().ServiceEntryPoint()