This commit is contained in:
aiden 2023-04-25 18:06:20 +01:00
parent 06bcd1653f
commit 4fbb85032e
Signed by: aiden
GPG Key ID: EFA9C74AEBF806E0

92
scdl.js

@ -1,7 +1,7 @@
/* /*
ISC License ISC License
Copyright (c) 2022, aiden (aiden@cmp.bz) Copyright (c) 2023, aiden (aiden@cmp.bz)
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
@ -15,36 +15,66 @@
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
function scdl() { if (!window.get_r) {
if (typeof scdl.c == "undefined") { window.get_r = function get_r() {
scdl.c = 0n; if (get_r.cache) {
} return get_r.cache[1];
let key = "scdl" + Math.floor(Math.random() * 0x100000000).toString(0x10).padStart(8, "0") + scdl.c++;
let fuck = true;
webpackJsonp.push([[], { [key]: function (_, __, r) {
if (fuck) {
fuck = false;
return;
} }
for (let idx = 0; typeof scdl.f == "undefined"; ++idx) { get_r.cache = [];
let obj = r(idx); webpackJsonp.push([[], {
if ("getCurrentSound" in obj) { get_r(_, __, r) {
scdl.f = obj; get_r.cache.push(r);
} }
} }, [["get_r"]]]);
let player = scdl.f.getCurrentSound().player.player._player._controllerManager._cacheManager._players.find(e => e._playlistSegmentRetriever != null); return get_r.cache[1];
if (!player) { }
return alert("Play a song."); }
} function scdl() {
let segments = player._playlistSegmentRetriever._segments; function find(...functions) {
if (player._playlist._data.segments.length != segments.length) { functions = new Set(functions);
return alert("Song not fully downloaded yet."); let r = get_r();
} let v = {};
let u8_arrays = []; let max = webpackJsonp.flat(Infinity).length;
for (let idx = 0; idx < segments.length; ++idx) { for (let idx = 0; idx < max; ++idx) {
u8_arrays.push(segments[idx].dataRetrieveJob._jobControl.progressUpdates.getProgressSoFar().data); try {
} let obj = r(idx);
alert("issa " + player._transmuxerAndMimeType.mimeType); for (let fn of functions) {
location = URL.createObjectURL(new Blob(u8_arrays, { type: "application/octet-stream" })); let p = fn(obj);
} }, [[key]]]); if (p) {
v = { ...v, ...p };
functions.delete(fn);
if (functions.size == 0) {
return v;
}
}
}
} catch {}
}
return null;
}
if (!scdl.cache) {
scdl.cache = find(
function (obj) {
if (obj.getCurrentSound) {
return { getCurrentSound: obj.getCurrentSound };
}
}
);
}
let curr = scdl.cache.getCurrentSound();
let streamUrlRetriever = curr.player.player._player._controllerManager._streamUrlRetriever;
streamUrlRetriever._retrieveStreamUrl(
streamUrlRetriever._mediaPayload.transcodings.find(p =>
p.format.protocol == "progressive"
).url
).onCompletion(async url => {
let blobURL = URL.createObjectURL(new Blob(
[await fetch(url).then(p => p.arrayBuffer())],
{ type: "application/octet-stream", }
));
let anchor = document.createElement("a");
anchor.download = curr.attributes.permalink + ".mp3";
anchor.href = blobURL;
anchor.click();
});
} }