Skip to content

Commit

Permalink
Merge pull request #1 from Stockpesce/main
Browse files Browse the repository at this point in the history
Reorder quality profiles, add MP3_320, remove unused dependencies, group binary dependencies
  • Loading branch information
zggff authored Nov 19, 2023
2 parents 548ebe7 + 142caf3 commit 91c38c0
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 36 deletions.
45 changes: 22 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ readme = "README.md"
keywords = ["deezer", "downloader"]
description = "crate to download music from deezer"

[features]
binary = ["clap", "env_logger", "futures"]

[dependencies]
reqwest = {version = "0.11.7", features = ["json", "cookies"]}
serde = {version = "1.0.130", features = ["derive"] }
reqwest = { version = "0.11.7", features = ["json", "cookies"] }
serde = { version = "1.0.130", features = ["derive"] }
serde_json = "1.0.72"
md5 = "0.7.0"
byteorder = "1.4.3"
hex = "0.4.3"
hex-literal = "0.3.4"
block-modes = "0.8.1"
Expand All @@ -23,7 +25,14 @@ id3 = "0.6.6"
tokio = { version = "1.23.0", features = ["full"] }
anyhow = "1.0.68"
log = "0.4.17"
env_logger = "0.10.0"
clap = { version = "4.0.30", features = ["derive"] }
futures = "0.3.25"
indicatif = "0.17.7"

# binary dependencies
clap = { version = "4.0.30", features = ["derive"], optional = true }
env_logger = { version = "0.10.0", optional = true }
futures = { version = "0.3.25", optional = true }


[[bin]]
name = "deezer_downloader"
required-features = ["binary"]
7 changes: 5 additions & 2 deletions src/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ impl Downloader {
"formats": [
{
"cipher": "BF_CBC_STRIPE",
"format": "MP3_64"
"format": "MP3_320"
},
{
"cipher": "BF_CBC_STRIPE",
"format": "MP3_128"
},
{
"cipher": "BF_CBC_STRIPE",
"format": "MP3_64"
},
{
"cipher": "BF_CBC_STRIPE",
"format": "MP3_MISC"
Expand Down Expand Up @@ -192,7 +196,6 @@ impl Downloader {
})
.collect();


match decrypted_song {
Ok(song) => Ok(song.into_iter().flatten().collect()),
Err(err) => Err(anyhow::Error::new(DeezerApiError::from(err))),
Expand Down
19 changes: 14 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
use std::{fs, path::PathBuf, sync::{Arc, atomic::{AtomicUsize, Ordering}}};
use std::{
fs,
path::PathBuf,
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
},
};

use clap::{Parser, Subcommand};
use deezer_downloader::{song::Song, Downloader, Playlist, SongMetadata};
Expand Down Expand Up @@ -98,9 +105,7 @@ async fn main() -> anyhow::Result<()> {
.tracks
.data
.iter()
.map(|song| {
filename_from_metadata(song)
})
.map(|song| filename_from_metadata(song))
.collect();
// INFO: this writes all song names into m3u8 file regardless of download status
fs::write(
Expand Down Expand Up @@ -141,7 +146,11 @@ async fn main() -> anyhow::Result<()> {
}));
}
join_all(tasks).await;
println!("DOWNLOADED: {} OUT OF {}", cnt.load(Ordering::Relaxed), playlist.len);
println!(
"DOWNLOADED: {} OUT OF {}",
cnt.load(Ordering::Relaxed),
playlist.len
);
pb.finish_and_clear();
}
}
Expand Down

0 comments on commit 91c38c0

Please sign in to comment.