mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-29 07:18:49 +02:00
feat(convert): optionally retain original files
This commit is contained in:
@@ -332,6 +332,27 @@ String normalizedConvertedAudioFormat(String targetFormat) {
|
||||
}
|
||||
}
|
||||
|
||||
String convertedOutputFileName({
|
||||
required String originalFileName,
|
||||
required String targetFormat,
|
||||
required bool keepOriginal,
|
||||
}) {
|
||||
final dotIndex = originalFileName.lastIndexOf('.');
|
||||
final baseName = dotIndex > 0
|
||||
? originalFileName.substring(0, dotIndex)
|
||||
: originalFileName;
|
||||
final suffix = keepOriginal ? '_converted' : '';
|
||||
return '$baseName$suffix${convertTargetExtAndMime(targetFormat).ext}';
|
||||
}
|
||||
|
||||
String convertedLibraryItemId(String sourceId, String filePath) {
|
||||
var hash = 5381;
|
||||
for (final codeUnit in filePath.codeUnits) {
|
||||
hash = (((hash << 5) + hash) ^ codeUnit) & 0x7fffffff;
|
||||
}
|
||||
return '$sourceId:converted:${hash.toRadixString(16)}';
|
||||
}
|
||||
|
||||
int? convertedAudioBitrateKbps({
|
||||
required String targetFormat,
|
||||
required String bitrate,
|
||||
|
||||
Reference in New Issue
Block a user