Remove emby references
This commit is contained in:
parent
f3afa8dab1
commit
a92146abc2
23 changed files with 208 additions and 207 deletions
|
@ -54,26 +54,26 @@ if __name__ == '__main__':
|
|||
|
||||
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(artists)"): itemtype = "artist"
|
||||
if not itemtype and xbmc.getCondVisibility("Container.Content(songs)"): itemtype = "song"
|
||||
if not itemtype and xbmc.getCondVisibility("Container.Content(pictures)"): itemtype = "picture"
|
||||
|
||||
if (not itemid or itemid == "-1") and xbmc.getInfoLabel("ListItem.Property(embyid)"):
|
||||
embyid = xbmc.getInfoLabel("ListItem.Property(embyid)")
|
||||
if (not itemid or itemid == "-1") and xbmc.getInfoLabel("ListItem.Property(plexid)"):
|
||||
plexid = xbmc.getInfoLabel("ListItem.Property(plexid)")
|
||||
else:
|
||||
with embydb.GetEmbyDB() as emby_db:
|
||||
item = emby_db.getItem_byKodiId(itemid, itemtype)
|
||||
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:
|
||||
item = PF.GetPlexMetadata(embyid)
|
||||
if plexid:
|
||||
item = PF.GetPlexMetadata(plexid)
|
||||
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
|
||||
API = PlexAPI.API(item[0])
|
||||
userdata = API.getUserData()
|
||||
|
@ -111,15 +111,15 @@ if __name__ == '__main__':
|
|||
ret = xbmcgui.Dialog().select(header, options)
|
||||
if ret != -1:
|
||||
if options[ret] == utils.language(30402):
|
||||
emby.updateUserRating(embyid, deletelike=True)
|
||||
emby.updateUserRating(plexid, deletelike=True)
|
||||
if options[ret] == utils.language(30403):
|
||||
emby.updateUserRating(embyid, like=True)
|
||||
emby.updateUserRating(plexid, like=True)
|
||||
if options[ret] == utils.language(30404):
|
||||
emby.updateUserRating(embyid, like=False)
|
||||
emby.updateUserRating(plexid, like=False)
|
||||
if options[ret] == utils.language(30405):
|
||||
emby.updateUserRating(embyid, favourite=True)
|
||||
emby.updateUserRating(plexid, favourite=True)
|
||||
if options[ret] == utils.language(30406):
|
||||
emby.updateUserRating(embyid, favourite=False)
|
||||
emby.updateUserRating(plexid, favourite=False)
|
||||
if options[ret] == utils.language(30407):
|
||||
kodiconn = utils.kodiSQL('music')
|
||||
kodicursor = kodiconn.cursor()
|
||||
|
@ -134,7 +134,7 @@ if __name__ == '__main__':
|
|||
musicutils.updateRatingToFile(newvalue, API.getFilePath())
|
||||
if utils.settings('enableExportSongRating') == "true":
|
||||
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 = ?" ))
|
||||
kodicursor.execute(query, (newvalue,itemid,))
|
||||
kodiconn.commit()
|
||||
|
@ -152,14 +152,14 @@ if __name__ == '__main__':
|
|||
line1=("Delete file from Emby Server? This will "
|
||||
"also delete the file(s) from disk!"))
|
||||
if not resp:
|
||||
logMsg("User skipped deletion for: %s." % embyid, 1)
|
||||
logMsg("User skipped deletion for: %s." % plexid, 1)
|
||||
delete = False
|
||||
|
||||
if delete:
|
||||
import downloadutils
|
||||
doUtils = downloadutils.DownloadUtils()
|
||||
url = "{server}/emby/Items/%s?format=json" % embyid
|
||||
logMsg("Deleting request: %s" % embyid, 0)
|
||||
url = "{server}/emby/Items/%s?format=json" % plexid
|
||||
logMsg("Deleting request: %s" % plexid, 0)
|
||||
doUtils.downloadUrl(url, action_type="DELETE")
|
||||
|
||||
'''if utils.settings('skipContextMenu') != "true":
|
||||
|
@ -169,7 +169,7 @@ if __name__ == '__main__':
|
|||
"also delete the file(s) from disk!")):
|
||||
import 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.executebuiltin("Container.Update")
|
|
@ -89,9 +89,9 @@ class Main:
|
|||
}
|
||||
|
||||
if "/extrafanart" in sys.argv[0]:
|
||||
embypath = sys.argv[2][1:]
|
||||
embyid = params.get('id',[""])[0]
|
||||
entrypoint.getExtraFanArt(embyid,embypath)
|
||||
plexpath = sys.argv[2][1:]
|
||||
plexid = params.get('id', [""])[0]
|
||||
entrypoint.getExtraFanArt(plexid, plexpath)
|
||||
|
||||
# Called by e.g. 3rd party plugin video extras
|
||||
if ("/Extras" in sys.argv[0] or "/VideoFiles" in sys.argv[0] or
|
||||
|
@ -141,7 +141,7 @@ class Main:
|
|||
if mode == "settings":
|
||||
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
||||
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
|
||||
xbmcgui.Dialog().ok(
|
||||
"PlexKodiConnect",
|
||||
|
|
|
@ -2300,7 +2300,7 @@ class API():
|
|||
listItem.setProperty('resumetime', str(userdata['Resume']))
|
||||
listItem.setProperty('totaltime', str(userdata['Runtime']))
|
||||
plexId = self.getRatingKey()
|
||||
listItem.setProperty('embyid', plexId)
|
||||
listItem.setProperty('plexid', plexId)
|
||||
with embydb.GetEmbyDB() as emby_db:
|
||||
try:
|
||||
listItem.setProperty('dbid',
|
||||
|
@ -2364,7 +2364,7 @@ class API():
|
|||
elif utils.window('replaceSMB') == 'true':
|
||||
if path.startswith('\\\\'):
|
||||
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
|
||||
|
||||
# exist() needs a / or \ at the end to work for directories
|
||||
|
@ -2383,16 +2383,16 @@ class API():
|
|||
if forceCheck is False:
|
||||
# Validate the path is correct with user intervention
|
||||
if self.askToValidate(path):
|
||||
utils.window('emby_shouldStop', value="true")
|
||||
utils.window('plex_shouldStop', value="true")
|
||||
path = None
|
||||
utils.window('emby_pathverified', value='true')
|
||||
utils.settings('emby_pathverified', value='true')
|
||||
utils.window('plex_pathverified', value='true')
|
||||
utils.settings('plex_pathverified', value='true')
|
||||
else:
|
||||
path = None
|
||||
elif forceCheck is False:
|
||||
if utils.window('emby_pathverified') != 'true':
|
||||
utils.window('emby_pathverified', value='true')
|
||||
utils.settings('emby_pathverified', value='true')
|
||||
if utils.window('plex_pathverified') != 'true':
|
||||
utils.window('plex_pathverified', value='true')
|
||||
utils.settings('plex_pathverified', value='true')
|
||||
return path
|
||||
|
||||
def askToValidate(self, url):
|
||||
|
|
|
@ -11,7 +11,7 @@ from plexbmchelper import listener, plexgdm, subscribers, functions, \
|
|||
|
||||
|
||||
@utils.logging
|
||||
@utils.ThreadMethodsAdditionalSuspend('emby_serverStatus')
|
||||
@utils.ThreadMethodsAdditionalSuspend('plex_serverStatus')
|
||||
@utils.ThreadMethods
|
||||
class PlexCompanion(threading.Thread):
|
||||
def __init__(self):
|
||||
|
|
|
@ -173,7 +173,7 @@ class Artwork():
|
|||
self.logMsg("Doing Image Cache Sync", 1)
|
||||
|
||||
dialog = xbmcgui.DialogProgress()
|
||||
dialog.create("Emby for Kodi", "Image Cache Sync")
|
||||
dialog.create("PlexKodiConnect", "Image Cache Sync")
|
||||
|
||||
# ask to rest all existing or not
|
||||
if xbmcgui.Dialog().yesno(
|
||||
|
@ -414,7 +414,7 @@ class Artwork():
|
|||
cacheimage = True
|
||||
|
||||
# Only for the main backdrop, poster
|
||||
if (utils.window('emby_initialScan') != "true" and
|
||||
if (utils.window('plex_initialScan') != "true" and
|
||||
imageType in ("fanart", "poster")):
|
||||
# Delete current entry before updating with the new one
|
||||
self.deleteCachedArtwork(url)
|
||||
|
|
|
@ -272,11 +272,11 @@ class DownloadUtils():
|
|||
self.unauthorizedAttempts):
|
||||
self.logMsg('We seem to be truly unauthorized for PMS'
|
||||
' %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.
|
||||
self.logMsg('Setting PMS server status to '
|
||||
'unauthorized', 0)
|
||||
window('emby_serverStatus', value="401")
|
||||
window('plex_serverStatus', value="401")
|
||||
xbmcgui.Dialog().notification(
|
||||
self.addonName,
|
||||
"Unauthorized for PMS",
|
||||
|
@ -331,7 +331,7 @@ class DownloadUtils():
|
|||
if int(window('countError')) >= self.connectionAttempts:
|
||||
self.logMsg('Failed to connect to %s too many times. '
|
||||
'Declare PMS dead' % url, -1)
|
||||
window('emby_online', value="false")
|
||||
window('plex_online', value="false")
|
||||
except:
|
||||
# 'countError' not yet set
|
||||
pass
|
||||
|
|
|
@ -118,7 +118,7 @@ class Embydb_Functions():
|
|||
|
||||
return view
|
||||
|
||||
def addView(self, embyid, name, mediatype, tagid):
|
||||
def addView(self, plexid, name, mediatype, tagid):
|
||||
|
||||
query = (
|
||||
'''
|
||||
|
@ -128,7 +128,7 @@ class Embydb_Functions():
|
|||
VALUES (?, ?, ?, ?)
|
||||
'''
|
||||
)
|
||||
self.embycursor.execute(query, (embyid, name, mediatype, tagid))
|
||||
self.embycursor.execute(query, (plexid, name, mediatype, tagid))
|
||||
|
||||
def updateView(self, name, tagid, mediafolderid):
|
||||
|
||||
|
@ -185,7 +185,7 @@ class Embydb_Functions():
|
|||
except:
|
||||
return None
|
||||
|
||||
def getItem_byId(self, embyid):
|
||||
def getItem_byId(self, plexid):
|
||||
|
||||
query = ' '.join((
|
||||
|
||||
|
@ -194,12 +194,12 @@ class Embydb_Functions():
|
|||
"WHERE emby_id = ?"
|
||||
))
|
||||
try:
|
||||
self.embycursor.execute(query, (embyid,))
|
||||
self.embycursor.execute(query, (plexid,))
|
||||
item = self.embycursor.fetchone()
|
||||
return item
|
||||
except: return None
|
||||
|
||||
def getItem_byWildId(self, embyid):
|
||||
def getItem_byWildId(self, plexid):
|
||||
|
||||
query = ' '.join((
|
||||
|
||||
|
@ -207,7 +207,7 @@ class Embydb_Functions():
|
|||
"FROM emby",
|
||||
"WHERE emby_id LIKE ?"
|
||||
))
|
||||
self.embycursor.execute(query, (embyid+"%",))
|
||||
self.embycursor.execute(query, (plexid+"%",))
|
||||
return self.embycursor.fetchall()
|
||||
|
||||
def getItem_byView(self, mediafolderid):
|
||||
|
@ -285,7 +285,7 @@ class Embydb_Functions():
|
|||
self.embycursor.execute(query, (mediatype,))
|
||||
return self.embycursor.fetchall()
|
||||
|
||||
def getMediaType_byId(self, embyid):
|
||||
def getMediaType_byId(self, plexid):
|
||||
|
||||
query = ' '.join((
|
||||
|
||||
|
@ -293,7 +293,7 @@ class Embydb_Functions():
|
|||
"FROM emby",
|
||||
"WHERE emby_id = ?"
|
||||
))
|
||||
self.embycursor.execute(query, (embyid,))
|
||||
self.embycursor.execute(query, (plexid,))
|
||||
try:
|
||||
itemtype = self.embycursor.fetchone()[0]
|
||||
|
||||
|
@ -315,7 +315,7 @@ class Embydb_Functions():
|
|||
|
||||
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):
|
||||
query = (
|
||||
'''
|
||||
|
@ -326,18 +326,18 @@ class Embydb_Functions():
|
|||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
'''
|
||||
)
|
||||
self.embycursor.execute(query, (embyid, kodiid, fileid, pathid, embytype, mediatype,
|
||||
self.embycursor.execute(query, (plexid, kodiid, fileid, pathid, embytype, mediatype,
|
||||
parentid, checksum, mediafolderid))
|
||||
|
||||
def updateReference(self, embyid, checksum):
|
||||
def updateReference(self, plexid, checksum):
|
||||
|
||||
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 = ?"
|
||||
self.embycursor.execute(query, (parent_kodiid, embyid))
|
||||
self.embycursor.execute(query, (parent_kodiid, plexid))
|
||||
|
||||
def removeItems_byParentId(self, parent_kodiid, mediatype):
|
||||
|
||||
|
@ -359,13 +359,13 @@ class Embydb_Functions():
|
|||
))
|
||||
self.embycursor.execute(query, (kodiid, mediatype,))
|
||||
|
||||
def removeItem(self, embyid):
|
||||
def removeItem(self, plexid):
|
||||
|
||||
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 ?"
|
||||
self.embycursor.execute(query, (embyid+"%",))
|
||||
self.embycursor.execute(query, (plexid+"%",))
|
||||
|
|
@ -234,7 +234,7 @@ def resetAuth():
|
|||
line1=string(39206))
|
||||
if resp == 1:
|
||||
utils.logMsg("PLEX", "Reset login attempts.", 1)
|
||||
utils.window('emby_serverStatus', value="Auth")
|
||||
utils.window('plex_serverStatus', value="Auth")
|
||||
else:
|
||||
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
||||
def addDirectoryItem(label, path, folder=True):
|
||||
|
@ -248,15 +248,15 @@ def doMainListing():
|
|||
string = xbmcaddon.Addon().getLocalizedString
|
||||
xbmcplugin.setContent(int(sys.argv[1]), 'files')
|
||||
# Get emby nodes from the window props
|
||||
embyprops = utils.window('Emby.nodes.total')
|
||||
if embyprops:
|
||||
totalnodes = int(embyprops)
|
||||
plexprops = utils.window('Plex.nodes.total')
|
||||
if plexprops:
|
||||
totalnodes = int(plexprops)
|
||||
for i in range(totalnodes):
|
||||
path = utils.window('Emby.nodes.%s.index' % i)
|
||||
path = utils.window('Plex.nodes.%s.index' % i)
|
||||
if not path:
|
||||
path = utils.window('Emby.nodes.%s.content' % i)
|
||||
label = utils.window('Emby.nodes.%s.title' % i)
|
||||
node_type = utils.window('Emby.nodes.%s.type' % i)
|
||||
path = utils.window('Plex.nodes.%s.content' % i)
|
||||
label = utils.window('Plex.nodes.%s.title' % 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.
|
||||
#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":
|
||||
|
@ -315,8 +315,8 @@ def resetDeviceId():
|
|||
def deleteItem():
|
||||
|
||||
# Serves as a keymap action
|
||||
if xbmc.getInfoLabel('ListItem.Property(embyid)'): # If we already have the embyid
|
||||
embyid = xbmc.getInfoLabel('ListItem.Property(embyid)')
|
||||
if xbmc.getInfoLabel('ListItem.Property(plexid)'): # If we already have the plexid
|
||||
plexid = xbmc.getInfoLabel('ListItem.Property(plexid)')
|
||||
else:
|
||||
dbid = xbmc.getInfoLabel('ListItem.DBID')
|
||||
itemtype = xbmc.getInfoLabel('ListItem.DBTYPE')
|
||||
|
@ -342,9 +342,9 @@ def deleteItem():
|
|||
embycursor.close()
|
||||
|
||||
try:
|
||||
embyid = item[0]
|
||||
plexid = item[0]
|
||||
except TypeError:
|
||||
utils.logMsg("EMBY delete", "Unknown embyId, unable to proceed.", 1)
|
||||
utils.logMsg("EMBY delete", "Unknown plexid, unable to proceed.", 1)
|
||||
return
|
||||
|
||||
if utils.settings('skipContextMenu') != "true":
|
||||
|
@ -353,12 +353,12 @@ def deleteItem():
|
|||
line1=("Delete file from Emby Server? This will "
|
||||
"also delete the file(s) from disk!"))
|
||||
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
|
||||
|
||||
doUtils = downloadutils.DownloadUtils()
|
||||
url = "{server}/emby/Items/%s?format=json" % embyid
|
||||
utils.logMsg("EMBY delete", "Deleting request: %s" % embyid, 0)
|
||||
url = "{server}/emby/Items/%s?format=json" % plexid
|
||||
utils.logMsg("EMBY delete", "Deleting request: %s" % plexid, 0)
|
||||
doUtils.downloadUrl(url, action_type="DELETE")
|
||||
|
||||
##### ADD ADDITIONAL USERS #####
|
||||
|
@ -671,9 +671,9 @@ def refreshPlaylist():
|
|||
def GetSubFolders(nodeindex):
|
||||
nodetypes = ["",".recent",".recentepisodes",".inprogress",".inprogressepisodes",".unwatched",".nextepisodes",".sets",".genres",".random",".recommended"]
|
||||
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:
|
||||
path = utils.window('Emby.nodes.%s%s.content' %(nodeindex,node))
|
||||
path = utils.window('Plex.nodes.%s%s.content' %(nodeindex,node))
|
||||
addDirectoryItem(title, path)
|
||||
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||
|
||||
|
@ -775,7 +775,7 @@ def createListItemFromEmbyItem(item,art=artwork.Artwork(),doUtils=downloadutils.
|
|||
premieredatelst = premieredate.split('T')[0].split("-")
|
||||
premieredate = "%s.%s.%s" %(premieredatelst[2],premieredatelst[1],premieredatelst[0])
|
||||
|
||||
li.setProperty("embyid",itemid)
|
||||
li.setProperty("plexid",itemid)
|
||||
|
||||
allart = art.getAllArtwork(item)
|
||||
|
||||
|
@ -1274,7 +1274,7 @@ def getVideoFiles(plexId, params):
|
|||
|
||||
|
||||
##### GET EXTRAFANART FOR LISTITEM #####
|
||||
def getExtraFanArt(embyId,embyPath):
|
||||
def getExtraFanArt(plexid,embyPath):
|
||||
|
||||
emby = embyserver.Read_EmbyServer()
|
||||
art = artwork.Artwork()
|
||||
|
@ -1282,24 +1282,24 @@ def getExtraFanArt(embyId,embyPath):
|
|||
# Get extrafanart for listitem
|
||||
# will be called by skinhelper script to get the extrafanart
|
||||
try:
|
||||
# for tvshows we get the embyid just from the path
|
||||
if not embyId:
|
||||
# for tvshows we get the plexid just from the path
|
||||
if not plexid:
|
||||
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
|
||||
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
|
||||
# because of the caching system in xbmc
|
||||
fanartDir = utils.tryDecode(xbmc.translatePath(
|
||||
"special://thumbnails/emby/%s/" % embyId))
|
||||
"special://thumbnails/emby/%s/" % plexid))
|
||||
|
||||
if not xbmcvfs.exists(fanartDir):
|
||||
# Download the images to the cache directory
|
||||
xbmcvfs.mkdirs(fanartDir)
|
||||
item = emby.getItem(embyId)
|
||||
item = emby.getItem(plexid)
|
||||
if item:
|
||||
backdrops = art.getAllArtwork(item)['Backdrop']
|
||||
tags = item['BackdropImageTags']
|
||||
|
@ -1339,7 +1339,7 @@ def getExtraFanArt(embyId,embyPath):
|
|||
|
||||
|
||||
def RunLibScan(mode):
|
||||
if utils.window('emby_online') != "true":
|
||||
if utils.window('plex_online') != "true":
|
||||
# Server is not online, do not run the sync
|
||||
string = xbmcaddon.Addon().getLocalizedString
|
||||
xbmcgui.Dialog().ok(heading=addonName,
|
||||
|
@ -1708,7 +1708,7 @@ def __LogOut():
|
|||
utils.window('suspend_LibraryThread', value='true')
|
||||
# Wait max for 10 seconds for all lib scans to shutdown
|
||||
counter = 0
|
||||
while utils.window('emby_dbScan') == 'true':
|
||||
while utils.window('plex_dbScan') == 'true':
|
||||
if counter > 200:
|
||||
# Failed to reset PMS and plex.tv connects. Try to restart Kodi.
|
||||
dialog.ok(addonName, string(39208))
|
||||
|
@ -1721,10 +1721,10 @@ def __LogOut():
|
|||
utils.logMsg(title, "Successfully stopped library sync", 1)
|
||||
|
||||
# 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
|
||||
counter = 0
|
||||
while utils.window('emby_serverStatus') == "401":
|
||||
while utils.window('plex_serverStatus') == "401":
|
||||
if counter > 100:
|
||||
# 'Failed to reset PKC. Try to restart Kodi.'
|
||||
dialog.ok(addonName, string(39208))
|
||||
|
|
|
@ -482,7 +482,7 @@ class InitialSetup():
|
|||
goToSettings = dialog.yesno(heading=self.addonName,
|
||||
line1=string(39017))
|
||||
if goToSettings:
|
||||
utils.window('emby_serverStatus', value="Stop")
|
||||
utils.window('plex_serverStatus', value="Stop")
|
||||
xbmc.executebuiltin(
|
||||
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
||||
else:
|
||||
|
|
|
@ -564,11 +564,11 @@ class Movies(Items):
|
|||
# Delete kodi boxset
|
||||
boxset_movies = emby_db.getItem_byParentId(kodiid, "movie")
|
||||
for movie in boxset_movies:
|
||||
embyid = movie[0]
|
||||
plexid = movie[0]
|
||||
movieid = movie[1]
|
||||
self.kodi_db.removefromBoxset(movieid)
|
||||
# Update emby reference
|
||||
emby_db.updateParentId(embyid, None)
|
||||
emby_db.updateParentId(plexid, None)
|
||||
|
||||
kodicursor.execute("DELETE FROM sets WHERE idSet = ?", (kodiid,))
|
||||
|
||||
|
@ -635,7 +635,7 @@ class MusicVideos(Items):
|
|||
|
||||
if not viewtag or not viewid:
|
||||
# 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)
|
||||
|
||||
# fileId information
|
||||
|
@ -672,7 +672,7 @@ class MusicVideos(Items):
|
|||
|
||||
if self.directpath:
|
||||
# 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
|
||||
resp = xbmcgui.Dialog().yesno(
|
||||
heading="Can't validate path",
|
||||
|
@ -683,11 +683,11 @@ class MusicVideos(Items):
|
|||
"to format your path correctly. Stop syncing?"
|
||||
% playurl))
|
||||
if resp:
|
||||
utils.window('emby_shouldStop', value="true")
|
||||
utils.window('plex_shouldStop', value="true")
|
||||
return False
|
||||
|
||||
path = playurl.replace(filename, "")
|
||||
utils.window('emby_pathverified', value="true")
|
||||
utils.window('plex_pathverified', value="true")
|
||||
else:
|
||||
# Set plugin path and media flags using real filename
|
||||
path = "plugin://plugin.video.plexkodiconnect.musicvideos/"
|
||||
|
@ -991,7 +991,7 @@ class TVShows(Items):
|
|||
|
||||
if viewtag is None or viewid is None:
|
||||
# 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)
|
||||
|
||||
# fileId information
|
||||
|
|
|
@ -30,22 +30,22 @@ class KodiMonitor(xbmc.Monitor):
|
|||
def onScanStarted(self, library):
|
||||
self.logMsg("Kodi library scan %s running." % library, 2)
|
||||
if library == "video":
|
||||
utils.window('emby_kodiScan', value="true")
|
||||
utils.window('plex_kodiScan', value="true")
|
||||
|
||||
def onScanFinished(self, library):
|
||||
self.logMsg("Kodi library scan %s finished." % library, 2)
|
||||
if library == "video":
|
||||
utils.window('emby_kodiScan', clear=True)
|
||||
utils.window('plex_kodiScan', clear=True)
|
||||
|
||||
def onSettingsChanged(self):
|
||||
# Monitor emby settings
|
||||
# Review reset setting at a later time, need to be adjusted to account for initial setup
|
||||
# changes.
|
||||
'''currentPath = utils.settings('useDirectPaths')
|
||||
if utils.window('emby_pluginpath') != currentPath:
|
||||
if utils.window('plex_pluginpath') != currentPath:
|
||||
# Plugin path value changed. Offer to reset
|
||||
self.logMsg("Changed to playback mode detected", 1)
|
||||
utils.window('emby_pluginpath', value=currentPath)
|
||||
utils.window('plex_pluginpath', value=currentPath)
|
||||
resp = xbmcgui.Dialog().yesno(
|
||||
heading="Playback mode change detected",
|
||||
line1=(
|
||||
|
@ -56,10 +56,10 @@ class KodiMonitor(xbmc.Monitor):
|
|||
utils.reset()'''
|
||||
|
||||
currentLog = utils.settings('logLevel')
|
||||
if utils.window('emby_logLevel') != currentLog:
|
||||
if utils.window('plex_logLevel') != currentLog:
|
||||
# The log level changed, set new prop
|
||||
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):
|
||||
if method not in ("Playlist.OnAdd"):
|
||||
|
@ -144,7 +144,7 @@ class KodiMonitor(xbmc.Monitor):
|
|||
elif method == "System.OnWake":
|
||||
# Allow network to wake up
|
||||
xbmc.sleep(10000)
|
||||
utils.window('emby_onWake', value="true")
|
||||
utils.window('plex_onWake', value="true")
|
||||
|
||||
elif method == "GUI.OnScreensaverDeactivated":
|
||||
if utils.settings('dbSyncScreensaver') == "true":
|
||||
|
|
|
@ -255,7 +255,7 @@ class ThreadedShowSyncInfo(Thread):
|
|||
|
||||
@utils.logging
|
||||
@utils.ThreadMethodsAdditionalSuspend('suspend_LibraryThread')
|
||||
@utils.ThreadMethodsAdditionalStop('emby_shouldStop')
|
||||
@utils.ThreadMethodsAdditionalStop('plex_shouldStop')
|
||||
@utils.ThreadMethods
|
||||
class LibrarySync(Thread):
|
||||
"""
|
||||
|
@ -298,8 +298,8 @@ class LibrarySync(Thread):
|
|||
'enableBackgroundSync') == "true" else False
|
||||
self.limitindex = int(utils.settings('limitindex'))
|
||||
|
||||
if utils.settings('emby_pathverified') == 'true':
|
||||
utils.window('emby_pathverified', value='true')
|
||||
if utils.settings('plex_pathverified') == 'true':
|
||||
utils.window('plex_pathverified', value='true')
|
||||
|
||||
# Just in case a time sync goes wrong
|
||||
self.timeoffset = int(utils.settings('kodiplextimeoffset'))
|
||||
|
@ -504,7 +504,7 @@ class LibrarySync(Thread):
|
|||
if self.enableMusic:
|
||||
xbmc.executebuiltin('UpdateLibrary(music)')
|
||||
|
||||
utils.window('emby_initialScan', clear=True)
|
||||
utils.window('plex_initialScan', clear=True)
|
||||
xbmc.executebuiltin('InhibitIdleShutdown(false)')
|
||||
utils.setScreensaver(value=screensaver)
|
||||
if utils.window('plex_scancrashed') == 'true':
|
||||
|
@ -513,7 +513,7 @@ class LibrarySync(Thread):
|
|||
utils.window('plex_scancrashed', clear=True)
|
||||
elif utils.window('plex_scancrashed') == '401':
|
||||
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
|
||||
self.dialog.ok(self.addonName, self.__language__(39409))
|
||||
|
||||
|
@ -730,7 +730,7 @@ class LibrarySync(Thread):
|
|||
pass
|
||||
|
||||
# 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
|
||||
with embydb.GetEmbyDB() as emby_db:
|
||||
|
@ -1539,7 +1539,7 @@ class LibrarySync(Thread):
|
|||
try:
|
||||
self.run_internal()
|
||||
except Exception as e:
|
||||
utils.window('emby_dbScan', clear=True)
|
||||
utils.window('plex_dbScan', clear=True)
|
||||
self.logMsg('LibrarySync thread crashed', -1)
|
||||
self.logMsg('Error message: %s' % e, -1)
|
||||
import traceback
|
||||
|
@ -1595,10 +1595,10 @@ class LibrarySync(Thread):
|
|||
return
|
||||
xbmc.sleep(1000)
|
||||
|
||||
if (window('emby_dbCheck') != "true" and installSyncDone):
|
||||
if (window('plex_dbCheck') != "true" and installSyncDone):
|
||||
# Verify the validity of the database
|
||||
currentVersion = settings('dbCreatedWithVersion')
|
||||
minVersion = window('emby_minDBVersion')
|
||||
minVersion = window('plex_minDBVersion')
|
||||
|
||||
if not self.compareDBVersion(currentVersion, minVersion):
|
||||
log("Db version out of date: %s minimum version required: "
|
||||
|
@ -1615,7 +1615,7 @@ class LibrarySync(Thread):
|
|||
utils.reset()
|
||||
break
|
||||
|
||||
window('emby_dbCheck', value="true")
|
||||
window('plex_dbCheck', value="true")
|
||||
|
||||
if not startupComplete:
|
||||
# Also runs when first installed
|
||||
|
@ -1633,7 +1633,7 @@ class LibrarySync(Thread):
|
|||
break
|
||||
|
||||
# Run start up sync
|
||||
window('emby_dbScan', value="true")
|
||||
window('plex_dbScan', value="true")
|
||||
log("Db version: %s" % settings('dbCreatedWithVersion'), 0)
|
||||
lastTimeSync = utils.getUnixTimestamp()
|
||||
self.syncPMStime()
|
||||
|
@ -1641,7 +1641,7 @@ class LibrarySync(Thread):
|
|||
lastSync = utils.getUnixTimestamp()
|
||||
librarySync = fullSync()
|
||||
# Initialize time offset Kodi - PMS
|
||||
window('emby_dbScan', clear=True)
|
||||
window('plex_dbScan', clear=True)
|
||||
if librarySync:
|
||||
log("Initial start-up full sync successful", 0)
|
||||
startupComplete = True
|
||||
|
@ -1661,23 +1661,23 @@ class LibrarySync(Thread):
|
|||
break
|
||||
|
||||
# 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
|
||||
if window('plex_runLibScan') in ("full", "repair"):
|
||||
log('Full library scan requested, starting', 0)
|
||||
window('emby_dbScan', value="true")
|
||||
window('plex_dbScan', value="true")
|
||||
if window('plex_runLibScan') == "full":
|
||||
fullSync()
|
||||
elif window('plex_runLibScan') == "repair":
|
||||
fullSync(repair=True)
|
||||
window('plex_runLibScan', clear=True)
|
||||
window('emby_dbScan', clear=True)
|
||||
window('plex_dbScan', clear=True)
|
||||
# Full library sync finished
|
||||
self.showKodiNote(string(39407), forced=True)
|
||||
# Reset views was requested from somewhere else
|
||||
elif window('plex_runLibScan') == "views":
|
||||
log('Refresh playlist and nodes requested, starting', 0)
|
||||
window('emby_dbScan', value="true")
|
||||
window('plex_dbScan', value="true")
|
||||
window('plex_runLibScan', clear=True)
|
||||
|
||||
# First remove playlists
|
||||
|
@ -1697,36 +1697,36 @@ class LibrarySync(Thread):
|
|||
self.showKodiNote(string(39406),
|
||||
forced=True,
|
||||
icon="error")
|
||||
window('emby_dbScan', clear=True)
|
||||
window('plex_dbScan', clear=True)
|
||||
else:
|
||||
now = utils.getUnixTimestamp()
|
||||
if (now - lastSync > fullSyncInterval and
|
||||
not xbmcplayer.isPlaying()):
|
||||
lastSync = now
|
||||
log('Doing scheduled full library scan', 1)
|
||||
window('emby_dbScan', value="true")
|
||||
window('plex_dbScan', value="true")
|
||||
if fullSync() is False and not threadStopped():
|
||||
log('Could not finish scheduled full sync', -1)
|
||||
self.showKodiNote(string(39410),
|
||||
forced=True,
|
||||
icon='error')
|
||||
window('emby_dbScan', clear=True)
|
||||
window('plex_dbScan', clear=True)
|
||||
# Full library sync finished
|
||||
self.showKodiNote(string(39407), forced=False)
|
||||
elif now - lastTimeSync > oneDay:
|
||||
lastTimeSync = now
|
||||
log('Starting daily time sync', 0)
|
||||
window('emby_dbScan', value="true")
|
||||
window('plex_dbScan', value="true")
|
||||
self.syncPMStime()
|
||||
window('emby_dbScan', clear=True)
|
||||
window('plex_dbScan', clear=True)
|
||||
elif enableBackgroundSync:
|
||||
# Check back whether we should process something
|
||||
# Only do this once every 10 seconds
|
||||
if now - lastProcessing > 10:
|
||||
lastProcessing = now
|
||||
window('emby_dbScan', value="true")
|
||||
window('plex_dbScan', value="true")
|
||||
processItems()
|
||||
window('emby_dbScan', clear=True)
|
||||
window('plex_dbScan', clear=True)
|
||||
# See if there is a PMS message we need to handle
|
||||
try:
|
||||
message = queue.get(block=False)
|
||||
|
@ -1735,10 +1735,10 @@ class LibrarySync(Thread):
|
|||
continue
|
||||
# Got a message from PMS; process it
|
||||
else:
|
||||
window('emby_dbScan', value="true")
|
||||
window('plex_dbScan', value="true")
|
||||
processMessage(message)
|
||||
queue.task_done()
|
||||
window('emby_dbScan', clear=True)
|
||||
window('plex_dbScan', clear=True)
|
||||
# NO sleep!
|
||||
continue
|
||||
else:
|
||||
|
|
|
@ -65,14 +65,14 @@ def getEmbyRatingFromKodiRating(rating):
|
|||
if (rating >= 5): favourite = True
|
||||
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()
|
||||
|
||||
previous_values = None
|
||||
filename = API.getFilePath()
|
||||
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.
|
||||
if enableimportsongrating:
|
||||
|
@ -83,7 +83,7 @@ def getAdditionalSongTags(embyid, emby_rating, API, kodicursor, emby_db, enablei
|
|||
hasEmbeddedCover = False
|
||||
|
||||
|
||||
emby_dbitem = emby_db.getItem_byId(embyid)
|
||||
emby_dbitem = emby_db.getItem_byId(plexid)
|
||||
try:
|
||||
kodiid = emby_dbitem[0]
|
||||
except TypeError:
|
||||
|
@ -100,44 +100,44 @@ def getAdditionalSongTags(embyid, emby_rating, API, kodicursor, emby_db, enablei
|
|||
if file_rating is None and currentvalue:
|
||||
return (currentvalue, comment, False)
|
||||
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
|
||||
updateEmbyRating = False
|
||||
|
||||
if currentvalue != None:
|
||||
# we need to translate the emby values...
|
||||
if emby_rating == 1 and currentvalue == 2:
|
||||
emby_rating = 2
|
||||
if emby_rating == 3 and currentvalue == 4:
|
||||
emby_rating = 4
|
||||
if plex_rating == 1 and currentvalue == 2:
|
||||
plex_rating = 2
|
||||
if plex_rating == 3 and currentvalue == 4:
|
||||
plex_rating = 4
|
||||
|
||||
#if updating rating into file is disabled, we ignore the rating in the file...
|
||||
if not enableupdatesongrating:
|
||||
file_rating = currentvalue
|
||||
#if convert emby likes/favourites convert to song rating is disabled, we ignore the emby rating...
|
||||
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
|
||||
rating = currentvalue
|
||||
updateFileRating = 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
|
||||
rating = emby_rating
|
||||
rating = plex_rating
|
||||
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
|
||||
rating = file_rating
|
||||
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...
|
||||
if emby_rating > file_rating:
|
||||
rating = emby_rating
|
||||
if plex_rating > file_rating:
|
||||
rating = plex_rating
|
||||
updateFileRating = True
|
||||
else:
|
||||
rating = file_rating
|
||||
|
@ -152,16 +152,16 @@ def getAdditionalSongTags(embyid, emby_rating, API, kodicursor, emby_db, enablei
|
|||
rating = file_rating
|
||||
#determine if we should also send the rating to emby server
|
||||
if enableexportsongrating:
|
||||
if emby_rating == 1 and file_rating == 2:
|
||||
emby_rating = 2
|
||||
if emby_rating == 3 and file_rating == 4:
|
||||
emby_rating = 4
|
||||
if emby_rating != file_rating:
|
||||
if plex_rating == 1 and file_rating == 2:
|
||||
plex_rating = 2
|
||||
if plex_rating == 3 and file_rating == 4:
|
||||
plex_rating = 4
|
||||
if plex_rating != file_rating:
|
||||
updateEmbyRating = True
|
||||
|
||||
elif enableexportsongrating:
|
||||
#set the initial rating to emby value
|
||||
rating = emby_rating
|
||||
rating = plex_rating
|
||||
|
||||
if updateFileRating and enableupdatesongrating:
|
||||
updateRatingToFile(rating, filename)
|
||||
|
@ -169,8 +169,8 @@ def getAdditionalSongTags(embyid, emby_rating, API, kodicursor, emby_db, enablei
|
|||
if updateEmbyRating and enableexportsongrating:
|
||||
# sync details to emby server. Translation needed between ID3 rating and emby likes/favourites:
|
||||
like, favourite, deletelike = getEmbyRatingFromKodiRating(rating)
|
||||
utils.window("ignore-update-%s" %embyid, "true") #set temp windows prop to ignore the update from webclient update
|
||||
emby.updateUserRating(embyid, like, favourite, deletelike)
|
||||
utils.window("ignore-update-%s" %plexid, "true") #set temp windows prop to ignore the update from webclient update
|
||||
emby.updateUserRating(plexid, like, favourite, deletelike)
|
||||
|
||||
return (rating, comment, hasEmbeddedCover)
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ class PlaybackUtils():
|
|||
sizePlaylist = playlist.size()
|
||||
self.currentPosition = startPos
|
||||
|
||||
propertiesPlayback = window('emby_playbackProps') == "true"
|
||||
propertiesPlayback = window('plex_playbackProps') == "true"
|
||||
introsPlaylist = False
|
||||
dummyPlaylist = False
|
||||
|
||||
|
@ -112,11 +112,11 @@ class PlaybackUtils():
|
|||
# Otherwise we get a loop.
|
||||
if not propertiesPlayback:
|
||||
|
||||
window('emby_playbackProps', value="true")
|
||||
window('plex_playbackProps', value="true")
|
||||
self.logMsg("Setting up properties in playlist.", 1)
|
||||
|
||||
if (not homeScreen and not seektime and
|
||||
window('emby_customPlaylist') != "true"):
|
||||
window('plex_customplaylist') != "true"):
|
||||
self.logMsg("Adding dummy file to playlist.", 2)
|
||||
dummyPlaylist = True
|
||||
playlist.add(playurl, listitem, index=startPos)
|
||||
|
@ -187,7 +187,7 @@ class PlaybackUtils():
|
|||
# We just skipped adding properties. Reset flag for next time.
|
||||
elif propertiesPlayback:
|
||||
self.logMsg("Resetting properties playback flag.", 2)
|
||||
window('emby_playbackProps', clear=True)
|
||||
window('plex_playbackProps', clear=True)
|
||||
|
||||
#self.pl.verifyPlaylist()
|
||||
########## SETUP MAIN ITEM ##########
|
||||
|
@ -204,12 +204,12 @@ class PlaybackUtils():
|
|||
|
||||
############### 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)
|
||||
API.CreateListItemFromPlexItem(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)):
|
||||
# Playlist was created just now, play it.
|
||||
self.logMsg("Play playlist.", 1)
|
||||
|
|
|
@ -104,12 +104,12 @@ class Player(xbmc.Player):
|
|||
|
||||
self.logMsg("Playing itemtype is: %s" % itemType, 1)
|
||||
|
||||
customseek = window('emby_customPlaylist.seektime')
|
||||
if (window('emby_customPlaylist') == "true" and customseek):
|
||||
customseek = window('plex_customplaylist.seektime')
|
||||
if (window('plex_customplaylist') == "true" and customseek):
|
||||
# Start at, when using custom playlist (play to Kodi from webclient)
|
||||
self.logMsg("Seeking to: %s" % customseek, 1)
|
||||
self.xbmcplayer.seekTime(int(customseek))
|
||||
window('emby_customPlaylist.seektime', clear=True)
|
||||
window('plex_customplaylist.seektime', clear=True)
|
||||
|
||||
seekTime = self.xbmcplayer.getTime()
|
||||
|
||||
|
@ -452,9 +452,9 @@ class Player(xbmc.Player):
|
|||
self.stopAll()
|
||||
|
||||
window('Plex_currently_playing_itemid', clear=True)
|
||||
window('emby_customPlaylist', clear=True)
|
||||
window('emby_customPlaylist.seektime', clear=True)
|
||||
window('emby_customPlaylist.seektime', clear=True)
|
||||
window('plex_customplaylist', clear=True)
|
||||
window('plex_customplaylist.seektime', clear=True)
|
||||
window('plex_customplaylist.seektime', clear=True)
|
||||
self.logMsg("Clear playlist properties.", 1)
|
||||
|
||||
def onPlayBackEnded(self):
|
||||
|
|
|
@ -41,11 +41,11 @@ class Playlist():
|
|||
self.logMsg("Items: %s and start at: %s" % (itemids, startat), 1)
|
||||
|
||||
started = False
|
||||
window('emby_customplaylist', value="true")
|
||||
window('plex_customplaylist', value="true")
|
||||
|
||||
if startat != 0:
|
||||
# Seek to the starting position
|
||||
window('emby_customplaylist.seektime', str(startat))
|
||||
window('plex_customplaylist.seektime', str(startat))
|
||||
|
||||
with embydb.GetEmbyDB() as emby_db:
|
||||
for itemid in itemids:
|
||||
|
|
|
@ -81,8 +81,8 @@ class Read_EmbyServer():
|
|||
|
||||
return items
|
||||
|
||||
def getView_embyId(self, itemid):
|
||||
# Returns ancestors using embyId
|
||||
def getView_plexid(self, itemid):
|
||||
# Returns ancestors using plexid
|
||||
viewId = None
|
||||
|
||||
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)
|
||||
|
||||
retry = 0
|
||||
while utils.window('emby_online') != "true":
|
||||
while utils.window('plex_online') != "true":
|
||||
# Wait server to come back online
|
||||
if retry == 5:
|
||||
self.logMsg("Unable to reconnect to server. Abort process.", 1)
|
||||
|
|
|
@ -131,14 +131,14 @@ class UserClient(threading.Thread):
|
|||
log("Access is restricted.", 1)
|
||||
self.HasAccess = False
|
||||
|
||||
elif window('emby_online') != "true":
|
||||
elif window('plex_online') != "true":
|
||||
# Server connection failed
|
||||
pass
|
||||
|
||||
elif window('emby_serverStatus') == "restricted":
|
||||
elif window('plex_serverStatus') == "restricted":
|
||||
log("Access is granted.", 1)
|
||||
self.HasAccess = True
|
||||
window('emby_serverStatus', clear=True)
|
||||
window('plex_serverStatus', clear=True)
|
||||
xbmcgui.Dialog().notification(self.addonName,
|
||||
utils.language(33007))
|
||||
|
||||
|
@ -239,7 +239,7 @@ class UserClient(threading.Thread):
|
|||
# Give attempts at entering password / selecting user
|
||||
if self.retry >= 2:
|
||||
log("Too many retries to login.", -1)
|
||||
window('emby_serverStatus', value="Stop")
|
||||
window('plex_serverStatus', value="Stop")
|
||||
dialog.ok(lang(33001),
|
||||
lang(39023))
|
||||
xbmc.executebuiltin(
|
||||
|
@ -358,7 +358,7 @@ class UserClient(threading.Thread):
|
|||
break
|
||||
xbmc.sleep(1000)
|
||||
|
||||
status = window('emby_serverStatus')
|
||||
status = window('plex_serverStatus')
|
||||
|
||||
if status == "Stop":
|
||||
xbmc.sleep(500)
|
||||
|
@ -371,7 +371,7 @@ class UserClient(threading.Thread):
|
|||
|
||||
elif status == "401":
|
||||
# Unauthorized access, revoke token
|
||||
window('emby_serverStatus', value="Auth")
|
||||
window('plex_serverStatus', value="Auth")
|
||||
self.resetClient()
|
||||
xbmc.sleep(2000)
|
||||
|
||||
|
@ -389,7 +389,7 @@ class UserClient(threading.Thread):
|
|||
log("Current accessToken: xxxx", 1)
|
||||
self.retry = 0
|
||||
window('suspend_LibraryThread', clear=True)
|
||||
window('emby_serverStatus', clear=True)
|
||||
window('plex_serverStatus', clear=True)
|
||||
|
||||
if not self.auth and (self.currUser is None):
|
||||
# Loop if no server found
|
||||
|
|
|
@ -254,7 +254,7 @@ def getUnixTimestamp(secondsIntoTheFuture=None):
|
|||
def logMsg(title, msg, level=1):
|
||||
# Get the logLevel set in UserClient
|
||||
try:
|
||||
logLevel = int(window('emby_logLevel'))
|
||||
logLevel = int(window('plex_logLevel'))
|
||||
except ValueError:
|
||||
logLevel = 0
|
||||
kodiLevel = {
|
||||
|
@ -414,9 +414,9 @@ def reset():
|
|||
return
|
||||
|
||||
# first stop any db sync
|
||||
window('emby_shouldStop', value="true")
|
||||
window('plex_shouldStop', value="true")
|
||||
count = 10
|
||||
while window('emby_dbScan') == "true":
|
||||
while window('plex_dbScan') == "true":
|
||||
logMsg("PLEX", "Sync is running, will retry: %s..." % count)
|
||||
count -= 1
|
||||
if count == 0:
|
||||
|
|
|
@ -98,13 +98,13 @@ class VideoNodes(object):
|
|||
path = "library://video/Plex-%s/" % dirname
|
||||
for i in range(1, indexnumber):
|
||||
# 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
|
||||
|
||||
if mediatype == "photo":
|
||||
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
|
||||
if not mediatype == "photo":
|
||||
|
@ -259,13 +259,13 @@ class VideoNodes(object):
|
|||
else:
|
||||
templabel = label
|
||||
|
||||
embynode = "Emby.nodes.%s" % indexnumber
|
||||
embynode = "Plex.nodes.%s" % indexnumber
|
||||
window('%s.title' % embynode, value=templabel)
|
||||
window('%s.path' % embynode, value=windowpath)
|
||||
window('%s.content' % embynode, value=path)
|
||||
window('%s.type' % embynode, value=mediatype)
|
||||
else:
|
||||
embynode = "Emby.nodes.%s.%s" % (indexnumber, nodetype)
|
||||
embynode = "Plex.nodes.%s.%s" % (indexnumber, nodetype)
|
||||
window('%s.title' % embynode, value=label)
|
||||
window('%s.path' % embynode, value=windowpath)
|
||||
window('%s.content' % embynode, value=path)
|
||||
|
@ -389,7 +389,7 @@ class VideoNodes(object):
|
|||
'channels': 30173
|
||||
}
|
||||
label = utils.language(labels[tagname])
|
||||
embynode = "Emby.nodes.%s" % indexnumber
|
||||
embynode = "Plex.nodes.%s" % indexnumber
|
||||
window('%s.title' % embynode, value=label)
|
||||
window('%s.path' % embynode, value=windowpath)
|
||||
window('%s.content' % embynode, value=path)
|
||||
|
@ -418,7 +418,7 @@ class VideoNodes(object):
|
|||
window = utils.window
|
||||
|
||||
self.logMsg("Clearing nodes properties.", 1)
|
||||
embyprops = window('Emby.nodes.total')
|
||||
plexprops = window('Plex.nodes.total')
|
||||
propnames = [
|
||||
|
||||
"index","path","title","content",
|
||||
|
@ -433,8 +433,8 @@ class VideoNodes(object):
|
|||
"inprogressepisodes.content","inprogressepisodes.path"
|
||||
]
|
||||
|
||||
if embyprops:
|
||||
totalnodes = int(embyprops)
|
||||
if plexprops:
|
||||
totalnodes = int(plexprops)
|
||||
for i in range(totalnodes):
|
||||
for prop in propnames:
|
||||
window('Emby.nodes.%s.%s' % (str(i), prop), clear=True)
|
||||
window('Plex.nodes.%s.%s' % (str(i), prop), clear=True)
|
|
@ -138,7 +138,7 @@ class WebSocket(threading.Thread):
|
|||
if counter > 10:
|
||||
log("Repeatedly could not connect to PMS, declaring "
|
||||
"the connection dead", -1)
|
||||
utils.window('emby_online', value='false')
|
||||
utils.window('plex_online', value='false')
|
||||
counter = 0
|
||||
xbmc.sleep(1000)
|
||||
except websocket.WebSocketTimeoutException:
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<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="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="FanArtTVAPIKey" type="text" default="639191cb0774661597f28a47e7e2bad5" visible="false"/>
|
||||
</category>
|
||||
|
|
41
service.py
41
service.py
|
@ -72,9 +72,9 @@ class Service():
|
|||
logLevel = self.getLogLevel()
|
||||
self.monitor = xbmc.Monitor()
|
||||
|
||||
window('emby_logLevel', value=str(logLevel))
|
||||
window('emby_kodiProfile', value=xbmc.translatePath("special://profile"))
|
||||
window('emby_pluginpath', value=utils.settings('useDirectPaths'))
|
||||
window('plex_logLevel', value=str(logLevel))
|
||||
window('plex_kodiProfile', value=xbmc.translatePath("special://profile"))
|
||||
window('plex_pluginpath', value=utils.settings('useDirectPaths'))
|
||||
|
||||
# Initial logging
|
||||
log("======== START %s ========" % self.addonName, 0)
|
||||
|
@ -87,10 +87,10 @@ class Service():
|
|||
# Reset window props for profile switch
|
||||
properties = [
|
||||
|
||||
"emby_online", "emby_serverStatus", "emby_onWake",
|
||||
"emby_syncRunning", "emby_dbCheck", "emby_kodiScan",
|
||||
"emby_shouldStop", "currUserId", "emby_dbScan", "emby_sessionId",
|
||||
"emby_initialScan", "emby_customplaylist", "emby_playbackProps",
|
||||
"plex_online", "plex_serverStatus", "plex_onWake",
|
||||
"plex_dbCheck", "plex_kodiScan",
|
||||
"plex_shouldStop", "currUserId", "plex_dbScan",
|
||||
"plex_initialScan", "plex_customplaylist", "plex_playbackProps",
|
||||
"plex_runLibScan", "plex_username", "pms_token", "plex_token",
|
||||
"pms_server", "plex_machineIdentifier", "plex_servername",
|
||||
"plex_authenticated", "PlexUserImage", "useDirectPaths",
|
||||
|
@ -106,7 +106,7 @@ class Service():
|
|||
videonodes.VideoNodes().clearProperties()
|
||||
|
||||
# Set the minimum database version
|
||||
window('emby_minDBVersion', value="1.1.5")
|
||||
window('plex_minDBVersion', value="1.1.5")
|
||||
|
||||
def getLogLevel(self):
|
||||
try:
|
||||
|
@ -148,10 +148,11 @@ class Service():
|
|||
counter = 0
|
||||
while not monitor.abortRequested():
|
||||
|
||||
if window('emby_kodiProfile') != kodiProfile:
|
||||
if window('plex_kodiProfile') != kodiProfile:
|
||||
# Profile change happened, terminate this thread and others
|
||||
log("Kodi profile was: %s and changed to: %s. Terminating old Emby thread."
|
||||
% (kodiProfile, utils.window('emby_kodiProfile')), 1)
|
||||
log("Kodi profile was: %s and changed to: %s. Terminating old "
|
||||
"PlexKodiConnect thread."
|
||||
% (kodiProfile, utils.window('plex_kodiProfile')), 1)
|
||||
|
||||
break
|
||||
|
||||
|
@ -160,8 +161,8 @@ class Service():
|
|||
# 2. User is set
|
||||
# 3. User has access to the server
|
||||
|
||||
if window('emby_online') == "true":
|
||||
# Emby server is online
|
||||
if window('plex_online') == "true":
|
||||
# Plex server is online
|
||||
# Verify if user is set and has access to the server
|
||||
if (user.currUser is not None) and user.HasAccess:
|
||||
# If an item is playing
|
||||
|
@ -179,15 +180,15 @@ class Service():
|
|||
td = datetime.today() - lastProgressUpdate
|
||||
secDiff = td.seconds
|
||||
|
||||
# Report progress to Emby server
|
||||
# Report progress to Plex server
|
||||
if (secDiff > 3):
|
||||
kplayer.reportPlayback()
|
||||
lastProgressUpdate = datetime.today()
|
||||
|
||||
elif window('emby_command') == "true":
|
||||
elif window('plex_command') == "true":
|
||||
# Received a remote control command that
|
||||
# requires updating immediately
|
||||
window('emby_command', clear=True)
|
||||
window('plex_command', clear=True)
|
||||
kplayer.reportPlayback()
|
||||
lastProgressUpdate = datetime.today()
|
||||
except Exception as e:
|
||||
|
@ -235,7 +236,7 @@ class Service():
|
|||
# Verify access with an API call
|
||||
user.hasAccess()
|
||||
|
||||
if window('emby_online') != "true":
|
||||
if window('plex_online') != "true":
|
||||
# Server went offline
|
||||
break
|
||||
|
||||
|
@ -256,7 +257,7 @@ class Service():
|
|||
# Alert the user and suppress future warning
|
||||
if self.server_online:
|
||||
log("Server is offline.", -1)
|
||||
window('emby_online', value="false")
|
||||
window('plex_online', value="false")
|
||||
# Suspend threads
|
||||
window('suspend_LibraryThread', value='true')
|
||||
xbmcgui.Dialog().notification(
|
||||
|
@ -294,7 +295,7 @@ class Service():
|
|||
sound=False)
|
||||
self.server_online = True
|
||||
log("Server %s is online and ready." % server, 1)
|
||||
window('emby_online', value="true")
|
||||
window('plex_online', value="true")
|
||||
if window('plex_authenticated') == 'true':
|
||||
# Server got offline when we were authenticated.
|
||||
# Hence resume threads
|
||||
|
@ -353,6 +354,6 @@ delay = int(utils.settings('startupDelay'))
|
|||
xbmc.log("Delaying Plex startup by: %s sec..." % delay)
|
||||
if delay and xbmc.Monitor().waitForAbort(delay):
|
||||
# Start the service
|
||||
xbmc.log("Abort requested while waiting. Emby for kodi not started.")
|
||||
xbmc.log("Abort requested while waiting. PKC not started.")
|
||||
else:
|
||||
Service().ServiceEntryPoint()
|
||||
|
|
Loading…
Reference in a new issue