/* the desktop's copy_stream_to_folder: the cached stream written into a folder picked on this phone, as the file it is โ€” no re-download, no tagging, no library row. Nothing leaves the phone, so the Wi-Fi guard has no say here. A track that has not finished streaming is counted back as missing, never fetched. */ async function copyToFolder(entries) { const files = entries.filter((e) => e.t?.stream && e.t.path).map((e) => ({ username: e.t.stream.username, path: e.t.path })); if (!files.length) return; try { const r = await api.pickLibraryFolder(); if (!r?.path) { player.error = "That folder has no path the phone can write to โ€” pick one on this phone's storage."; return; } const [saved, missing] = await api.copyStreamToFolder(files, r.path); note(saved ? saved + " file" + (saved === 1 ? "" : "s") + " copied" + (missing ? " ยท " + missing + " not cached yet" : "") : "Not cached yet โ€” play it through first"); } catch (e) { if (!/cancelled/.test(String(e))) oops(e); } }