vfmt: весь код в формате V master (без изменений логики)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
K1ndWha1eandClaude Opus 5.5 committed 2026-10-11 17:31:02 +03:00
1 parent 4c9184aeb2
commit 6161a7faaa
12 files changed
+405 -287

No files matched your search

+9 -10
View File
@@ -2,12 +2,11 @@ module metadata
import os
pub fn (mut audio Audio) detect_tags(mut data os.File) {
// ? --- Проверка версии ID3v1 ---
last_bytes := get_bytes(mut data, -128, 3)
if last_bytes[0..3].bytestr() == "TAG" {
if last_bytes[0..3].bytestr() == 'TAG' {
audio.id3v1.embedded = true
}
// ===============================
@@ -15,7 +14,7 @@ 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" {
if first_ten_bytes[..3].bytestr() == 'ID3' {
if first_ten_bytes[3] == 3 {
audio.id3v23.embedded = true
} else if first_ten_bytes[3] == 4 {
@@ -38,7 +37,7 @@ pub fn get_bytes(mut audio os.File, position int, size int) []u8 {
last_bytes := audio.read_bytes_at(size, u64(pos))
audio.seek(0, os.SeekMode.start) or { panic(err) }
// =========================================================
return last_bytes
}
@@ -92,7 +91,7 @@ pub fn encode_header[T](mut id3v T) {
id3v.encoded_header << [id3v.version]
// Минорная версия и спец. флаги
id3v.encoded_header << []u8{len: 2}
id3v.encoded_header << metadata.encode_header_size(id3v.size)
}
@@ -110,7 +109,7 @@ pub fn encode_embed_tags[T](mut id3v2 T) {
// Читаются только заполненные тэги
if id3v2.$(field.name).cur_size > 0 {
// Фрейма не было в файле и init не вызывался: имя берётся из поля структуры
if id3v2.$(field.name).name == "" && field.name.len == 4 {
if id3v2.$(field.name).name == '' && field.name.len == 4 {
id3v2.$(field.name).init(field.name, id3v2.version)
}
@@ -140,8 +139,8 @@ pub fn encode_embed_tags[T](mut id3v2 T) {
// Добавляет аудио из файла после нового тэга в encoded_header, старый тэг пропускается
pub fn insert_tags_into_audio[T](mut id3v2 T, mut audio os.File) ! {
header := get_bytes(mut audio, 0, 10)
if header.len < 10 || header[..3].bytestr() != "ID3" {
return error("в файле нет тэга ID3v2")
if header.len < 10 || header[..3].bytestr() != 'ID3' {
return error('в файле нет тэга ID3v2')
}
// Размер старого тэга берётся из файла, id3v2.size уже хранит размер нового.
@@ -155,7 +154,7 @@ pub fn insert_tags_into_audio[T](mut id3v2 T, mut audio os.File) ! {
audio.seek(0, .end)!
file_size := u64(audio.tell()!)
if audio_start > file_size {
return error("размер тэга (${audio_start}) больше размера файла (${file_size})")
return error('размер тэга (${audio_start}) больше размера файла (${file_size})')
}
// Аудио читается сразу в конец encoded_header, без промежуточной копии всего файла
@@ -168,7 +167,7 @@ pub fn insert_tags_into_audio[T](mut id3v2 T, mut audio os.File) ! {
for read < sound_len {
n := unsafe { audio.read_into_ptr(&u8(id3v2.encoded_header.data) + header_len + read, sound_len - read)! }
if n == 0 {
return error("файл закончился раньше ожидаемого")
return error('файл закончился раньше ожидаемого')
}
read += n
}