Only copy syncplay.lua when needed

This commit is contained in:
Etoh 2019-02-09 17:58:26 +00:00
parent 89f8a28f3f
commit d8ebb50da7
3 changed files with 39 additions and 35 deletions

View File

@ -5,7 +5,7 @@
Principal author: Etoh
Other contributors: DerGenaue, jb, Pilotat
Project: https://syncplay.pl/
Version: 0.3.4
Version: 0.3.5
Note:
* This interface module is intended to be used in conjunction with Syncplay.
@ -78,7 +78,7 @@ Syncplay should install this automatically to your user folder.
--]==========================================================================]
local connectorversion = "0.3.4"
local connectorversion = "0.3.5"
local vlcversion = vlc.misc.version()
local vlcmajorversion = tonumber(vlcversion:sub(1,1)) -- get the major version of VLC
local durationdelay = 500000 -- Pause for get_duration command etc for increased reliability (uses microseconds)

View File

@ -102,7 +102,7 @@ COMMANDS_TOGGLE = ['t', 'toggle']
MPC_MIN_VER = "1.6.4"
MPC_BE_MIN_VER = "1.5.2.3123"
VLC_MIN_VERSION = "2.2.1"
VLC_INTERFACE_MIN_VERSION = "0.3.4"
VLC_INTERFACE_VERSION = "0.3.5"
VLC_LATENCY_ERROR_THRESHOLD = 2.0
MPV_UNRESPONSIVE_THRESHOLD = 60.0
CONTROLLED_ROOMS_MIN_VERSION = "1.3.0"

View File

@ -341,22 +341,6 @@ class VlcPlayer(BasePlayer):
call.append(filePath)
else:
call.append(self.__playerController.getMRL(filePath))
def _usevlcintf(vlcIntfPath, vlcIntfUserPath):
vlcSyncplayInterfacePath = vlcIntfPath + "syncplay.lua"
if not os.path.isfile(vlcSyncplayInterfacePath):
vlcSyncplayInterfacePath = vlcIntfUserPath + "syncplay.lua"
if os.path.isfile(vlcSyncplayInterfacePath):
with open(vlcSyncplayInterfacePath, 'rU') as interfacefile:
for line in interfacefile:
if "local connectorversion" in line:
interface_version = line[26:31]
if utils.meetsMinVersion(interface_version, constants.VLC_INTERFACE_MIN_VERSION):
return True
else:
self.oldIntfVersion = line[26:31]
return False
return False
if isLinux():
playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
@ -373,6 +357,26 @@ class VlcPlayer(BasePlayer):
playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/"
playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"
def _intfNeedsUpdating(vlcSyncplayInterfacePath):
self.__playerController._client.ui.showDebugMessage("Checking if '{}' exists and if it is the expected version".format(vlcSyncplayInterfacePath))
if not os.path.isfile(vlcSyncplayInterfacePath):
self.__playerController._client.ui.showDebugMessage("syncplay.lua not found, so file needs copying")
return True
if os.path.isfile(vlcSyncplayInterfacePath):
with open(vlcSyncplayInterfacePath, 'rU') as interfacefile:
for line in interfacefile:
if "local connectorversion" in line:
interface_version = line[26:31]
if interface_version == constants.VLC_INTERFACE_VERSION:
self.__playerController._client.ui.showDebugMessage("syncplay.lua exists and is expected version, so no file needs copying")
return False
else:
self.oldIntfVersion = line[26:31]
self.__playerController._client.ui.showDebugMessage("syncplay.lua is {} but expected version is {} so file needs to be copied".format(interface_version, constants.VLC_INTERFACE_VERSION))
return True
self.__playerController._client.ui.showDebugMessage("Up-to-dateness checks failed, so copy the file.")
return True
if _intfNeedsUpdating(os.path.join(playerController.vlcIntfUserPath, "syncplay.lua")):
try:
copyForm = utils.findResourcePath("syncplay.lua")
copyTo = os.path.join(playerController.vlcIntfUserPath, "syncplay.lua")
@ -381,7 +385,7 @@ class VlcPlayer(BasePlayer):
shutil.copyfile(copyForm, copyTo)
except Exception as e:
playerController._client.ui.showErrorMessage(e)
else:
return
if isLinux():
playerController.vlcDataPath = "/usr/lib/syncplay/resources"
else: