Skip to content

Commit 29a1524

Browse files
authored
cleanup rspotify::model imports (#620)
1 parent 9fc65c6 commit 29a1524

File tree

13 files changed

+200
-195
lines changed

13 files changed

+200
-195
lines changed

spotify_player/src/cli/client.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ use crate::{
1414
cli::Request,
1515
client::{Client, PlayerRequest},
1616
config::get_cache_folder_path,
17-
state::{Context, ContextId, Playback, PlaybackMetadata, SharedState},
18-
};
19-
use rspotify::{
20-
model::{
21-
AlbumId, ArtistId, CurrentPlaybackContext, Id, PlayableId, PlaylistId, SearchResult,
22-
SearchType, TrackId,
17+
state::{
18+
AlbumId, ArtistId, Context, ContextId, Id, PlayableId, Playback, PlaybackMetadata,
19+
PlaylistId, SharedState, TrackId,
2320
},
24-
prelude::{BaseClient, OAuthClient},
2521
};
22+
use rspotify::prelude::{BaseClient, OAuthClient};
2623

2724
use super::{
2825
Command, Deserialize, GetRequest, IdOrName, ItemId, ItemType, Key, PlaylistCommand, Response,
@@ -96,7 +93,7 @@ async fn send_response(
9693
async fn current_playback(
9794
client: &Client,
9895
state: Option<&SharedState>,
99-
) -> Result<Option<CurrentPlaybackContext>> {
96+
) -> Result<Option<rspotify::model::CurrentPlaybackContext>> {
10097
// get current playback from the application's state, if exists, or by making an API request
10198
match state {
10299
Some(state) => Ok(state.player.read().current_playback()),
@@ -230,11 +227,11 @@ async fn get_spotify_id(client: &Client, typ: ItemType, id_or_name: IdOrName) ->
230227
IdOrName::Id(id) => ItemId::Playlist(PlaylistId::from_id(id)?),
231228
IdOrName::Name(name) => {
232229
let results = client
233-
.search_specific_type(&name, SearchType::Playlist)
230+
.search_specific_type(&name, rspotify::model::SearchType::Playlist)
234231
.await?;
235232

236233
match results {
237-
SearchResult::Playlists(page) => {
234+
rspotify::model::SearchResult::Playlists(page) => {
238235
if page.items.is_empty() {
239236
anyhow::bail!("Cannot find playlist with name='{name}'");
240237
}
@@ -248,11 +245,11 @@ async fn get_spotify_id(client: &Client, typ: ItemType, id_or_name: IdOrName) ->
248245
IdOrName::Id(id) => ItemId::Album(AlbumId::from_id(id)?),
249246
IdOrName::Name(name) => {
250247
let results = client
251-
.search_specific_type(&name, SearchType::Album)
248+
.search_specific_type(&name, rspotify::model::SearchType::Album)
252249
.await?;
253250

254251
match results {
255-
SearchResult::Albums(page) => {
252+
rspotify::model::SearchResult::Albums(page) => {
256253
if !page.items.is_empty() && page.items[0].id.is_some() {
257254
ItemId::Album(page.items[0].id.clone().unwrap())
258255
} else {
@@ -267,11 +264,11 @@ async fn get_spotify_id(client: &Client, typ: ItemType, id_or_name: IdOrName) ->
267264
IdOrName::Id(id) => ItemId::Artist(ArtistId::from_id(id)?),
268265
IdOrName::Name(name) => {
269266
let results = client
270-
.search_specific_type(&name, SearchType::Artist)
267+
.search_specific_type(&name, rspotify::model::SearchType::Artist)
271268
.await?;
272269

273270
match results {
274-
SearchResult::Artists(page) => {
271+
rspotify::model::SearchResult::Artists(page) => {
275272
if page.items.is_empty() {
276273
anyhow::bail!("Cannot find artist with name='{name}'");
277274
}
@@ -285,11 +282,11 @@ async fn get_spotify_id(client: &Client, typ: ItemType, id_or_name: IdOrName) ->
285282
IdOrName::Id(id) => ItemId::Track(TrackId::from_id(id)?),
286283
IdOrName::Name(name) => {
287284
let results = client
288-
.search_specific_type(&name, SearchType::Track)
285+
.search_specific_type(&name, rspotify::model::SearchType::Track)
289286
.await?;
290287

291288
match results {
292-
SearchResult::Tracks(page) => {
289+
rspotify::model::SearchResult::Tracks(page) => {
293290
if !page.items.is_empty() && page.items[0].id.is_some() {
294291
ItemId::Track(page.items[0].id.clone().unwrap())
295292
} else {

spotify_player/src/client/handlers.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use anyhow::Context;
2-
use rspotify::model::PlayableItem;
32
use tracing::Instrument;
43

54
use crate::{
@@ -54,13 +53,13 @@ fn handle_playback_change_event(
5453
player.buffered_playback.as_ref(),
5554
player.currently_playing(),
5655
) {
57-
(Some(playback), Some(PlayableItem::Track(track))) => (
56+
(Some(playback), Some(rspotify::model::PlayableItem::Track(track))) => (
5857
playback,
5958
PlayableId::Track(track.id.clone().expect("null track_id")),
6059
&track.name,
6160
track.duration,
6261
),
63-
(Some(playback), Some(PlayableItem::Episode(episode))) => (
62+
(Some(playback), Some(rspotify::model::PlayableItem::Episode(episode))) => (
6463
playback,
6564
PlayableId::Episode(episode.id.clone()),
6665
&episode.name,

0 commit comments

Comments
 (0)