基础实现代码框架先上,后面慢慢改逻辑

This commit is contained in:
2026-08-23 19:24:16 +08:00
parent 6c4e77ca00
commit 9a60441e04
9 changed files with 446 additions and 1 deletions
+141
View File
@@ -0,0 +1,141 @@
// lib/metadata/metadata_model.dart
import 'dart:typed_data';
/// 从音频文件读取的原始元数据(未经任何处理)
class RawMetadata {
final String title;
final String artist;
final String album;
final String albumArtist;
final String composer;
final String genre;
final int year;
final int trackNumber;
final int discNumber;
final Uint8List? artwork;
const RawMetadata({
this.title = '',
this.artist = '',
this.album = '',
this.albumArtist = '',
this.composer = '',
this.genre = '',
this.year = 0,
this.trackNumber = 0,
this.discNumber = 0,
this.artwork,
});
/// 判断是否为空(没有任何有效信息)
bool get isEmpty =>
title.isEmpty &&
artist.isEmpty &&
album.isEmpty &&
albumArtist.isEmpty &&
composer.isEmpty &&
genre.isEmpty &&
year == 0 &&
trackNumber == 0 &&
discNumber == 0 &&
artwork == null;
bool get isNotEmpty => !isEmpty;
}
/// 经过标准化处理后的元数据
class NormalizedMetadata {
final String title;
final String artist;
final String album;
final String albumArtist;
final String composer;
final String genre;
final int year;
final int trackNumber;
final int discNumber;
final Uint8List? artwork;
const NormalizedMetadata({
this.title = '',
this.artist = '',
this.album = '',
this.albumArtist = '',
this.composer = '',
this.genre = '',
this.year = 0,
this.trackNumber = 0,
this.discNumber = 0,
this.artwork,
});
bool get isEmpty =>
title.isEmpty &&
artist.isEmpty &&
album.isEmpty &&
albumArtist.isEmpty &&
composer.isEmpty &&
genre.isEmpty &&
year == 0 &&
trackNumber == 0 &&
discNumber == 0 &&
artwork == null;
bool get isNotEmpty => !isEmpty;
}
/// 带置信度的候选元数据
class CandidateMetadata {
final NormalizedMetadata metadata;
final double confidence; // 0.0 ~ 1.0
final Map<String, double> evidence; // 证据来源权重
const CandidateMetadata({
required this.metadata,
required this.confidence,
this.evidence = const {},
});
}
/// 最终确认的元数据
class FinalMetadata {
final String title;
final String artist;
final String album;
final String albumArtist;
final String composer;
final String genre;
final int year;
final int trackNumber;
final int discNumber;
final Uint8List? artwork;
final String source; // 'file_tag', 'filename', 'cache', 'user_corrected'
const FinalMetadata({
this.title = '',
this.artist = '',
this.album = '',
this.albumArtist = '',
this.composer = '',
this.genre = '',
this.year = 0,
this.trackNumber = 0,
this.discNumber = 0,
this.artwork,
this.source = 'unknown',
});
bool get isEmpty =>
title.isEmpty &&
artist.isEmpty &&
album.isEmpty &&
albumArtist.isEmpty &&
composer.isEmpty &&
genre.isEmpty &&
year == 0 &&
trackNumber == 0 &&
discNumber == 0 &&
artwork == null;
bool get isNotEmpty => !isEmpty;
}