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"
|
||||
checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.69.1"
|
||||
|
|
@ -820,11 +826,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "down_on_spot"
|
||||
version = "0.2.5"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"aspotify",
|
||||
"async-std",
|
||||
"async-stream",
|
||||
"base64 0.22.0",
|
||||
"chrono",
|
||||
"clap",
|
||||
"colored",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ panic = "abort"
|
|||
|
||||
[package]
|
||||
name = "down_on_spot"
|
||||
version = "0.2.6"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
authors = ["exttex", "oSumAtrIX"]
|
||||
build = "build.rs"
|
||||
|
|
@ -20,6 +20,7 @@ clap = "4.2.1"
|
|||
log = "0.4"
|
||||
url = "2.2"
|
||||
protobuf = "3.1"
|
||||
base64 = "0.22.0"
|
||||
id3 = "1.3"
|
||||
dirs = "5.0.0"
|
||||
chrono = "0.4"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use base64::Engine;
|
||||
use chrono::{Datelike, NaiveDate};
|
||||
use oggvorbismeta::{read_comment_header, replace_comment_header, CommentHeader, VorbisComments};
|
||||
use std::fs::File;
|
||||
|
|
@ -40,8 +41,31 @@ impl super::Tag for OggTag {
|
|||
self.set_raw(tag, value);
|
||||
}
|
||||
|
||||
fn add_cover(&mut self, _mime: &str, _data: Vec<u8>) {
|
||||
error!("ALBUM ART IN OGG NOT SUPPORTED!");
|
||||
fn add_cover(&mut self, mime: &str, data: Vec<u8>) {
|
||||
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>) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue