mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
7a7a9f5e6b
111 of 122 top-level src/utils/ files move into 16 topic folders (audio, cache, cover, share, server, playback, playlist, deviceSync, waveform, mix, format, export, changelog, ui, perf, componentHelpers). True singletons with no cluster stay at the utils/ root. Pure file-move: a path-aware codemod rewrote 539 relative-import specifiers across 275 files; no logic touched. The hot-path coverage gate list (.github/frontend-hot-path-files.txt) is updated to the new paths for the 11 gated utils files — a mechanical consequence of the move, not a CI change. tsc is green.
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import type { SubsonicSong } from '../../api/subsonicTypes';
|
|
import { passesMixMinRatings, type MixMinRatingsConfig } from '../mix/mixRatingFilter';
|
|
|
|
export const AUDIOBOOK_GENRES = [
|
|
'hörbuch', 'hoerbuch', 'hörspiel', 'hoerspiel',
|
|
'audiobook', 'audio book', 'spoken word', 'spokenword',
|
|
'podcast', 'kapitel', 'thriller', 'krimi', 'speech',
|
|
'fantasy', 'comedy', 'literature',
|
|
];
|
|
|
|
export function formatRandomMixDuration(seconds: number): string {
|
|
if (!seconds || isNaN(seconds)) return '0:00';
|
|
const m = Math.floor(seconds / 60);
|
|
const s = seconds % 60;
|
|
return `${m}:${s.toString().padStart(2, '0')}`;
|
|
}
|
|
|
|
interface FilterArgs {
|
|
excludeAudiobooks: boolean;
|
|
customGenreBlacklist: string[];
|
|
mixRatingCfg: MixMinRatingsConfig;
|
|
}
|
|
|
|
export function filterRandomMixSongs(songs: SubsonicSong[], args: FilterArgs): SubsonicSong[] {
|
|
const { excludeAudiobooks, customGenreBlacklist, mixRatingCfg } = args;
|
|
return songs.filter(song => {
|
|
if (!excludeAudiobooks) return true;
|
|
const checkText = (text: string) => {
|
|
const t = text.toLowerCase();
|
|
if (AUDIOBOOK_GENRES.some(ag => t.includes(ag))) return true;
|
|
if (customGenreBlacklist.some(bg => t.includes(bg.toLowerCase()))) return true;
|
|
return false;
|
|
};
|
|
if (song.genre && checkText(song.genre)) return false;
|
|
if (song.title && checkText(song.title)) return false;
|
|
if (song.album && checkText(song.album)) return false;
|
|
if (song.artist && checkText(song.artist)) return false;
|
|
if (!passesMixMinRatings(song, mixRatingCfg)) return false;
|
|
return true;
|
|
});
|
|
}
|