modified: Cargo.lock
modified: Cargo.toml modified: src/db.rs modified: src/loading_screen.rs modified: src/sync.rs
This commit is contained in:
parent
fc23d3a7b6
commit
e4061dde2d
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -433,7 +433,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1662,7 +1662,7 @@ dependencies = [
|
|||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys",
|
"linux-raw-sys",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1881,8 +1881,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "soundcloud"
|
name = "soundcloud"
|
||||||
version = "0.1.4"
|
version = "0.1.8"
|
||||||
source = "git+https://gitea.awain.net/alterwain/soundcloud_api.git#22f02cfa43bb91370211b64c9c6240496bd44515"
|
source = "git+https://gitea.awain.net/alterwain/soundcloud_api.git#656aef28f356411ff25cee14214ea0e677563537"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hyper-util",
|
"hyper-util",
|
||||||
"regex",
|
"regex",
|
||||||
@ -2029,7 +2029,7 @@ dependencies = [
|
|||||||
"getrandom 0.3.1",
|
"getrandom 0.3.1",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix",
|
"rustix",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2532,7 +2532,7 @@ version = "0.1.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -22,7 +22,7 @@ futures = "0.3"
|
|||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
tokio-util = { version = "0.7.12", features = ["codec"] }
|
tokio-util = { version = "0.7.12", features = ["codec"] }
|
||||||
strum = { version = "0.27", features = ["derive"] }
|
strum = { version = "0.27", features = ["derive"] }
|
||||||
soundcloud = { version = "0.1.4", git = "https://gitea.awain.net/alterwain/soundcloud_api.git" }
|
soundcloud = { version = "0.1.8", git = "https://gitea.awain.net/alterwain/soundcloud_api.git" }
|
||||||
itunesdb = { version = "0.1.2", git = "https://gitea.awain.net/alterwain/ITunesDB.git" }
|
itunesdb = { version = "0.1.2", git = "https://gitea.awain.net/alterwain/ITunesDB.git" }
|
||||||
ureq = "3.0.5"
|
ureq = "3.0.5"
|
||||||
color-thief = "0.2"
|
color-thief = "0.2"
|
||||||
|
@ -50,7 +50,7 @@ impl From<CloudTrack> for Track {
|
|||||||
size: f.metadata().unwrap().len() as u32,
|
size: f.metadata().unwrap().len() as u32,
|
||||||
length: 0,
|
length: 0,
|
||||||
year: 0,
|
year: 0,
|
||||||
bitrate: header.bitrate.bps(),
|
bitrate: header.bitrate.bps() / 1000,
|
||||||
sample_rate: header.sample_rate.hz(),
|
sample_rate: header.sample_rate.hz(),
|
||||||
play_count: 0,
|
play_count: 0,
|
||||||
dbid: hash(data),
|
dbid: hash(data),
|
||||||
@ -61,7 +61,9 @@ impl From<CloudTrack> for Track {
|
|||||||
title: value.title.unwrap(),
|
title: value.title.unwrap(),
|
||||||
location: String::new(),
|
location: String::new(),
|
||||||
album: String::new(),
|
album: String::new(),
|
||||||
artist: "Soundcloud".to_string(),
|
artist: value
|
||||||
|
.user
|
||||||
|
.map_or(String::new(), |a| a.username.unwrap_or(a.permalink)),
|
||||||
genre: value.genre.unwrap_or_default(),
|
genre: value.genre.unwrap_or_default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,26 +57,16 @@ impl LoadingScreen {
|
|||||||
|
|
||||||
frame.render_widget(main_content, chunks[0]);
|
frame.render_widget(main_content, chunks[0]);
|
||||||
|
|
||||||
let gauge = Gauge::default()
|
if self.progress.is_some() {
|
||||||
.block(
|
self.render_overall(frame, chunks[1]);
|
||||||
Block::default()
|
|
||||||
.borders(Borders::ALL)
|
|
||||||
.title(" Downloading Playlist "),
|
|
||||||
)
|
|
||||||
.gauge_style(Style::default().fg(Color::Green))
|
|
||||||
.ratio(self.progress.unwrap().0 as f64 / self.progress.unwrap().1 as f64)
|
|
||||||
.label(format!(
|
|
||||||
"{:}/{:}",
|
|
||||||
self.progress.unwrap().0,
|
|
||||||
self.progress.unwrap().1
|
|
||||||
));
|
|
||||||
|
|
||||||
frame.render_widget(gauge, chunks[1]);
|
|
||||||
|
|
||||||
if self.s_progress.is_none() {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.s_progress.is_some() {
|
||||||
|
self.render_current(frame, chunks[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_current(&self, frame: &mut Frame, area: Rect) {
|
||||||
let s: String = self
|
let s: String = self
|
||||||
.s_progress
|
.s_progress
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -96,6 +86,24 @@ impl LoadingScreen {
|
|||||||
.ratio(ratio / 100.0)
|
.ratio(ratio / 100.0)
|
||||||
.label(self.s_progress.as_ref().unwrap().progress_total.to_string());
|
.label(self.s_progress.as_ref().unwrap().progress_total.to_string());
|
||||||
|
|
||||||
frame.render_widget(gauge, chunks[2]);
|
frame.render_widget(gauge, area);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_overall(&self, frame: &mut Frame, area: Rect) {
|
||||||
|
let gauge = Gauge::default()
|
||||||
|
.block(
|
||||||
|
Block::default()
|
||||||
|
.borders(Borders::ALL)
|
||||||
|
.title(" Downloading Playlist "),
|
||||||
|
)
|
||||||
|
.gauge_style(Style::default().fg(Color::Green))
|
||||||
|
.ratio(self.progress.unwrap().0 as f64 / self.progress.unwrap().1 as f64)
|
||||||
|
.label(format!(
|
||||||
|
"{:}/{:}",
|
||||||
|
self.progress.unwrap().0,
|
||||||
|
self.progress.unwrap().1
|
||||||
|
));
|
||||||
|
|
||||||
|
frame.render_widget(gauge, area);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
src/sync.rs
36
src/sync.rs
@ -86,6 +86,9 @@ async fn download_playlist(
|
|||||||
let _ = db::insert_track(database, t);
|
let _ = db::insert_track(database, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let _ = sender
|
||||||
|
.send(AppEvent::SwitchScreen(AppState::MainScreen))
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn parse_itunes(database: &Database, sender: &Sender<AppEvent>, path: String) {
|
async fn parse_itunes(database: &Database, sender: &Sender<AppEvent>, path: String) {
|
||||||
@ -119,7 +122,7 @@ async fn parse_itunes(database: &Database, sender: &Sender<AppEvent>, path: Stri
|
|||||||
let config = LyricaConfiguration::default();
|
let config = LyricaConfiguration::default();
|
||||||
let cfg_str = toml::to_string_pretty(&config).unwrap();
|
let cfg_str = toml::to_string_pretty(&config).unwrap();
|
||||||
let mut file = File::create(&p).await.unwrap();
|
let mut file = File::create(&p).await.unwrap();
|
||||||
file.write(cfg_str.as_bytes()).await;
|
let _ = file.write(cfg_str.as_bytes()).await;
|
||||||
}
|
}
|
||||||
let mut file = File::open(p).await.unwrap();
|
let mut file = File::open(p).await.unwrap();
|
||||||
let mut content = String::new();
|
let mut content = String::new();
|
||||||
@ -128,10 +131,31 @@ async fn parse_itunes(database: &Database, sender: &Sender<AppEvent>, path: Stri
|
|||||||
|
|
||||||
let app_version = soundcloud::get_app().await.unwrap().unwrap();
|
let app_version = soundcloud::get_app().await.unwrap().unwrap();
|
||||||
let client_id = soundcloud::get_client_id().await.unwrap().unwrap();
|
let client_id = soundcloud::get_client_id().await.unwrap().unwrap();
|
||||||
let playlists =
|
let playlists = soundcloud::get_playlists(
|
||||||
soundcloud::get_playlists(config.get_soundcloud().user_id, client_id, app_version)
|
config.get_soundcloud().user_id,
|
||||||
.await
|
client_id.clone(),
|
||||||
.unwrap();
|
app_version.clone(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let _ = sender.send(AppEvent::SoundcloudGot(playlists)).await;
|
let mut playlists = playlists.collection;
|
||||||
|
|
||||||
|
for playlist in playlists.iter_mut() {
|
||||||
|
if let Ok(tracks) = soundcloud::get_tracks(
|
||||||
|
playlist.tracks.clone(),
|
||||||
|
client_id.clone(),
|
||||||
|
app_version.clone(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
playlist.tracks = tracks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = sender
|
||||||
|
.send(AppEvent::SoundcloudGot(CloudPlaylists {
|
||||||
|
collection: playlists,
|
||||||
|
}))
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user