android: a folder of audio files, and a paste of track links
The paste door now reads itself the way the desktop's does: one track link in the paste and every line is looked up on its own public page (playlist_import_track_links), which is the way past Spotify's 100-track public ceiling — the wait screen counts them as they arrive. A fourth door imports a folder of audio files off this phone, picked with the storage plugin's own document-tree picker; playlist_import_folder grew a path argument for it, because on Android it had no dialog to open and always answered nothing. A YouTube playlist link needed no door at all — the link one already dispatches it.
This commit is contained in:
1 parent
24c6857847
commit
c737809325
9 files changed
+215
-47
No files matched your search
@@ -288,6 +288,45 @@ function mockImport(cmd, args) {
|
||||
}, 180);
|
||||
});
|
||||
}
|
||||
if (cmd === "playlist_import_track_links") {
|
||||
const links = String(args?.text || "").split(/\r?\n/).map((l) => l.trim())
|
||||
.filter((l) => /^https?:\/\//.test(l) || /^spotify:track:/.test(l));
|
||||
if (!links.length) return Promise.reject(new Error("Nothing to import in that paste."));
|
||||
/* one row per link, in the paste's order — the lines a real lookup
|
||||
would have read off each track's own public page. A page each is
|
||||
slow, and the pace here is slow on purpose: the walk's still takes
|
||||
long enough to miss a wait card that closes inside a second. */
|
||||
const named = ["Aphex Twin - Track 1", "Daft Punk - One More Time", "Bicep - Glue", "Four Tet - Track 2"];
|
||||
const entries = impParse(links.map((_, i) => named[i % named.length]).join("\n"));
|
||||
return new Promise((r) => {
|
||||
let done = 0;
|
||||
const tick = setInterval(() => {
|
||||
done++;
|
||||
mockEmit("playlist:link-progress", { done, total: links.length, waiting: false });
|
||||
if (done >= links.length) {
|
||||
clearInterval(tick);
|
||||
setTimeout(() => r(impDraft(entries, args?.name || "Pasted track links", "links", args?.name ?? null, {
|
||||
warnings: [entries.length + " track" + (entries.length === 1 ? "" : "s") + " read from " + links.length + " pasted link" + (links.length === 1 ? "" : "s") + "."],
|
||||
})), 250);
|
||||
}
|
||||
}, 600);
|
||||
});
|
||||
}
|
||||
if (cmd === "playlist_import_folder") {
|
||||
const root = String(args?.path || "");
|
||||
if (!root) return Promise.resolve(null); /* the desktop's dialog, dismissed */
|
||||
const name = root.split(/[\\/]/).filter(Boolean).pop() || "Folder";
|
||||
/* four files off a record the library already holds, as the backend's
|
||||
walk hands them over: every row local, matched by path */
|
||||
const own = albums[0];
|
||||
const entries = tracksFor(own.id).slice(0, 4).map((t, i) => ({
|
||||
ordinal: i, title: t.title, artist: own.artist, album: own.title,
|
||||
duration_secs: t.duration_secs, start_ms: null, raw: t.path,
|
||||
resolution: "local", matched_by: "path", path: t.path, art_path: own.art_path,
|
||||
track_id: null, art_url: null, isrc: null,
|
||||
}));
|
||||
return new Promise((r) => setTimeout(() => r(impDraft(entries, name, "folder", name)), 500));
|
||||
}
|
||||
if (cmd === "playlist_import_commit") {
|
||||
const name = String(args?.name || "").trim();
|
||||
if (!name) return Promise.reject(new Error("The playlist needs a name"));
|
||||
|
||||
Reference in new issue
Block a user