Fix some stuff with chromecast adapter

This commit is contained in:
Sumner Evans
2020-06-17 22:07:27 -06:00
parent 3acd8d8a49
commit fc8b90c8a5
2 changed files with 6 additions and 7 deletions

View File

@@ -163,7 +163,7 @@ class ChromecastPlayer(Player):
pass
_serving_song_id = multiprocessing.Array("c", 1024) # huge buffer, just in case
_serving_token = multiprocessing.Array("c", 12)
_serving_token = multiprocessing.Array("c", 16)
def _run_server_process(self, host: str, port: int):
app = bottle.Bottle()
@@ -233,10 +233,8 @@ class ChromecastPlayer(Player):
assert self._current_chromecast
scheme = urlparse(uri).scheme
if scheme == "file":
token = base64.b64encode(os.urandom(8)).decode("ascii")
for r in (("+", "."), ("/", "-"), ("=", "_")):
token = token.replace(*r)
self._serving_token.value = token.encode()
token = base64.b16encode(os.urandom(8))
self._serving_token.value = token
self._serving_song_id.value = song.id.encode()
# If this fails, then we are basically screwed, so don't care if it blows
@@ -248,7 +246,8 @@ class ChromecastPlayer(Player):
host_ip = s.getsockname()[0]
s.close()
uri = f"http://{host_ip}:{self.config.get(LAN_PORT_KEY)}/s/{token}"
uri = f"http://{host_ip}:{self.config.get(LAN_PORT_KEY)}/s/{token.decode()}"
print(uri)
cover_art_url = AdapterManager.get_cover_art_uri(song.cover_art, size=1000)
self._current_chromecast.media_controller.play_media(

View File

@@ -433,7 +433,7 @@ class PlayerControls(Gtk.ActionBar):
)
)
for player_id, player_name in players:
for player_id, player_name in sorted(players, key=lambda p: p[1]):
icon = (
"audio-volume-high-symbolic"
if player_id == self.current_device