aome510 / spotify-player

A Spotify player in the terminal with full feature parity
MIT License
3.37k stars 147 forks source link

Support discovering zeroconf devices #187

Closed flexwie closed 1 year ago

flexwie commented 1 year ago

Describe the bug The devices pane does not show my spotifyd instance running on my machine. The official player and mobile app are both showing it to me. Other Spotify Connect devices are shown in spotify-player.

To Reproduce Install spotify-player and spotifyd, run spotifyd in the background.

Expected behavior Spotifyd should be shown like any other Connect device.

Environment

Additional context I have the client ID set up in my config and no username/password as per the docs.

aome510 commented 1 year ago

I have the client ID set up in my config and no username/password as per the docs

I assume you already followed this doc (https://github.com/aome510/spotify-player#spotify-connect).

Can you provide logs in ~/.cache/spotify-player?

flexwie commented 1 year ago

I added the id of the client I created to my config. This is my config right now:

client_id = "8f03b7ae0a8a45bf9dxxxxxxxxx"
enable_media_control = true
default_device = "spotify-player"

[device]
name = "spotify-player"
volume = 100
device_type = "speaker"
bitrate = 160
audio_cache = false

I habe quite a few logs in that folder, is there anything particular you are looking for? This is the latest (I skipped the keymap and auth part)

2023-05-04T06:26:47.252425Z  INFO spotify_player::state: General configurations: AppConfig { theme: "dracula", client_id: "8f03b7ae0a8a45bf9dxxxxxxxxxx", copy_command: Command { command: "pbcopy", args: [] }, pl
ayback_format: "{track} • {artists}\n{album}\n{metadata}", proxy: None, ap_port: None, app_refresh_duration_in_ms: 32, playback_refresh_duration_in_ms: 0, cover_image_refresh_duration_in_ms: 2000, page_size_in_rows:
 20, track_table_item_max_len: 32, play_icon: "▶", pause_icon: "▌▌", liked_icon: "♥", border_type: Plain, progress_bar_type: Rectangle, playback_window_position: Top, cover_img_length: 9, cover_img_width: 5, cover_i
mg_scale: 1.0, playback_window_width: 6, enable_media_control: true, enable_streaming: true, enable_cover_image_cache: true, default_device: "spotify-player", device: DeviceConfig { name: "spotify-player", device_ty
pe: "speaker", volume: 100, bitrate: 160, audio_cache: false } }
2023-05-04T06:26:47.252642Z  WARN spotify_player::config::theme: Failed to open the theme config file (path="/Users/flexwie/.config/spotify-player/theme.toml"): No such file or directory (os error 2). Use the defaul
t configurations instead
2023-05-04T06:26:47.252664Z  INFO spotify_player::state: Theme configurations: ThemeConfig { themes: [Theme { name: "default", palette: Palette { background: None, foreground: None, black: Color { color: Black }, bl
ue: Color { color: LightBlue }, cyan: Color { color: LightCyan }, green: Color { color: LightGreen }, magenta: Color { color: LightMagenta }, red: Color { color: LightRed }, white: Color { color: Gray }, yellow: Col
or { color: LightYellow }, bright_black: Color { color: DarkGray }, bright_white: Color { color: White }, bright_red: Color { color: Red }, bright_magenta: Color { color: Magenta }, bright_green: Color { color: Gree
n }, bright_cyan: Color { color: Cyan }, bright_blue: Color { color: Blue }, bright_yellow: Color { color: Yellow } }, component_style: ComponentStyle { block_title: None, border: None, playback_track: None, playbac
k_artists: None, playback_album: None, playback_metadata: None, playback_progress_bar: None, current_playing: None, page_desc: None, table_header: None, selection: None } }] }
2023-05-04T06:26:47.252696Z  WARN spotify_player::config::keymap: Failed to open the keymap config file (path="/Users/flexwie/.config/spotify-player/keymap.toml"): No such file or directory (os error 2). Use the def
ault configurations instead
2023-05-04T06:26:49.021928Z  INFO spotify_player::streaming: Application's connect configurations: ConnectConfig { name: "spotify-player", device_type: Speaker, initial_volume: Some(65535), has_volume_ctrl: true, autoplay: false }
2023-05-04T06:26:49.022116Z  INFO spotify_player::streaming: Initializing a new integrated player with device_id=01f17411-a936-4296-a048-d1f87488666f
2023-05-04T06:26:49.022316Z  INFO spotify_player::streaming: Starting an integrated Spotify player using librespot's spirc protocol
2023-05-04T06:26:49.225128Z  INFO spotify_player::streaming: Got an event from the integrated player: VolumeSet { volume: 65535 }
2023-05-04T06:26:49.322505Z  INFO spotify_player: No playback found on startup, trying to connect to an available device...
2023-05-04T06:26:49.322705Z  INFO spotify_player::media_control: Initializing application's media control event watcher...
2023-05-04T06:26:49.392691Z  INFO client_request{request=GetCurrentUser}: spotify_player::client: successfully handled the client request, took: 70ms
2023-05-04T06:26:49.512493Z  INFO client_request{request=GetUserFollowedArtists}: spotify_player::client: successfully handled the client request, took: 189ms
2023-05-04T06:26:49.519491Z  INFO client_request{request=GetUserSavedAlbums}: spotify_player::client: successfully handled the client request, took: 196ms
2023-05-04T06:26:49.528296Z  INFO client_request{request=GetCurrentUserQueue}: spotify_player::client: successfully handled the client request, took: 205ms
2023-05-04T06:26:49.528349Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 205ms
2023-05-04T06:26:49.549555Z  INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 226ms
2023-05-04T06:26:49.571227Z  INFO client_request{request=GetUserSavedTracks}: spotify_player::client: successfully handled the client request, took: 248ms
2023-05-04T06:26:50.433079Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Available devices: [Device { id: Some("cc4ec7d1e808718d4cf32d94a22dbea169054eba"), is_active: false, is_private_session: false, is_restricted: false, name: "Schlafzimmer", _type: Speaker, volume_percent: Some(0) }]
2023-05-04T06:26:50.433180Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Trying to connect to device (id=01f17411-a936-4296-a048-d1f87488666f)
2023-05-04T06:26:51.716302Z  INFO spotify_player::streaming: Got an event from the integrated player: Started { play_request_id: 0, track_id: SpotifyId { id: 267802404047856429741752316171105019281, audio_type: Track }, position_ms: 105277 }
2023-05-04T06:26:51.716429Z  INFO spotify_player::streaming: Got an event from the integrated player: Loading { play_request_id: 0, track_id: SpotifyId { id: 267802404047856429741752316171105019281, audio_type: Trac
k }, position_ms: 105277 }
2023-05-04T06:26:51.719146Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Connection succeeded (device_id=01f17411-a936-4296-a048-d1f87488666f)!
2023-05-04T06:26:51.719195Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: successfully handled the client request, took: 2396ms
2023-05-04T06:26:51.788039Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 71ms
2023-05-04T06:26:51.790470Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 73ms
2023-05-04T06:26:54.002095Z  INFO spotify_player::streaming: Got an event from the integrated player: Paused { play_request_id: 0, track_id: SpotifyId { id: 267802404047856429741752316171105019281, audio_type: Track
 }, position_ms: 105276, duration_ms: 183800 }
2023-05-04T06:26:54.035010Z  INFO spotify_player::client: Retrieving an image from url: https://i.scdn.co/image/ab67616d0000b273cbf098e557adf406ca4b20de
2023-05-04T06:26:54.220946Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 218ms
aome510 commented 1 year ago

@flexwie thanks. I can confirm this issue is reproducible on my end.

I think this issue happens because spotify_player relies on get-devices API to list the list of available devices while spotifyd relies on zeroconf authentication. In other words, spotifyd device won't show up in the get-devices API until it gets authenticated with spotify connect using official Spotify apps.

I'll try to figure out a way to make these kinds of devices discoverable by spotify_player. In the meantime, one possible workaround is to specify username and password as in https://docs.spotifyd.rs/config/File.html to make spotifyd device authenticated w/o spotify connect.

aome510 commented 1 year ago

Related: https://github.com/Spotifyd/spotifyd/issues/903#issuecomment-1519034873

Downgrading to 0.3.3 is also another option.

aome510 commented 1 year ago

Updated: adding support for discovering devices using https://en.wikipedia.org/wiki/Zero-configuration_networking requires to implement the zeroconf networking specs in spotify_player. This is not trivial though as I don't have any knowledge on this subject.

Updated the issue's description. I don't have any plans to fix this issue.

My suggested workaround will be either

flexwie commented 1 year ago

Thanks for your help on this issue @aome510! Just adding my credentials in the spotifyd config did not solve the issue for me, but selecting the spotifyd client from the official Spotify app did!