mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-12 21:52:33 +00:00
Remove old dependencies
This commit is contained in:
parent
77278111a1
commit
bf703e474d
3 changed files with 78 additions and 81 deletions
|
@ -12,15 +12,10 @@ categories = ["accessibility", "multimedia::audio"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Id3
|
# Id3
|
||||||
flate2 = { version = "1.0.20", optional = true }
|
flate2 = { version = "1.0.20", optional = true }
|
||||||
id3 = {version = "0.6.4", optional = true} # De/Encoding
|
|
||||||
filepath = { version = "0.1.1", optional = true } # wav/aiff only supports paths for some reason
|
|
||||||
# Ogg
|
# Ogg
|
||||||
ogg_pager = { version = "0.1.7", optional = true }
|
ogg_pager = { version = "0.1.7", optional = true }
|
||||||
# Mp4
|
# Mp4
|
||||||
mp4ameta = {version = "0.11.0", optional = true}
|
|
||||||
simdutf8 = { version = "0.1.3", optional = true }
|
simdutf8 = { version = "0.1.3", optional = true }
|
||||||
# Case insensitive keys (APE/FLAC/Opus/Vorbis)
|
|
||||||
unicase = { version = "2.6.0"}
|
|
||||||
|
|
||||||
# Quick string accessor methods for Tag
|
# Quick string accessor methods for Tag
|
||||||
paste = { version = "1.0.5", optional = true }
|
paste = { version = "1.0.5", optional = true }
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use super::read::read_comments;
|
use super::read::read_comments;
|
||||||
use super::write::create_comments;
|
|
||||||
use crate::error::{LoftyError, Result};
|
use crate::error::{LoftyError, Result};
|
||||||
use crate::picture::Picture;
|
use crate::picture::Picture;
|
||||||
use crate::types::file::AudioFile;
|
use crate::types::file::AudioFile;
|
||||||
|
|
|
@ -10,80 +10,83 @@ use std::fs::File;
|
||||||
use std::io::{Seek, SeekFrom, Write};
|
use std::io::{Seek, SeekFrom, Write};
|
||||||
|
|
||||||
use ogg_pager::Page;
|
use ogg_pager::Page;
|
||||||
use unicase::UniCase;
|
|
||||||
|
|
||||||
pub(crate) fn create_comments(packet: &mut Vec<u8>, comments: &HashMap<UniCase<String>, String>) {
|
// TODO
|
||||||
for (a, b) in comments {
|
// use unicase::UniCase;
|
||||||
let comment = format!("{}={}", a, b);
|
//
|
||||||
let comment_b = comment.as_bytes();
|
// pub(crate) fn create_comments(packet: &mut Vec<u8>, comments: &HashMap<UniCase<String>, String>) {
|
||||||
packet.extend((comment_b.len() as u32).to_le_bytes().iter());
|
// for (a, b) in comments {
|
||||||
packet.extend(comment_b.iter());
|
// let comment = format!("{}={}", a, b);
|
||||||
}
|
// let comment_b = comment.as_bytes();
|
||||||
}
|
// packet.extend((comment_b.len() as u32).to_le_bytes().iter());
|
||||||
|
// packet.extend(comment_b.iter());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
pub(crate) fn create_pages(
|
// TODO
|
||||||
file: &mut File,
|
// pub(crate) fn create_pages(
|
||||||
sig: &[u8],
|
// file: &mut File,
|
||||||
vendor: &str,
|
// sig: &[u8],
|
||||||
comments: &HashMap<UniCase<String>, String>,
|
// vendor: &str,
|
||||||
pictures: &Option<Cow<'static, [Picture]>>,
|
// comments: &HashMap<UniCase<String>, String>,
|
||||||
) -> Result<()> {
|
// pictures: &Option<Cow<'static, [Picture]>>,
|
||||||
let mut packet = Vec::new();
|
// ) -> Result<()> {
|
||||||
|
// let mut packet = Vec::new();
|
||||||
packet.extend(sig.iter());
|
//
|
||||||
packet.extend((vendor.len() as u32).to_le_bytes().iter());
|
// packet.extend(sig.iter());
|
||||||
packet.extend(vendor.as_bytes().iter());
|
// packet.extend((vendor.len() as u32).to_le_bytes().iter());
|
||||||
|
// packet.extend(vendor.as_bytes().iter());
|
||||||
let comments_len = pictures.as_ref().map_or_else(
|
//
|
||||||
|| comments.len() as u32,
|
// let comments_len = pictures.as_ref().map_or_else(
|
||||||
|pictures| (comments.len() + pictures.len()) as u32,
|
// || comments.len() as u32,
|
||||||
);
|
// |pictures| (comments.len() + pictures.len()) as u32,
|
||||||
|
// );
|
||||||
packet.extend(comments_len.to_le_bytes().iter());
|
//
|
||||||
create_comments(&mut packet, comments);
|
// packet.extend(comments_len.to_le_bytes().iter());
|
||||||
|
// create_comments(&mut packet, comments);
|
||||||
if let Some(pics) = pictures {
|
//
|
||||||
for pic in pics.iter() {
|
// if let Some(pics) = pictures {
|
||||||
let comment = format!(
|
// for pic in pics.iter() {
|
||||||
"METADATA_BLOCK_PICTURE={}",
|
// let comment = format!(
|
||||||
base64::encode(pic.as_flac_bytes())
|
// "METADATA_BLOCK_PICTURE={}",
|
||||||
);
|
// base64::encode(pic.as_flac_bytes())
|
||||||
let comment_b = comment.as_bytes();
|
// );
|
||||||
packet.extend((comment_b.len() as u32).to_le_bytes().iter());
|
// let comment_b = comment.as_bytes();
|
||||||
packet.extend(comment_b.iter());
|
// packet.extend((comment_b.len() as u32).to_le_bytes().iter());
|
||||||
}
|
// packet.extend(comment_b.iter());
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
let mut pages = page_from_packet(&mut *packet)?;
|
//
|
||||||
write_to(file, &mut pages, sig)?;
|
// let mut pages = page_from_packet(&mut *packet)?;
|
||||||
|
// write_to(file, &mut pages, sig)?;
|
||||||
Ok(())
|
//
|
||||||
}
|
// Ok(())
|
||||||
|
// }
|
||||||
fn write_to(mut data: &mut File, pages: &mut [Page], sig: &[u8]) -> Result<()> {
|
//
|
||||||
let first_page = Page::read(&mut data, false)?;
|
// fn write_to(mut data: &mut File, pages: &mut [Page], sig: &[u8]) -> Result<()> {
|
||||||
|
// let first_page = Page::read(&mut data, false)?;
|
||||||
let ser = first_page.serial;
|
//
|
||||||
|
// let ser = first_page.serial;
|
||||||
let mut writer = Vec::new();
|
//
|
||||||
writer.write_all(&*first_page.as_bytes())?;
|
// let mut writer = Vec::new();
|
||||||
|
// writer.write_all(&*first_page.as_bytes())?;
|
||||||
let first_md_page = Page::read(&mut data, false)?;
|
//
|
||||||
verify_signature(&first_md_page, sig)?;
|
// let first_md_page = Page::read(&mut data, false)?;
|
||||||
|
// verify_signature(&first_md_page, sig)?;
|
||||||
match sig {
|
//
|
||||||
VORBIS_COMMENT_HEAD => {
|
// match sig {
|
||||||
vorbis::write_to(data, &mut writer, first_md_page.content, ser, pages)?;
|
// VORBIS_COMMENT_HEAD => {
|
||||||
},
|
// vorbis::write_to(data, &mut writer, first_md_page.content, ser, pages)?;
|
||||||
OPUSTAGS => {
|
// },
|
||||||
opus::write_to(data, &mut writer, ser, pages)?;
|
// OPUSTAGS => {
|
||||||
},
|
// opus::write_to(data, &mut writer, ser, pages)?;
|
||||||
_ => unreachable!(),
|
// },
|
||||||
}
|
// _ => unreachable!(),
|
||||||
|
// }
|
||||||
data.seek(SeekFrom::Start(0))?;
|
//
|
||||||
data.set_len(first_page.end as u64)?;
|
// data.seek(SeekFrom::Start(0))?;
|
||||||
data.write_all(&*writer)?;
|
// data.set_len(first_page.end as u64)?;
|
||||||
|
// data.write_all(&*writer)?;
|
||||||
Ok(())
|
//
|
||||||
}
|
// Ok(())
|
||||||
|
// }
|
||||||
|
|
Loading…
Reference in a new issue