aome510 / spotify-player

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

"spotify_player get key playback" sometimes returns outdated information #415

Closed DOD-101 closed 3 months ago

DOD-101 commented 3 months ago

Describe the bug A clear and concise description of what the bug is.

The "spotify_player get key playback" command sometimes returns outdated information, when changing the playback from a TUI client while playing music via the daemon.

To Reproduce

  1. Start the daemon
  2. Use the CLI commands to start some playback. At this point, if you try to get the playback info it should be accurate.
  3. Now open a regular spotify_player window and change the track.

You should see that if you close the window and try to get the playback info again, it will still be displaying the song that was playing before you switched it in the TUI.

Note: Sometimes the playback info will correct itself again after a short while and will from then forward show the right info until repeat step 3 again.

Expected behaviour The command should be returning what is currently being shown in the TUI, aka what I am hearing.

Log and backtrace

Log of the daemon:

2024-04-19T20:36:56.624967Z  INFO spotify_player: Configurations: Configs { app_config: AppConfig { theme: "dracula", client_id: "fb9c6f0fd604439e8a6ac868290354c3", client_port: 8080, copy_command: Command { command: "wl-copy", args: [] }, player_event_hook_command: None, playback_format: "{track} • {artists}\n{album}\n{metadata}", tracks_playback_limit: 50, proxy: None, ap_port: None, app_refresh_duration_in_ms: 32, playback_refresh_duration_in_ms: 0, page_size_in_rows: 20, 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_img_scale: 2.2, playback_window_width: 6, enable_media_control: true, enable_streaming: Always, enable_cover_image_cache: true, default_device: "arch101-0", device: DeviceConfig { name: "arch101-0", device_type: "speaker", volume: 70, bitrate: 320, audio_cache: true, normalization: false } }, keymap_config: KeymapConfig { keymaps: [Keymap { key_sequence: KeySequence { keys: [None(Char('n'))] }, command: NextTrack }, Keymap { key_sequence: KeySequence { keys: [None(Char('p'))] }, command: PreviousTrack }, Keymap { key_sequence: KeySequence { keys: [None(Char('.'))] }, command: PlayRandom }, Keymap { key_sequence: KeySequence { keys: [None(Char(' '))] }, command: ResumePause }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('r'))] }, command: Repeat }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('s'))] }, command: Shuffle }, Keymap { key_sequence: KeySequence { keys: [None(Char('+'))] }, command: VolumeUp }, Keymap { key_sequence: KeySequence { keys: [None(Char('-'))] }, command: VolumeDown }, Keymap { key_sequence: KeySequence { keys: [None(Char('_'))] }, command: Mute }, Keymap { key_sequence: KeySequence { keys: [None(Char('>'))] }, command: SeekForward }, Keymap { key_sequence: KeySequence { keys: [None(Char('<'))] }, command: SeekBackward }, Keymap { key_sequence: KeySequence { keys: [None(Enter)] }, command: ChooseSelected }, Keymap { key_sequence: KeySequence { keys: [None(Char('r'))] }, command: RefreshPlayback }, Keymap { key_sequence: KeySequence { keys: [None(Char('/'))] }, command: Search }, Keymap { key_sequence: KeySequence { keys: [None(Char('z'))] }, command: Queue }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('z'))] }, command: AddSelectedItemToQueue }, Keymap { key_sequence: KeySequence { keys: [None(Char('Z'))] }, command: AddSelectedItemToQueue }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char(' '))] }, command: ShowActionsOnSelectedItem }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('a'))] }, command: ShowActionsOnSelectedItem }, Keymap { key_sequence: KeySequence { keys: [None(Char('a'))] }, command: ShowActionsOnCurrentTrack }, Keymap { key_sequence: KeySequence { keys: [None(Char('R'))] }, command: RestartIntegratedClient }, Keymap { key_sequence: KeySequence { keys: [None(Tab)] }, command: FocusNextWindow }, Keymap { key_sequence: KeySequence { keys: [None(BackTab)] }, command: FocusPreviousWindow }, Keymap { key_sequence: KeySequence { keys: [None(Char('T'))] }, command: SwitchTheme }, Keymap { key_sequence: KeySequence { keys: [None(Char('D'))] }, command: SwitchDevice }, Keymap { key_sequence: KeySequence { keys: [None(Char('u')), None(Char('p'))] }, command: BrowseUserPlaylists }, Keymap { key_sequence: KeySequence { keys: [None(Char('u')), None(Char('a'))] }, command: BrowseUserFollowedArtists }, Keymap { key_sequence: KeySequence { keys: [None(Char('u')), None(Char('A'))] }, command: BrowseUserSavedAlbums }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char(' '))] }, command: CurrentlyPlayingContextPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('t'))] }, command: TopTrackPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('r'))] }, command: RecentlyPlayedTrackPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('y'))] }, command: LikedTrackPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('L'))] }, command: LyricPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('l'))] }, command: LyricPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('l'))] }, command: LibraryPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('s'))] }, command: SearchPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('b'))] }, command: BrowsePage }, Keymap { key_sequence: KeySequence { keys: [None(Backspace)] }, command: PreviousPage }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('q'))] }, command: PreviousPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('O'))] }, command: OpenSpotifyLinkFromClipboard }, Keymap { key_sequence: KeySequence { keys: [None(Char('?'))] }, command: OpenCommandHelp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('h'))] }, command: OpenCommandHelp }, Keymap { key_sequence: KeySequence { keys: [None(Char('q'))] }, command: Quit }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('c'))] }, command: Quit }, Keymap { key_sequence: KeySequence { keys: [None(Esc)] }, command: ClosePopup }, Keymap { key_sequence: KeySequence { keys: [None(Char('j'))] }, command: SelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('n'))] }, command: SelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [None(Down)] }, command: SelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [None(Char('k'))] }, command: SelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('p'))] }, command: SelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [None(Up)] }, command: SelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [None(PageUp)] }, command: PageSelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('b'))] }, command: PageSelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [None(PageDown)] }, command: PageSelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('f'))] }, command: PageSelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('g'))] }, command: SelectFirstOrScrollToTop }, Keymap { key_sequence: KeySequence { keys: [None(Home)] }, command: SelectFirstOrScrollToTop }, Keymap { key_sequence: KeySequence { keys: [None(Char('G'))] }, command: SelectLastOrScrollToBottom }, Keymap { key_sequence: KeySequence { keys: [None(End)] }, command: SelectLastOrScrollToBottom }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('t'))] }, command: SortTrackByTitle }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('a'))] }, command: SortTrackByArtists }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('A'))] }, command: SortTrackByAlbum }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('d'))] }, command: SortTrackByDuration }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('D'))] }, command: SortTrackByAddedDate }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('r'))] }, command: ReverseTrackOrder }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('k'))] }, command: MovePlaylistItemUp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('j'))] }, command: MovePlaylistItemDown }, Keymap { key_sequence: KeySequence { keys: [None(Char('N'))] }, command: CreatePlaylist }] }, theme_config: ThemeConfig { themes: [Theme { name: "default", palette: Palette { background: None, foreground: None, black: Color { color: Black }, blue: Color { color: Blue }, cyan: Color { color: Cyan }, green: Color { color: Green }, magenta: Color { color: Magenta }, red: Color { color: Red }, white: Color { color: Gray }, yellow: Color { color: Yellow }, bright_black: Color { color: DarkGray }, bright_white: Color { color: White }, bright_red: Color { color: LightRed }, bright_magenta: Color { color: LightMagenta }, bright_green: Color { color: LightGreen }, bright_cyan: Color { color: LightCyan }, bright_blue: Color { color: LightBlue }, bright_yellow: Color { color: LightYellow } }, component_style: ComponentStyle { block_title: None, border: None, playback_track: None, playback_artists: None, playback_album: None, playback_metadata: None, playback_progress_bar: None, current_playing: None, page_desc: None, table_header: None, selection: None } }] }, cache_folder: "/home/david/.cache/spotify-player", config_folder: "/home/david/.config/spotify-player" }
2024-04-19T20:36:56.625066Z  INFO spotify_player: Starting the application as a daemon...
2024-04-19T20:36:56.626399Z  INFO spotify_player::state::data: Loading Playlists data from /home/david/.cache/spotify-player/Playlists_cache.json...
2024-04-19T20:36:56.631014Z  INFO spotify_player::state::data: Successfully loaded Playlists data!
2024-04-19T20:36:56.631040Z  INFO spotify_player::state::data: Loading FollowedArtists data from /home/david/.cache/spotify-player/FollowedArtists_cache.json...
2024-04-19T20:36:56.631945Z  INFO spotify_player::state::data: Successfully loaded FollowedArtists data!
2024-04-19T20:36:56.631956Z  INFO spotify_player::state::data: Loading SavedAlbums data from /home/david/.cache/spotify-player/SavedAlbums_cache.json...
2024-04-19T20:36:56.643306Z  INFO spotify_player::state::data: Successfully loaded SavedAlbums data!
2024-04-19T20:36:56.643326Z  INFO spotify_player::state::data: Loading SavedTracks data from /home/david/.cache/spotify-player/SavedTracks_cache.json...
2024-04-19T20:36:57.052806Z  INFO spotify_player::state::data: Successfully loaded SavedTracks data!
2024-04-19T20:36:57.758590Z  INFO spotify_player::auth: Successfully used the cached credentials to create a new session!
2024-04-19T20:36:57.797628Z  INFO spotify_player::token: Getting new authentication token...
2024-04-19T20:36:58.059194Z  INFO spotify_player::token: Got new token: Token { access_token: "BQCN0X8mhxbPZPovBGXR91E0VuBbxEP-O6m2XKnpaEEpcHZqlqC8lxNN_uOXGa4zSIRpI-CfaOH9xpoWQrVnjLdh0r5dqHCNEgeAhVTLcnIqwiTVJm-GJfXYGAo-J3CS8U-j9HKXHw2JV0U8hpSLHK71N4PqFy9JyF2KMGpyQHP35f9qxog38ZmbXOMOt4ZzA2EXmWcj-c8n8Vt5utp4cX08ascvsQ3Tw1Tq2iJzwh1axHhTeBmE0TzecXMQOJm2D3AF7J8ZwVlwO8rauCxG6AIeQosEnnPvvX51KjDtJ1f4J9PhvoYvK4aZlFGnlhA", expires_in: TimeDelta { secs: 3600, nanos: 0 }, expires_at: Some(2024-04-19T21:36:58.059185883Z), refresh_token: None, scopes: {} }
2024-04-19T20:36:58.059283Z  INFO spotify_player::streaming: Application's connect configurations: ConnectConfig { name: "arch101-0", device_type: Speaker, initial_volume: Some(45875), has_volume_ctrl: true, autoplay: false }
2024-04-19T20:36:58.059340Z  INFO spotify_player::streaming: Initializing a new integrated player with device_id=7f218a71-4765-4355-882a-9395d2cda9f3
2024-04-19T20:36:58.059531Z  INFO spotify_player::streaming: Starting an integrated Spotify player using librespot's spirc protocol
2024-04-19T20:36:58.167549Z  INFO spotify_player: No playback found on startup, trying to connect to an available device...
2024-04-19T20:36:58.167663Z  INFO spotify_player::media_control: Initializing application's media control event watcher...
2024-04-19T20:36:58.167668Z  INFO spotify_player: Starting a client socket at 127.0.0.1:8080
2024-04-19T20:36:58.272819Z  INFO client_request{request=GetCurrentUser}: spotify_player::client: successfully handled the client request, took: 104ms
2024-04-19T20:36:58.293343Z  INFO client_request{request=GetUserFollowedArtists}: spotify_player::client: successfully handled the client request, took: 125ms
2024-04-19T20:36:58.862564Z  INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 694ms
2024-04-19T20:36:59.230125Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Available devices: []
2024-04-19T20:36:59.230161Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Trying to connect to device (id=7f218a71-4765-4355-882a-9395d2cda9f3)
2024-04-19T20:36:59.774861Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Connection succeeded (device_id=7f218a71-4765-4355-882a-9395d2cda9f3)!
2024-04-19T20:36:59.774937Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: successfully handled the client request, took: 1607ms
2024-04-19T20:37:00.344350Z  INFO spotify_player::streaming: Got a new player event: Paused { track_id: TrackId("2X485T9Z5Ly0xyaghN73ed"), position_ms: 11, duration_ms: 467586 }
2024-04-19T20:37:00.771471Z  INFO client_request{request=GetUserSavedAlbums}: spotify_player::client: successfully handled the client request, took: 2603ms
2024-04-19T20:37:01.276688Z  INFO spotify_player::client: Retrieving an image from the file: /home/david/.cache/spotify-player/image/Currents-Tame Impala-cover.jpg
2024-04-19T20:37:01.276788Z  INFO spotify_player::client: Retrieving an image from the file: /home/david/.cache/spotify-player/image/Currents-Tame Impala-cover.jpg
2024-04-19T20:37:08.776314Z  INFO client_request{request=GetUserSavedTracks}: spotify_player::client: successfully handled the client request, took: 10608ms
2024-04-19T20:37:32.953657Z  INFO socket_request{request=Playback(Play) dest_addr=127.0.0.1:54229}: spotify_player::cli::client: Successfully handled the socket request.
2024-04-19T20:37:33.249364Z  INFO spotify_player::streaming: Got a new player event: Playing { track_id: TrackId("2X485T9Z5Ly0xyaghN73ed"), position_ms: 11, duration_ms: 467586 }
2024-04-19T20:37:33.249700Z  INFO spotify_player::streaming: Got a new player event: Playing { track_id: TrackId("2X485T9Z5Ly0xyaghN73ed"), position_ms: 11, duration_ms: 467586 }
2024-04-19T20:37:48.361701Z  INFO spotify_player::streaming: Got a new player event: Changed { old_track_id: TrackId("2X485T9Z5Ly0xyaghN73ed"), new_track_id: TrackId("0yc6Gst2xkRu0eMLeRMGCX") }
2024-04-19T20:37:49.078319Z  INFO spotify_player::streaming: Got a new player event: Playing { track_id: TrackId("0yc6Gst2xkRu0eMLeRMGCX"), position_ms: 0, duration_ms: 290616 }
2024-04-19T20:38:15.890467Z  INFO socket_request{request=Get(Key(Playback)) dest_addr=127.0.0.1:42950}: spotify_player::cli::client: Successfully handled the socket request.

Log of the client:

2024-04-19T20:37:45.542751Z  INFO spotify_player: Configurations: Configs { app_config: AppConfig { theme: "dracula", client_id: "fb9c6f0fd604439e8a6ac868290354c3", client_port: 8080, copy_command: Command { command: "wl-copy", args: [] }, player_event_hook_command: None, playback_format: "{track} • {artists}\n{album}\n{metadata}", tracks_playback_limit: 50, proxy: None, ap_port: None, app_refresh_duration_in_ms: 32, playback_refresh_duration_in_ms: 0, page_size_in_rows: 20, 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_img_scale: 2.2, playback_window_width: 6, enable_media_control: true, enable_streaming: Always, enable_cover_image_cache: true, default_device: "arch101-0", device: DeviceConfig { name: "arch101-0", device_type: "speaker", volume: 70, bitrate: 320, audio_cache: true, normalization: false } }, keymap_config: KeymapConfig { keymaps: [Keymap { key_sequence: KeySequence { keys: [None(Char('n'))] }, command: NextTrack }, Keymap { key_sequence: KeySequence { keys: [None(Char('p'))] }, command: PreviousTrack }, Keymap { key_sequence: KeySequence { keys: [None(Char('.'))] }, command: PlayRandom }, Keymap { key_sequence: KeySequence { keys: [None(Char(' '))] }, command: ResumePause }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('r'))] }, command: Repeat }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('s'))] }, command: Shuffle }, Keymap { key_sequence: KeySequence { keys: [None(Char('+'))] }, command: VolumeUp }, Keymap { key_sequence: KeySequence { keys: [None(Char('-'))] }, command: VolumeDown }, Keymap { key_sequence: KeySequence { keys: [None(Char('_'))] }, command: Mute }, Keymap { key_sequence: KeySequence { keys: [None(Char('>'))] }, command: SeekForward }, Keymap { key_sequence: KeySequence { keys: [None(Char('<'))] }, command: SeekBackward }, Keymap { key_sequence: KeySequence { keys: [None(Enter)] }, command: ChooseSelected }, Keymap { key_sequence: KeySequence { keys: [None(Char('r'))] }, command: RefreshPlayback }, Keymap { key_sequence: KeySequence { keys: [None(Char('/'))] }, command: Search }, Keymap { key_sequence: KeySequence { keys: [None(Char('z'))] }, command: Queue }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('z'))] }, command: AddSelectedItemToQueue }, Keymap { key_sequence: KeySequence { keys: [None(Char('Z'))] }, command: AddSelectedItemToQueue }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char(' '))] }, command: ShowActionsOnSelectedItem }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('a'))] }, command: ShowActionsOnSelectedItem }, Keymap { key_sequence: KeySequence { keys: [None(Char('a'))] }, command: ShowActionsOnCurrentTrack }, Keymap { key_sequence: KeySequence { keys: [None(Char('R'))] }, command: RestartIntegratedClient }, Keymap { key_sequence: KeySequence { keys: [None(Tab)] }, command: FocusNextWindow }, Keymap { key_sequence: KeySequence { keys: [None(BackTab)] }, command: FocusPreviousWindow }, Keymap { key_sequence: KeySequence { keys: [None(Char('T'))] }, command: SwitchTheme }, Keymap { key_sequence: KeySequence { keys: [None(Char('D'))] }, command: SwitchDevice }, Keymap { key_sequence: KeySequence { keys: [None(Char('u')), None(Char('p'))] }, command: BrowseUserPlaylists }, Keymap { key_sequence: KeySequence { keys: [None(Char('u')), None(Char('a'))] }, command: BrowseUserFollowedArtists }, Keymap { key_sequence: KeySequence { keys: [None(Char('u')), None(Char('A'))] }, command: BrowseUserSavedAlbums }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char(' '))] }, command: CurrentlyPlayingContextPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('t'))] }, command: TopTrackPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('r'))] }, command: RecentlyPlayedTrackPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('y'))] }, command: LikedTrackPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('L'))] }, command: LyricPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('l'))] }, command: LyricPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('l'))] }, command: LibraryPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('s'))] }, command: SearchPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('b'))] }, command: BrowsePage }, Keymap { key_sequence: KeySequence { keys: [None(Backspace)] }, command: PreviousPage }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('q'))] }, command: PreviousPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('O'))] }, command: OpenSpotifyLinkFromClipboard }, Keymap { key_sequence: KeySequence { keys: [None(Char('?'))] }, command: OpenCommandHelp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('h'))] }, command: OpenCommandHelp }, Keymap { key_sequence: KeySequence { keys: [None(Char('q'))] }, command: Quit }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('c'))] }, command: Quit }, Keymap { key_sequence: KeySequence { keys: [None(Esc)] }, command: ClosePopup }, Keymap { key_sequence: KeySequence { keys: [None(Char('j'))] }, command: SelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('n'))] }, command: SelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [None(Down)] }, command: SelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [None(Char('k'))] }, command: SelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('p'))] }, command: SelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [None(Up)] }, command: SelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [None(PageUp)] }, command: PageSelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('b'))] }, command: PageSelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [None(PageDown)] }, command: PageSelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('f'))] }, command: PageSelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('g'))] }, command: SelectFirstOrScrollToTop }, Keymap { key_sequence: KeySequence { keys: [None(Home)] }, command: SelectFirstOrScrollToTop }, Keymap { key_sequence: KeySequence { keys: [None(Char('G'))] }, command: SelectLastOrScrollToBottom }, Keymap { key_sequence: KeySequence { keys: [None(End)] }, command: SelectLastOrScrollToBottom }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('t'))] }, command: SortTrackByTitle }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('a'))] }, command: SortTrackByArtists }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('A'))] }, command: SortTrackByAlbum }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('d'))] }, command: SortTrackByDuration }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('D'))] }, command: SortTrackByAddedDate }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('r'))] }, command: ReverseTrackOrder }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('k'))] }, command: MovePlaylistItemUp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('j'))] }, command: MovePlaylistItemDown }, Keymap { key_sequence: KeySequence { keys: [None(Char('N'))] }, command: CreatePlaylist }] }, theme_config: ThemeConfig { themes: [Theme { name: "default", palette: Palette { background: None, foreground: None, black: Color { color: Black }, blue: Color { color: Blue }, cyan: Color { color: Cyan }, green: Color { color: Green }, magenta: Color { color: Magenta }, red: Color { color: Red }, white: Color { color: Gray }, yellow: Color { color: Yellow }, bright_black: Color { color: DarkGray }, bright_white: Color { color: White }, bright_red: Color { color: LightRed }, bright_magenta: Color { color: LightMagenta }, bright_green: Color { color: LightGreen }, bright_cyan: Color { color: LightCyan }, bright_blue: Color { color: LightBlue }, bright_yellow: Color { color: LightYellow } }, component_style: ComponentStyle { block_title: None, border: None, playback_track: None, playback_artists: None, playback_album: None, playback_metadata: None, playback_progress_bar: None, current_playing: None, page_desc: None, table_header: None, selection: None } }] }, cache_folder: "/home/david/.cache/spotify-player", config_folder: "/home/david/.config/spotify-player" }
2024-04-19T20:37:45.542851Z  INFO spotify_player::state::data: Loading Playlists data from /home/david/.cache/spotify-player/Playlists_cache.json...
2024-04-19T20:37:45.545949Z  INFO spotify_player::state::data: Successfully loaded Playlists data!
2024-04-19T20:37:45.545963Z  INFO spotify_player::state::data: Loading FollowedArtists data from /home/david/.cache/spotify-player/FollowedArtists_cache.json...
2024-04-19T20:37:45.546701Z  INFO spotify_player::state::data: Successfully loaded FollowedArtists data!
2024-04-19T20:37:45.546706Z  INFO spotify_player::state::data: Loading SavedAlbums data from /home/david/.cache/spotify-player/SavedAlbums_cache.json...
2024-04-19T20:37:45.556126Z  INFO spotify_player::state::data: Successfully loaded SavedAlbums data!
2024-04-19T20:37:45.556141Z  INFO spotify_player::state::data: Loading SavedTracks data from /home/david/.cache/spotify-player/SavedTracks_cache.json...
2024-04-19T20:37:45.960588Z  INFO spotify_player::state::data: Successfully loaded SavedTracks data!
2024-04-19T20:37:46.207307Z  INFO spotify_player::auth: Successfully used the cached credentials to create a new session!
2024-04-19T20:37:46.247041Z  INFO spotify_player::token: Getting new authentication token...
2024-04-19T20:37:46.286136Z  INFO spotify_player::token: Got new token: Token { access_token: "BQA2Q7FQ6vcDTESFm-SDpkccx_4uZ8_5T_B4wUSu3_6WvnPp-Lavqoc4H6txjaplc4TJHixGHd5KogmOJJswt7SiyzGecSqiATTzHMPyMlYiuTHAzCMSQXl6tzv4ZfWIFVxRZMkCH_cVcwS0mGuEX1rUUYZM1NDOqqzrkwKvirRJCNCqTqJEWHnWHDzIM9qYM5ZWMC_ob4GKnU7DY2JepHdiAE2e3vN6xD342E_SsQFRuqCMQlxkzyOqbuKxv4mOeD9mPv8B9OxYkavI6OwKqVvxAmYvkCkjhkW-1WE5nc5CmH-6QQvcb5VO4SY1vVE", expires_in: TimeDelta { secs: 3600, nanos: 0 }, expires_at: Some(2024-04-19T21:37:46.286133033Z), refresh_token: None, scopes: {} }
2024-04-19T20:37:46.286173Z  INFO spotify_player::streaming: Application's connect configurations: ConnectConfig { name: "arch101-0", device_type: Speaker, initial_volume: Some(45875), has_volume_ctrl: true, autoplay: false }
2024-04-19T20:37:46.286188Z  INFO spotify_player::streaming: Initializing a new integrated player with device_id=2e1ca715-2e22-4c2b-90b9-d07b277c7d6e
2024-04-19T20:37:46.286246Z  INFO spotify_player::streaming: Starting an integrated Spotify player using librespot's spirc protocol
2024-04-19T20:37:46.540051Z  INFO spotify_player::client: Retrieving an image from the file: /home/david/.cache/spotify-player/image/Currents-Tame Impala-cover.jpg
2024-04-19T20:37:46.540418Z  INFO spotify_player::client: Retrieving an image from the file: /home/david/.cache/spotify-player/image/Currents-Tame Impala-cover.jpg
2024-04-19T20:37:46.554355Z  INFO spotify_player: Starting a client socket at 127.0.0.1:8080
2024-04-19T20:37:46.554401Z  WARN spotify_player: Failed to create a client socket for handling CLI commands: Address already in use (os error 98)
2024-04-19T20:37:46.554492Z  INFO spotify_player::media_control: Initializing application's media control event watcher...
2024-04-19T20:37:46.656630Z  INFO client_request{request=GetCurrentUser}: spotify_player::client: successfully handled the client request, took: 102ms
2024-04-19T20:37:46.675075Z  INFO client_request{request=GetUserFollowedArtists}: spotify_player::client: successfully handled the client request, took: 120ms
2024-04-19T20:37:47.137058Z  INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 582ms
2024-04-19T20:37:48.345657Z  INFO client_request{request=Player(NextTrack)}: spotify_player::client: successfully handled the client request, took: 291ms
2024-04-19T20:37:49.427086Z  INFO client_request{request=GetUserSavedAlbums}: spotify_player::client: successfully handled the client request, took: 2872ms
2024-04-19T20:37:49.554469Z  INFO spotify_player::client: Retrieving an image from the file: /home/david/.cache/spotify-player/image/Cigarettes After Sex-Cigarettes After Sex-cover.jpg
2024-04-19T20:37:49.554557Z  INFO spotify_player::client: Retrieving an image from the file: /home/david/.cache/spotify-player/image/Cigarettes After Sex-Cigarettes After Sex-cover.jpg
2024-04-19T20:37:57.382364Z  INFO client_request{request=GetUserSavedTracks}: spotify_player::client: successfully handled the client request, took: 10827ms

Environment

Additional context I think the issue may have to do with the fact that the application doesn't call the spotify api each time. It first tries to get the info from the application itself (see line 94 in spotify_player/src/cli/client.rs), which could be causing this strange behaviour when using the daemon and a client at the same time.

aome510 commented 3 months ago

I think the issue may have to do with the fact that the application doesn't call the spotify api each time

This is intended to speed up the command's latency. The player should be able to infer its playback state most of the time. However, if you control the player's playback using external tool, e.g from other Spotify client, the state may not be up-to-date. I'm well aware of this drawback and will be working on a patch

DOD-101 commented 3 months ago

Would it be possible to - perhaps simply in the interim - implement a flag / setting that tells it to always call the API?

aome510 commented 3 months ago

yes, but it feels more like a hack than a proper fix

aome510 commented 3 months ago

@DOD-101 should be fixed with #418. Can you try the latest main?

DOD-101 commented 3 months ago

Sure thing.

DOD-101 commented 3 months ago

Alrighty, so after a little bit of testing, I have found the following:

  1. If the song changes by itself, it now works as intended.
  2. If however one changes the song manually in any way it will take 1.5 to 2 min to update.

So it's kinda fixed, but at the same time it probably shouldn't take that long to "recognize" the change.

aome510 commented 3 months ago

How did you test the change? WDYM by "one changes the song manually in any way"?

DOD-101 commented 3 months ago

How did you test the change?

I cloned the git repo and then cargo build it with only the daemon feature flag added. Making sure to delete the Arch package and then I ran it form ~/.cargo/bin. Then I followed the steps outlined in the original post.

WDYM by "one changes the song manually in any way"?

I meant that if you either skip to the next song (via the shortcut) or by simply selecting some other song in the tui. Should have been more clear here: This only applies to changing the song in another client. If one changes the song via the "spotify_player playback next" command it will update almost instantly, as if it just finished playing.

aome510 commented 3 months ago

Making sure to delete the Arch package and then I ran it form ~/.cargo/bin.

cargo build doesn't produce the binary in ~/.cargo/bin though, it should be inside the repo's target/debug

DOD-101 commented 3 months ago

I'm sorry. I accidentally ran cargo install instead of cargo build (not familiar with rust). My bad.

It works like a charm now. Thanks. Keep up the great work.

aome510 commented 3 months ago

Great! Thanks for confirming