Update script.js

This commit is contained in:
Broque Thomas 2026-01-04 15:14:49 -08:00
parent 381e43c76b
commit c9939ac418

View file

@ -9378,6 +9378,23 @@ async function streamAlbumTrack(albumIndex, trackIndex) {
const album = window.currentSearchResults[albumIndex];
console.log(`🎵 Album data:`, album);
// Surgical Fix: Handle YouTube results which are "flat" (no tracks array)
if (album.username === 'youtube') {
// For YouTube results, the "album" is actually the track itself
const track = album;
const trackData = {
...track,
username: 'youtube',
filename: track.filename,
artist: track.artist,
album: track.title, // Use title as album name for player
title: track.title
};
console.log(`🎵 Streaming YouTube track directly:`, trackData);
await startStream(trackData);
return;
}
if (!album.tracks || !album.tracks[trackIndex]) {
console.error(`❌ No tracks in album or invalid track index. Tracks length: ${album.tracks ? album.tracks.length : 'undefined'}`);
showToast('Track not found in album', 'error');