diff --git a/sublime/players/chromecast.py b/sublime/players/chromecast.py index 07e5e41..fe6f538 100644 --- a/sublime/players/chromecast.py +++ b/sublime/players/chromecast.py @@ -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( diff --git a/sublime/ui/player_controls.py b/sublime/ui/player_controls.py index 541a54c..eadd081 100644 --- a/sublime/ui/player_controls.py +++ b/sublime/ui/player_controls.py @@ -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