feat(upload): enhance audio upload handling and user feedback
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m1s
ci / db / db (push) Successful in 1m16s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m12s
ci / api / api (push) Successful in 45s
ci / recommender / recommender (push) Successful in 1m50s
ci / ts / ts (packages + web) (push) Failing after 6m53s
ci / docker / docker (образы собираются — их сервер собирает сам при обновлении) (push) Successful in 1m13s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m1s
ci / db / db (push) Successful in 1m16s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m12s
ci / api / api (push) Successful in 45s
ci / recommender / recommender (push) Successful in 1m50s
ci / ts / ts (packages + web) (push) Failing after 6m53s
ci / docker / docker (образы собираются — их сервер собирает сам при обновлении) (push) Successful in 1m13s
- Introduced a new warning for users uploading non-FLAC or WAV formats, indicating that these formats should only be used as a last resort. - Added functionality to highlight files needing format attention in the upload queue. - Updated the UI to provide clearer guidance on acceptable audio formats during uploads. - Improved documentation to reflect changes in upload requirements and user interface updates.
This commit is contained in:
1 parent
74da457362
commit
1e3b350dfc
49 files changed
+147
-5572
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { needsFormatAttention } from './files';
|
||||
|
||||
describe('needsFormatAttention', () => {
|
||||
it('marks everything except flac and wav', () => {
|
||||
expect(needsFormatAttention('flac', 'a.mp3')).toBe(false);
|
||||
expect(needsFormatAttention('WAV', 'track.wav')).toBe(false);
|
||||
expect(needsFormatAttention(null, 'Кино/01.wav')).toBe(false);
|
||||
expect(needsFormatAttention('mp3', 'a.flac')).toBe(true);
|
||||
expect(needsFormatAttention(null, 'folder/song.MP3')).toBe(true);
|
||||
expect(needsFormatAttention(null, 'song.m4a')).toBe(true);
|
||||
expect(needsFormatAttention(null, 'noext')).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -8,6 +8,22 @@ export interface PickedFile {
|
||||
/** Форматы, которые принимает очередь (сервер всё равно проверяет содержимое через ffprobe). */
|
||||
export const AUDIO_EXTENSIONS = ['flac', 'mp3', 'm4a', 'ogg', 'opus', 'wav', 'aiff', 'aif', 'wv'];
|
||||
|
||||
/** То, что просим присылать. MP3 и прочие — крайний случай, их помечает очередь. */
|
||||
const PREFERRED_AUDIO = new Set(['flac', 'wav']);
|
||||
|
||||
export function audioExt(name: string): string {
|
||||
const base = name.split(/[/\\]/).pop() ?? name;
|
||||
const dot = base.lastIndexOf('.');
|
||||
if (dot < 0 || dot === base.length - 1) return '';
|
||||
return base.slice(dot + 1).toLowerCase();
|
||||
}
|
||||
|
||||
/** Не FLAC и не WAV: в очереди на добавление такой файл нужно выделить. */
|
||||
export function needsFormatAttention(format: string | null | undefined, name: string): boolean {
|
||||
const ext = (format || audioExt(name)).toLowerCase();
|
||||
return ext !== '' && !PREFERRED_AUDIO.has(ext);
|
||||
}
|
||||
|
||||
export function isAudio(name: string): boolean {
|
||||
const ext = name.split('.').pop()?.toLowerCase() ?? '';
|
||||
return AUDIO_EXTENSIONS.includes(ext);
|
||||
|
||||
Reference in new issue
Block a user