def get_spotty_binary(self):
'''find the correct spotty binary belonging to the platform'''
sp_binary = None
if xbmc.getCondVisibility("System.Platform.Windows"):
sp_binary = os.path.join(os.path.dirname(__file__), "spotty", "windows", "spotty.exe")
self.supports_discovery = False # The current MDNS implementation cannot be built on Windows
elif xbmc.getCondVisibility("System.Platform.OSX"):
# macos binary is x86_64 intel
sp_binary = os.path.join(os.path.dirname(__file__), "spotty", "darwin", "spotty")
elif xbmc.getCondVisibility("System.Platform.Linux + !System.Platform.Android"):
# try to find out the correct architecture by trial and error
import platform
architecture = platform.machine()
log_msg("reported architecture: %s" % architecture)
if architecture.startswith('AMD64') or architecture.startswith('x86_64'):
# generic linux x86_64 binary
sp_binary = os.path.join(os.path.dirname(__file__), "spotty", "x86-linux", "spotty-x86_64")
else:
# just try to get the correct binary path if we're unsure about the platform/cpu
paths = []
paths.append(os.path.join(os.path.dirname(__file__), "spotty", "arm-linux", "spotty-muslhf"))
paths.append(os.path.join(os.path.dirname(__file__), "spotty", "arm-linux", "spotty-hf"))
paths.append(os.path.join(os.path.dirname(__file__), "spotty", "x86-linux", "spotty"))
for binary_path in paths:
if self.test_spotty(binary_path):
sp_binary = binary_path
break
if sp_binary:
st = os.stat(sp_binary)
os.chmod(sp_binary, st.st_mode | stat.S_IEXEC)
log_msg("Architecture detected. Using spotty binary %s" % sp_binary)
else:
log_msg("Failed to detect architecture or platform not supported ! Local playback will not be available.")
return sp_binary
评论列表
文章目录