Rigellute / spotify-tui

Spotify for the terminal written in Rust 🚀
MIT License
17.46k stars 521 forks source link

[Feature Request] Hide unplayable songs #718

Open Frederick888 opened 3 years ago

Frederick888 commented 3 years ago

Is your feature request related to a problem? Please describe. Some songs in my playlists are unplayable. It causes errors when client tries to play such songs.

Describe the solution you'd like Implementing a 'Hide Unplayable Songs' option like the official Spotify app. File 24-1-21, 00 28 43

For example, in one of my playlists the first 3 songs are unplayable.

image image

In spt if I choose any of them the playback just stops:

event Readable Token(16777220)
loop process - 1 events, 0.000s
attempting to decode a frame
frame decoded from buffer
attempting to decode a frame
scheduling Read for: 4
flushing framed transport
framed transport flushed
loop poll - 18.858204492s
loop time - Instant { t: 101897221113932 }
loop process, 21.827µs
kMessageTypeLoad "" webapi-fd53d24a4c1240bbada50df3f1e1a041 809839986 1611422552743
State: context_uri: "spotify:playlist:4BQbhhBMXPR4PZSxIU3tuH" index: 4294967295 position_ms: 0 status: kPlayStatusStop position_measured_at: 1611422575312 context_description: "\345\204\252\343\201\227\343\201\204\346\233\262" shuffle: false repeat: false playing_from_fallback: true
Frame has 0 tracks
No more tracks left in queue
command=Stop
Player::stop called from invalid state
scheduling Read for: 4
flushing framed transport
writing; remaining=439
framed transport flushed
loop poll - 343.224µs
loop time - Instant { t: 101897221753714 }
loop process, 19.373µs
event Readable | Writable Token(16777220)
loop process - 1 events, 0.000s
attempting to decode a frame
frame decoded from buffer
attempting to decode a frame
scheduling Read for: 4
flushing framed transport
framed transport flushed
loop poll - 160.925599ms
loop time - Instant { t: 101897382712130 }
loop process, 19.271µs
loop poll - 5.521µs
loop time - Instant { t: 101897382782498 }
loop process, 15.891µs

Originally reported at Spotifyd/spotifyd#794

Rigellute commented 3 years ago

Hopefully there's a property on the track itself that indicates if it is playable or not 🤔

Frederick888 commented 3 years ago

@Rigellute There are at the moment 2 properties:

  1. is_playable: true when it's playable; omitted when it's not. Not sure whether false is ever used.
  2. is_local: If it's a local file.

So ideally we need 2 configs/CLI arguments for each of them. I guess local files can still be played when using official app as playback device, but in the case of spotifyd both unplayable and local songs should be filtered out.

FYI the API response of the example playlist is:

{
    "href": "https://api.spotify.com/v1/playlists/<playlist_id>/tracks?offset=0&limit=100&market=from_token&additional_types=track%2Cepisode",
    "items": [
        {
            "added_at": "2019-03-07T10:37:57Z",
            "added_by": {
                "external_urls": {
                    "spotify": "https://open.spotify.com/user/<user_id>"
                },
                "href": "https://api.spotify.com/v1/users/<user_id>",
                "id": "<user_id>",
                "type": "user",
                "uri": "spotify:user:<user_id>"
            },
            "is_local": true,
            "primary_color": null,
            "track": {
                "album": {
                    "album_type": null,
                    "artists": [],
                    "available_markets": [],
                    "external_urls": {},
                    "href": null,
                    "id": null,
                    "images": [],
                    "name": "ZIGAEXPERIENTIA",
                    "release_date": null,
                    "release_date_precision": null,
                    "type": "album",
                    "uri": null
                },
                "artists": [
                    {
                        "external_urls": {},
                        "href": null,
                        "id": null,
                        "name": "supercell",
                        "type": "artist",
                        "uri": null
                    }
                ],
                "available_markets": [],
                "disc_number": 0,
                "duration_ms": 424000,
                "explicit": false,
                "external_ids": {},
                "external_urls": {},
                "href": null,
                "id": null,
                "is_local": true,
                "name": "銀色飛行船",
                "popularity": 0,
                "preview_url": null,
                "track_number": 0,
                "type": "track",
                "uri": "spotify:local:supercell:ZIGAEXPERIENTIA:%E9%8A%80%E8%89%B2%E9%A3%9B%E8%A1%8C%E8%88%B9:424"
            },
            "video_thumbnail": {
                "url": null
            }
        },
        {
            "added_at": "2019-03-07T10:37:57Z",
            "added_by": {
                "external_urls": {
                    "spotify": "https://open.spotify.com/user/<user_id>"
                },
                "href": "https://api.spotify.com/v1/users/<user_id>",
                "id": "<user_id>",
                "type": "user",
                "uri": "spotify:user:<user_id>"
            },
            "is_local": true,
            "primary_color": null,
            "track": {
                "album": {
                    "album_type": null,
                    "artists": [],
                    "available_markets": [],
                    "external_urls": {},
                    "href": null,
                    "id": null,
                    "images": [],
                    "name": "銀色飛行船",
                    "release_date": null,
                    "release_date_precision": null,
                    "type": "album",
                    "uri": null
                },
                "artists": [
                    {
                        "external_urls": {},
                        "href": null,
                        "id": null,
                        "name": "supercell",
                        "type": "artist",
                        "uri": null
                    }
                ],
                "available_markets": [],
                "disc_number": 0,
                "duration_ms": 143000,
                "explicit": false,
                "external_ids": {},
                "external_urls": {},
                "href": null,
                "id": null,
                "is_local": true,
                "name": "劇場版アニメ映画 「ねらわれた学園」 特報用BGM",
                "popularity": 0,
                "preview_url": null,
                "track_number": 0,
                "type": "track",
                "uri": "spotify:local:supercell:%E9%8A%80%E8%89%B2%E9%A3%9B%E8%A1%8C%E8%88%B9:%E5%8A%87%E5%A0%B4%E7%89%88%E3%82%A2%E3%83%8B%E3%83%A1%E6%98%A0%E7%94%BB+%E3%80%8C%E3%81%AD%E3%82%89%E3%82%8F%E3%82%8C%E3%81%9F%E5%AD%A6%E5%9C%92%E3%80%8D+%E7%89%B9%E5%A0%B1%E7%94%A8BGM:143"
            },
            "video_thumbnail": {
                "url": null
            }
        },
        {
            "added_at": "2019-03-07T10:37:57Z",
            "added_by": {
                "external_urls": {
                    "spotify": "https://open.spotify.com/user/<user_id>"
                },
                "href": "https://api.spotify.com/v1/users/<user_id>",
                "id": "<user_id>",
                "type": "user",
                "uri": "spotify:user:<user_id>"
            },
            "is_local": true,
            "primary_color": null,
            "track": {
                "album": {
                    "album_type": null,
                    "artists": [],
                    "available_markets": [],
                    "external_urls": {},
                    "href": null,
                    "id": null,
                    "images": [],
                    "name": "One more time, One more chance ''Byōsoku 5 Centimeter'' Special Edition",
                    "release_date": null,
                    "release_date_precision": null,
                    "type": "album",
                    "uri": null
                },
                "artists": [
                    {
                        "external_urls": {},
                        "href": null,
                        "id": null,
                        "name": "Yamazaki Masayoshi",
                        "type": "artist",
                        "uri": null
                    }
                ],
                "available_markets": [],
                "disc_number": 0,
                "duration_ms": 141000,
                "explicit": false,
                "external_ids": {},
                "external_urls": {},
                "href": null,
                "id": null,
                "is_local": true,
                "name": "Yuki no Eki ~One more time, One more chance~ (from ''Byōsoku 5 Centimeter'' Original Soundtrack)",
                "popularity": 0,
                "preview_url": null,
                "track_number": 0,
                "type": "track",
                "uri": "spotify:local:Yamazaki+Masayoshi:One+more+time%2C+One+more+chance+%27%27By%C5%8Dsoku+5+Centimeter%27%27+Special+Edition:Yuki+no+Eki+%EF%BD%9EOne+more+time%2C+One+more+chance%EF%BD%9E+%28from+%27%27By%C5%8Dsoku+5+Centimeter%27%27+Original+Soundtrack%29:141"
            },
            "video_thumbnail": {
                "url": null
            }
        },
        {
            "added_at": "2019-08-19T12:15:56Z",
            "added_by": {
                "external_urls": {
                    "spotify": "https://open.spotify.com/user/<user_id>"
                },
                "href": "https://api.spotify.com/v1/users/<user_id>",
                "id": "<user_id>",
                "type": "user",
                "uri": "spotify:user:<user_id>"
            },
            "is_local": false,
            "primary_color": null,
            "sharing_info": {
                "share_id": "-85igrYUSoaEXc694HFG_g",
                "share_url": "https://open.spotify.com/track/5R73heiC9M9u94jsNrS2BF?si=-85igrYUSoaEXc694HFG_g",
                "uri": "spotify:track:5R73heiC9M9u94jsNrS2BF"
            },
            "track": {
                "album": {
                    "album_type": "album",
                    "artists": [
                        {
                            "external_urls": {
                                "spotify": "https://open.spotify.com/artist/3D73KNJRMbV45N59E8IN0F"
                            },
                            "href": "https://api.spotify.com/v1/artists/3D73KNJRMbV45N59E8IN0F",
                            "id": "3D73KNJRMbV45N59E8IN0F",
                            "name": "Mika Nakashima",
                            "type": "artist",
                            "uri": "spotify:artist:3D73KNJRMbV45N59E8IN0F"
                        }
                    ],
                    "external_urls": {
                        "spotify": "https://open.spotify.com/album/1d75Jg7kVu2v5bNneBd0j9"
                    },
                    "href": "https://api.spotify.com/v1/albums/1d75Jg7kVu2v5bNneBd0j9",
                    "id": "1d75Jg7kVu2v5bNneBd0j9",
                    "images": [
                        {
                            "height": 640,
                            "url": "https://i.scdn.co/image/ab67616d0000b2737964fb772e16a4d2c5ed5794",
                            "width": 640
                        },
                        {
                            "height": 300,
                            "url": "https://i.scdn.co/image/ab67616d00001e027964fb772e16a4d2c5ed5794",
                            "width": 300
                        },
                        {
                            "height": 64,
                            "url": "https://i.scdn.co/image/ab67616d000048517964fb772e16a4d2c5ed5794",
                            "width": 64
                        }
                    ],
                    "name": "LOVE",
                    "release_date": "2003-11-06",
                    "release_date_precision": "day",
                    "total_tracks": 13,
                    "type": "album",
                    "uri": "spotify:album:1d75Jg7kVu2v5bNneBd0j9"
                },
                "artists": [
                    {
                        "external_urls": {
                            "spotify": "https://open.spotify.com/artist/3D73KNJRMbV45N59E8IN0F"
                        },
                        "href": "https://api.spotify.com/v1/artists/3D73KNJRMbV45N59E8IN0F",
                        "id": "3D73KNJRMbV45N59E8IN0F",
                        "name": "Mika Nakashima",
                        "type": "artist",
                        "uri": "spotify:artist:3D73KNJRMbV45N59E8IN0F"
                    }
                ],
                "disc_number": 1,
                "duration_ms": 341973,
                "episode": false,
                "explicit": false,
                "external_ids": {
                    "isrc": "JPN300301301"
                },
                "external_urls": {
                    "spotify": "https://open.spotify.com/track/5R73heiC9M9u94jsNrS2BF"
                },
                "href": "https://api.spotify.com/v1/tracks/5R73heiC9M9u94jsNrS2BF",
                "id": "5R73heiC9M9u94jsNrS2BF",
                "is_local": false,
                "is_playable": true,
                "name": "雪の華",
                "popularity": 50,
                "preview_url": "https://p.scdn.co/mp3-preview/a4847a0f3f5e2d3a77fdd19d82a0549a0d9f1ee1?cid=d8a5ed958d274c2e8ee717e6a4b0971d",
                "track": true,
                "track_number": 4,
                "type": "track",
                "uri": "spotify:track:5R73heiC9M9u94jsNrS2BF"
            },
            "video_thumbnail": {
                "url": null
            }
        },
        {
            "added_at": "2019-08-19T12:16:54Z",
            "added_by": {
                "external_urls": {
                    "spotify": "https://open.spotify.com/user/<user_id>"
                },
                "href": "https://api.spotify.com/v1/users/<user_id>",
                "id": "<user_id>",
                "type": "user",
                "uri": "spotify:user:<user_id>"
            },
            "is_local": false,
            "primary_color": null,
            "sharing_info": {
                "share_id": "RaXTddZBTWOwmRhpULQhvg",
                "share_url": "https://open.spotify.com/track/2gmZpgSxuqhwGaMipiLLLn?si=RaXTddZBTWOwmRhpULQhvg",
                "uri": "spotify:track:2gmZpgSxuqhwGaMipiLLLn"
            },
            "track": {
                "album": {
                    "album_type": "single",
                    "artists": [
                        {
                            "external_urls": {
                                "spotify": "https://open.spotify.com/artist/4Mc3zbnQx4wRb0tYg7A8sG"
                            },
                            "href": "https://api.spotify.com/v1/artists/4Mc3zbnQx4wRb0tYg7A8sG",
                            "id": "4Mc3zbnQx4wRb0tYg7A8sG",
                            "name": "supercell",
                            "type": "artist",
                            "uri": "spotify:artist:4Mc3zbnQx4wRb0tYg7A8sG"
                        }
                    ],
                    "external_urls": {
                        "spotify": "https://open.spotify.com/album/28PjOT4OMA2lMdL6Dpr7Py"
                    },
                    "href": "https://api.spotify.com/v1/albums/28PjOT4OMA2lMdL6Dpr7Py",
                    "id": "28PjOT4OMA2lMdL6Dpr7Py",
                    "images": [
                        {
                            "height": 640,
                            "url": "https://i.scdn.co/image/ab67616d0000b273609a43d143128bea2dc1b7cd",
                            "width": 640
                        },
                        {
                            "height": 300,
                            "url": "https://i.scdn.co/image/ab67616d00001e02609a43d143128bea2dc1b7cd",
                            "width": 300
                        },
                        {
                            "height": 64,
                            "url": "https://i.scdn.co/image/ab67616d00004851609a43d143128bea2dc1b7cd",
                            "width": 64
                        }
                    ],
                    "name": "銀色飛行船",
                    "release_date": "2012-12-19",
                    "release_date_precision": "day",
                    "total_tracks": 5,
                    "type": "album",
                    "uri": "spotify:album:28PjOT4OMA2lMdL6Dpr7Py"
                },
                "artists": [
                    {
                        "external_urls": {
                            "spotify": "https://open.spotify.com/artist/4Mc3zbnQx4wRb0tYg7A8sG"
                        },
                        "href": "https://api.spotify.com/v1/artists/4Mc3zbnQx4wRb0tYg7A8sG",
                        "id": "4Mc3zbnQx4wRb0tYg7A8sG",
                        "name": "supercell",
                        "type": "artist",
                        "uri": "spotify:artist:4Mc3zbnQx4wRb0tYg7A8sG"
                    }
                ],
                "disc_number": 1,
                "duration_ms": 425453,
                "episode": false,
                "explicit": false,
                "external_ids": {
                    "isrc": "JPSR01203941"
                },
                "external_urls": {
                    "spotify": "https://open.spotify.com/track/2gmZpgSxuqhwGaMipiLLLn"
                },
                "href": "https://api.spotify.com/v1/tracks/2gmZpgSxuqhwGaMipiLLLn",
                "id": "2gmZpgSxuqhwGaMipiLLLn",
                "is_local": false,
                "is_playable": true,
                "name": "銀色飛行船",
                "popularity": 9,
                "preview_url": "https://p.scdn.co/mp3-preview/4d1164490bbf78cc9cb272d0e64ba9bddabc8109?cid=d8a5ed958d274c2e8ee717e6a4b0971d",
                "track": true,
                "track_number": 1,
                "type": "track",
                "uri": "spotify:track:2gmZpgSxuqhwGaMipiLLLn"
            },
            "video_thumbnail": {
                "url": null
            }
        }
    ],
    "limit": 100,
    "next": null,
    "offset": 0,
    "previous": null,
    "total": 5
}
elbart commented 3 years ago

As mentioned in https://github.com/ramsayleung/rspotify/issues/190, we currently do not get this is_playable information in a reliable way from rspotify. I filed an upstream issue there and will try to help them debug the issue.

Shorono commented 3 years ago

Getting the "is_playable" flag would probably make this easily fixable too. https://github.com/Rigellute/spotify-tui/issues/766