return None
# make sure that the token is still valid by just requesting it
await self.get_token()
- spotty = self.get_spotty_binary()
+ spotty = await self.get_spotty_binary()
spotty_exec = f'{spotty} -n temp -c "/tmp" -b 320 --pass-through --single-track spotify://track:{track.item_id}'
return StreamDetails(
type=StreamType.EXECUTABLE,
]
scope = ",".join(scopes)
args = [
- self.get_spotty_binary(),
+ await self.get_spotty_binary(),
"-t",
"--client-id",
get_app_var(2),
) as response:
return await response.text()
- @staticmethod
- def get_spotty_binary():
+ async def get_spotty_binary(self):
"""Find the correct spotty binary belonging to the platform."""
if platform.system() == "Windows":
return os.path.join(
if platform.system() == "Darwin":
# macos binary is x86_64 intel
return os.path.join(os.path.dirname(__file__), "spotty", "osx", "spotty")
+
if platform.system() == "Linux":
architecture = platform.machine()
if architecture in ["AMD64", "x86_64"]:
os.path.dirname(__file__), "spotty", "linux", "spotty-i386"
)
if "aarch64" in architecture or "armv8" in architecture:
- # arm64 linux binary
- return os.path.join(
+ # try arm64 linux binary, fallback to 32 bits
+ spotty_path = os.path.join(
os.path.dirname(__file__), "spotty", "linux", "spotty-aarch64"
)
+ try:
+ spotty = await asyncio.create_subprocess_exec(
+ *[spotty_path, "-V"], stdout=asyncio.subprocess.PIPE
+ )
+ stdout, _ = await spotty.communicate()
+ if spotty.returncode == 0 and b"librespot" in stdout:
+ return spotty_path
+ except OSError as err:
+ self.logger.exception(
+ "failed to start arm64 spotty binary, fallback to 32 bits",
+ exc_info=err,
+ )
# assume armv7
return os.path.join(
os.path.dirname(__file__), "spotty", "linux", "spotty-armhf"