Add variables documentation to the readme and allow variables in the downloader path
This commit is contained in:
parent
19b25479ae
commit
9779b4af6b
3 changed files with 26 additions and 8 deletions
17
README.md
17
README.md
|
|
@ -51,9 +51,24 @@ Usage:
|
|||
down_on_spot.exe (track_url | album_url | playlist_url | artist_url)
|
||||
```
|
||||
|
||||
### Template variables
|
||||
|
||||
The following variables are available for `path` and `filename_template` in the `settings.json`:
|
||||
|
||||
- %0disc%
|
||||
- %0track%
|
||||
- %album%
|
||||
- %albumArtist%
|
||||
- %albumArtists%
|
||||
- %artist%
|
||||
- %disc%
|
||||
- %id%
|
||||
- %title%
|
||||
- %track%
|
||||
|
||||
## Known issues
|
||||
|
||||
- KDE Konsole specific prints to clear the screen or color the text does not work on windows
|
||||
- KDE Konsole specific prints to clear the screen or color the text does not work on windows
|
||||
- Premium account dependency due to librespot
|
||||
- Sometimes downloads slow down
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ impl Downloader {
|
|||
let queue: Vec<Download> = tracks.into_iter().map(|t| t.into()).collect();
|
||||
self.add_to_queue_multiple(queue).await;
|
||||
}
|
||||
|
||||
|
||||
// Unsupported
|
||||
SpotifyItem::Other(u) => {
|
||||
error!("Unsupported URI: {}", u);
|
||||
|
|
@ -272,8 +272,7 @@ impl DownloaderInternal {
|
|||
.get_album(&track.album.id.ok_or(SpotifyError::Unavailable)?, None)
|
||||
.await?
|
||||
.data;
|
||||
// Generate path
|
||||
let mut filename = config.filename_template.to_owned();
|
||||
|
||||
let tags: Vec<(&str, String)> = vec![
|
||||
("%title%", sanitize(&track.name)),
|
||||
(
|
||||
|
|
@ -331,10 +330,15 @@ impl DownloaderInternal {
|
|||
),
|
||||
),
|
||||
];
|
||||
|
||||
// Generate path
|
||||
let mut filename = config.filename_template.to_owned();
|
||||
let mut path_template = config.path.to_owned();
|
||||
for (t, v) in tags {
|
||||
path_template = path_template.replace(t, &v);
|
||||
filename = filename.replace(t, &v);
|
||||
}
|
||||
let path = config.path.join(filename);
|
||||
let path = PathBuf::from(path_template).join(filename);
|
||||
tokio::fs::create_dir_all(path.parent().unwrap()).await?;
|
||||
|
||||
// Download
|
||||
|
|
@ -809,7 +813,7 @@ impl ToString for Quality {
|
|||
pub struct DownloaderConfig {
|
||||
pub concurrent_downloads: usize,
|
||||
pub quality: Quality,
|
||||
pub path: PathBuf,
|
||||
pub path: String,
|
||||
pub filename_template: String,
|
||||
pub id3v24: bool,
|
||||
pub convert_to_mp3: bool,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use crate::downloader::DownloaderConfig;
|
||||
use crate::downloader::Quality;
|
||||
use crate::error::SpotifyError;
|
||||
use std::path::PathBuf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use tokio::{
|
||||
|
|
@ -36,7 +35,7 @@ impl Settings {
|
|||
downloader: DownloaderConfig {
|
||||
concurrent_downloads: 4,
|
||||
quality: Quality::Q320,
|
||||
path: PathBuf::from("downloads"),
|
||||
path: "downloads".to_string(),
|
||||
filename_template: "%artist% - %title%".to_string(),
|
||||
id3v24: true,
|
||||
convert_to_mp3: false,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue