Fix rspotify InvalidToken panics
This commit is contained in:
parent
8ba909dd6a
commit
d283542b1d
1 changed files with 753 additions and 753 deletions
|
|
@ -283,18 +283,18 @@ impl DownloaderInternal {
|
||||||
config: DownloaderConfig,
|
config: DownloaderConfig,
|
||||||
) -> Result<(), SpotifyError> {
|
) -> Result<(), SpotifyError> {
|
||||||
// Fetch metadata
|
// Fetch metadata
|
||||||
|
self.spotify.spotify.request_token().await?;
|
||||||
|
|
||||||
let track = self
|
let track = self
|
||||||
.spotify
|
.spotify
|
||||||
.spotify
|
.spotify
|
||||||
.track(TrackId::from_id(&job.track_id).unwrap(), None)
|
.track(TrackId::from_id(&job.track_id).unwrap(), None)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
let album = self
|
let album = self
|
||||||
.spotify
|
.spotify
|
||||||
.spotify
|
.spotify
|
||||||
.album(track.album.id.ok_or(SpotifyError::Unavailable)?, None)
|
.album(track.album.id.ok_or(SpotifyError::Unavailable)?, None)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let tags: Vec<(&str, String)> = vec![
|
let tags: Vec<(&str, String)> = vec![
|
||||||
("%title%", sanitize(&track.name)),
|
("%title%", sanitize(&track.name)),
|
||||||
|
|
@ -412,7 +412,7 @@ impl DownloaderInternal {
|
||||||
(Field::TrackNumber, vec![track.track_number.to_string()]),
|
(Field::TrackNumber, vec![track.track_number.to_string()]),
|
||||||
(Field::DiscNumber, vec![track.disc_number.to_string()]),
|
(Field::DiscNumber, vec![track.disc_number.to_string()]),
|
||||||
(Field::Genre, album.genres.clone()),
|
(Field::Genre, album.genres.clone()),
|
||||||
(Field::Label, vec![album.label.unwrap()]),
|
(Field::Label, vec![album.label.unwrap().to_string()]),
|
||||||
];
|
];
|
||||||
let date = album.release_date;
|
let date = album.release_date;
|
||||||
// Write tags
|
// Write tags
|
||||||
|
|
@ -802,7 +802,7 @@ pub struct SearchResult {
|
||||||
impl From<rspotify::model::FullTrack> for SearchResult {
|
impl From<rspotify::model::FullTrack> for SearchResult {
|
||||||
fn from(val: rspotify::model::FullTrack) -> Self {
|
fn from(val: rspotify::model::FullTrack) -> Self {
|
||||||
SearchResult {
|
SearchResult {
|
||||||
track_id: val.id.unwrap().to_string(),
|
track_id: val.id.unwrap().id().to_string(),
|
||||||
author: val.artists[0].name.to_owned(),
|
author: val.artists[0].name.to_owned(),
|
||||||
title: val.name,
|
title: val.name,
|
||||||
}
|
}
|
||||||
|
|
@ -813,7 +813,7 @@ impl From<rspotify::model::FullTrack> for Download {
|
||||||
fn from(val: rspotify::model::FullTrack) -> Self {
|
fn from(val: rspotify::model::FullTrack) -> Self {
|
||||||
Download {
|
Download {
|
||||||
id: 0,
|
id: 0,
|
||||||
track_id: val.id.unwrap().to_string(),
|
track_id: val.id.unwrap().id().to_string(),
|
||||||
title: val.name,
|
title: val.name,
|
||||||
state: DownloadState::None,
|
state: DownloadState::None,
|
||||||
}
|
}
|
||||||
|
|
@ -824,7 +824,7 @@ impl From<rspotify::model::SimplifiedTrack> for Download {
|
||||||
fn from(val: rspotify::model::SimplifiedTrack) -> Self {
|
fn from(val: rspotify::model::SimplifiedTrack) -> Self {
|
||||||
Download {
|
Download {
|
||||||
id: 0,
|
id: 0,
|
||||||
track_id: val.id.unwrap().to_string(),
|
track_id: val.id.unwrap().id().to_string(),
|
||||||
title: val.name,
|
title: val.name,
|
||||||
state: DownloadState::None,
|
state: DownloadState::None,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue