*небольшой рефакторинг

*добавлен метод encode_size для Frame
This commit is contained in:
K1ndWha1e committed 2026-07-12 00:26:27 +03:00
1 parent 81034325a1
commit 18ac12f3b5
6 files changed
+55 -60

No files matched your search

+30 -8
View File
@@ -15,14 +15,13 @@ pub fn (mut audio Audio) detect_tags(mut data os.File) {
// ? --- Проверка версии ID3v23.3 ---
first_ten_bytes := get_bytes(mut data, 0, 4)
if first_ten_bytes[..3].bytestr() == "ID3" && first_ten_bytes[3] == 3 {
audio.id3v23.embedded = true
}
// ===============================
// ? --- Проверка версии ID3v23.4 ---
if first_ten_bytes[..3].bytestr() == "ID3" && first_ten_bytes[3] == 4 {
audio.id3v24.embedded = true
if first_ten_bytes[..3].bytestr() == "ID3" {
if first_ten_bytes[3] == 3 {
audio.id3v23.embedded = true
} else if first_ten_bytes[3] == 4 {
// Проверка версии ID3v23.4
audio.id3v24.embedded = true
}
}
// ===============================
}
@@ -42,3 +41,26 @@ pub fn get_bytes(mut audio os.File, position int, size int) []u8 {
return last_bytes
}
pub fn fill_tag[T](mut tag T, mut audio os.File) {
mut current_frame := &Frame{}
// Самая первая позиция
mut start_position := u64(10)
// Получаем вне возможные байты
all_tag_bytes := get_bytes(mut audio, 10, int(tag.size + start_position))
for tag.size > start_position {
current_frame.fill_frame(all_tag_bytes, start_position, tag.version)
start_position = current_frame.end
tag.size -= current_frame.size
tag.add_frame(current_frame)
}
}
pub fn get_full_size[T](mut tag T, mut audio os.File) {
// Первые 10 байт тэга
first_ten_bytes := get_bytes(mut audio, 0, 10)
tag.size = (u64(first_ten_bytes[6]) << 21) | (u64(first_ten_bytes[7]) << 14) | (u64(first_ten_bytes[8]) << 7) | u64(first_ten_bytes[9])
}