From 348f885920fd8063b5819d73735ad994bc935188 Mon Sep 17 00:00:00 2001 From: Lorenzo Pistone Date: Thu, 14 Feb 2019 16:45:42 +0100 Subject: [PATCH] Also give album name and spotify id to the helper script --- src/main.rs | 5 +++-- tag_ogg | 13 +++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1decca5..48c3ced 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ use librespot_core::authentication::Credentials; use librespot_core::config::SessionConfig; use librespot_core::session::Session; use librespot_core::spotify_id::SpotifyId; -use librespot_metadata::{Artist, FileFormat, Metadata, Track}; +use librespot_metadata::{Artist, FileFormat, Metadata, Track, Album}; use regex::Regex; use scoped_threadpool::Pool; use tokio_core::reactor::Core; @@ -96,9 +96,10 @@ fn main() { std::fs::write(&fname, &decrypted_buffer[0xa7..]).expect("Cannot write decrypted track"); info!("Filename: {}", fname); } else { + let album = core.run(Album::get(&session, track.album)).expect("Cannot get album metadata"); let mut cmd = Command::new(args[3].to_owned()); cmd.stdin(Stdio::piped()); - cmd.arg(track.name).args(artists_strs.iter()); + cmd.arg(id.to_base62()).arg(track.name).arg(album.name).args(artists_strs.iter()); let mut child = cmd.spawn().expect("Could not run helper program"); let pipe = child.stdin.as_mut().expect("Could not open helper stdin"); pipe.write_all(&decrypted_buffer[0xa7..]).expect("Failed to write to stdin"); diff --git a/tag_ogg b/tag_ogg index ca1bd47..732bd2e 100755 --- a/tag_ogg +++ b/tag_ogg @@ -2,12 +2,17 @@ set -e -fname=$(echo "${2} - ${1}.ogg" | tr '/' - | tr '\0' ' ') +fname=$(echo "${4} - ${2}.ogg" | tr '/' - | tr '\0' ' ') cat > "$fname" { - echo "TITLE=${1}" | tr '\n' ' ' - shift + echo "SPOTIFY_ID=${1}" + title=$(tr '\n' ' ' <<< "${2}") + album=$(tr '\n' ' ' <<< "${3}") + echo "TITLE=${title}" + echo "ALBUM=${album}" + shift 3 for artist in "$@"; do - echo "ARTIST=${artist}" | tr '\n' ' ' + artist=$(tr '\n' ' ' <<< "${artist}") + echo "ARTIST=${artist}" done } | vorbiscomment -a "$fname"