feat: Add album art to OGG files (#81)
This commit is contained in:
parent
c55c35ca77
commit
669dbb18e1
3 changed files with 36 additions and 4 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
|
@ -414,6 +414,12 @@ version = "0.21.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
|
checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "base64"
|
||||||
|
version = "0.22.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bindgen"
|
name = "bindgen"
|
||||||
version = "0.69.1"
|
version = "0.69.1"
|
||||||
|
|
@ -820,11 +826,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "down_on_spot"
|
name = "down_on_spot"
|
||||||
version = "0.2.5"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aspotify",
|
"aspotify",
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-stream",
|
"async-stream",
|
||||||
|
"base64 0.22.0",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"colored",
|
"colored",
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ panic = "abort"
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "down_on_spot"
|
name = "down_on_spot"
|
||||||
version = "0.2.6"
|
version = "0.3.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["exttex", "oSumAtrIX"]
|
authors = ["exttex", "oSumAtrIX"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
@ -20,6 +20,7 @@ clap = "4.2.1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
url = "2.2"
|
url = "2.2"
|
||||||
protobuf = "3.1"
|
protobuf = "3.1"
|
||||||
|
base64 = "0.22.0"
|
||||||
id3 = "1.3"
|
id3 = "1.3"
|
||||||
dirs = "5.0.0"
|
dirs = "5.0.0"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use base64::Engine;
|
||||||
use chrono::{Datelike, NaiveDate};
|
use chrono::{Datelike, NaiveDate};
|
||||||
use oggvorbismeta::{read_comment_header, replace_comment_header, CommentHeader, VorbisComments};
|
use oggvorbismeta::{read_comment_header, replace_comment_header, CommentHeader, VorbisComments};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
@ -40,8 +41,31 @@ impl super::Tag for OggTag {
|
||||||
self.set_raw(tag, value);
|
self.set_raw(tag, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_cover(&mut self, _mime: &str, _data: Vec<u8>) {
|
fn add_cover(&mut self, mime: &str, data: Vec<u8>) {
|
||||||
error!("ALBUM ART IN OGG NOT SUPPORTED!");
|
let mut picture: Vec<u8> = Vec::new();
|
||||||
|
|
||||||
|
// MIME type
|
||||||
|
picture.extend(3u32.to_be_bytes().iter());
|
||||||
|
picture.extend((mime.as_bytes().len() as u32).to_be_bytes().iter());
|
||||||
|
picture.extend(mime.as_bytes());
|
||||||
|
|
||||||
|
// Description
|
||||||
|
picture.extend(0u32.to_be_bytes().iter());
|
||||||
|
|
||||||
|
// Width, height, depth, and number of colors
|
||||||
|
picture.extend(0u32.to_be_bytes().iter());
|
||||||
|
picture.extend(0u32.to_be_bytes().iter());
|
||||||
|
picture.extend(0u32.to_be_bytes().iter());
|
||||||
|
picture.extend(0u32.to_be_bytes().iter());
|
||||||
|
|
||||||
|
// Image data
|
||||||
|
picture.extend((data.len() as u32).to_be_bytes().iter());
|
||||||
|
picture.extend(data);
|
||||||
|
|
||||||
|
self.tag.add_tag_single(
|
||||||
|
"METADATA_BLOCK_PICTURE",
|
||||||
|
&base64::engine::general_purpose::STANDARD.encode(picture),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_raw(&mut self, tag: &str, value: Vec<String>) {
|
fn set_raw(&mut self, tag: &str, value: Vec<String>) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue