feat(url-play): YouTube/Instagram entfernt nur MP3-Links; UI: Checkbox entfernt, Button heißt jetzt 'Download'

This commit is contained in:
vibe-bot 2025-08-08 18:31:15 +02:00
parent d4b839f888
commit c2bd7b4503
3 changed files with 11 additions and 116 deletions

View file

@ -23,7 +23,6 @@ export default function App() {
const selectedCount = useMemo(() => Object.values(selectedSet).filter(Boolean).length, [selectedSet]);
const [clock, setClock] = useState<string>(() => new Intl.DateTimeFormat('de-DE', { hour: '2-digit', minute: '2-digit', hour12: false, timeZone: 'Europe/Berlin' }).format(new Date()));
const [mediaUrl, setMediaUrl] = useState<string>('');
const [mediaDownload, setMediaDownload] = useState<boolean>(false);
useEffect(() => {
(async () => {
@ -186,23 +185,19 @@ export default function App() {
if (e.key === 'Enter') {
if (!selected) { setError('Bitte Voice-Channel wählen'); return; }
const [guildId, channelId] = selected.split(':');
try { await playUrl(mediaUrl, guildId, channelId, volume, mediaDownload); }
try { await playUrl(mediaUrl, guildId, channelId, volume); }
catch (err: any) { setError(err?.message || 'Play-URL fehlgeschlagen'); }
}
}}
placeholder="YouTube/Instagram/MP3 URL..."
placeholder="MP3 URL..."
/>
<button type="button" className="tab" onClick={async () => {
if (!selected) { setError('Bitte Voice-Channel wählen'); return; }
const [guildId, channelId] = selected.split(':');
try { await playUrl(mediaUrl, guildId, channelId, volume, mediaDownload); }
try { await playUrl(mediaUrl, guildId, channelId, volume); }
catch (e: any) { setError(e?.message || 'Play-URL fehlgeschlagen'); }
}}>Abspielen</button>
}}>Download</button>
</div>
<label style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<input type="checkbox" checked={mediaDownload} onChange={(e) => setMediaDownload(e.target.checked)} />
Download speichern
</label>
</section>
{!isAdmin && (

View file

@ -88,10 +88,10 @@ export async function adminRename(from: string, to: string): Promise<string> {
return data?.to as string;
}
export async function playUrl(url: string, guildId: string, channelId: string, volume: number, download?: boolean): Promise<void> {
export async function playUrl(url: string, guildId: string, channelId: string, volume: number): Promise<void> {
const res = await fetch(`${API_BASE}/play-url`, {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ url, guildId, channelId, volume, download: !!download })
body: JSON.stringify({ url, guildId, channelId, volume })
});
if (!res.ok) {
const data = await res.json().catch(() => ({}));