Last active
February 12, 2025 16:36
-
-
Save DreamOfTranscendence/82013bb47abb16d53b0f18c7654d1738 to your computer and use it in GitHub Desktop.
sndcld_crkr_l0l_node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //sndcld craker, nodejs. lol. | |
| //this is a fun client-side-only lite 'hack'. It may not continue to work if the bot-detection system is well designed or if the developers see this hack and change the exact text patterns in their API | |
| //designed to run in nodejs, nodejs has no audio player so I reccomend using ffplay that comes with the ffmpeg library/full-install | |
| var https=require("https"); | |
| //exec_=require("child_process"); | |
| //zlib = require("zlib"); //use on resp buffer if needed to implement accept-encoding: gzip request header | |
| if(typeof self=="undefined") let self=this; //must be global context this right here | |
| self.fakeFox='Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0'; | |
| self.options = { | |
| method: 'GET' | |
| }; | |
| self.l_rez=[]; | |
| let curl=function getHttpsUrl(url,cb){ | |
| var cbf=typeof cb=="function", | |
| req = https.request(url, self.options, (res) => { | |
| var rd=[],rv={"hed":res.headers,"sc":res.statusCode,"url":url}, | |
| ri=self.l_rez.push(rv); | |
| res.on('data', (d) => { rd.push(d); }); | |
| res.on("end",(e)=>{ rv.rez=Buffer.concat(rd); cbf&&cb(rv.rez, ri); }); | |
| }); | |
| req.on('error', (e) => { | |
| console.error(e); cbf&&cb(null,null,e); | |
| }); | |
| req.setHeader("User-Agent",self.fakeFox); | |
| req.end(); | |
| }; //end of getHttpsUrl | |
| self.aaay=function Array_ext(s){ | |
| s=s.substr(s.indexOf("[")); | |
| var b=0,e=-1, L=9000; | |
| do{ b=s.indexOf("[",b+1); e=s.indexOf("]",e+1); }while(b<e&&L--); | |
| return s.substr(0,e+1); | |
| }; | |
| self.get_s_trac=function getStrac(s_trac){ | |
| curl(s_trac,(dat,r_i)=>{ | |
| let sdata=dat.toString("binary"), | |
| tri=sdata.indexOf('"transcodings":'), //check quantity with sdata.split('"transcodings":') //??? | |
| abg=sdata.indexOf("[",tri), | |
| abd=sdata.substr(abg); abd.substr(0,5); | |
| let rzz=aaay(abd), | |
| rza=rzz.split('url'); //semi on PURPOSE | |
| if(tri==-1||rza.length==1) return console.error("Falure @ start of API extract sequence"); | |
| i=1,L=rza.length,c=false; | |
| while(i<L){ c=rza[i]; if(c.indexOf('"mp3')!=-1&&c.indexOf("progre")!=-1) break; else c=false; i++; }; | |
| //can replace "mp3 with "opus but progre isn't available so it has to be hls, my recommended method is load the hls/m3u8 list with curl function and grab the LAST audio segment from the list and replace the start-byte-index in the url with 0 to get a progressive stream that MIGHT work. | |
| let ub,url=c.substring(ub=c.indexOf("http"),c.indexOf('"',ub)); | |
| let dunLy=function(urg){ //might need to re-request this if at_last_real_mp3_url expires | |
| console.log("Mp3 url: "+(self.at_last_real_mp3_url=JSON.parse(urg.toString("binary")).url)); | |
| //use (child_process) exec_.spawn('ffplay "'+self.at_last_real_mp3_url+'"',(proc)=>{ /*proccess handler including closer, implement play/pause and seeking if possible to emulate js Audio object but not entire HTML element*/ }); | |
| }; | |
| if(self._snd_cid){ | |
| curl(url+"?client_id="+_snd_cid, dunLy); | |
| }else{ | |
| let scrip=sdata.split("<script "),slst=[]; | |
| i=1,L=scrip.length,c=false,b=8,jsurl=false; | |
| while(i<L){ | |
| c=scrip[i]; c=c.substr(0,c.indexOf('>')); | |
| if(b=c.indexOf('src=')){ jsurl=c.substring(c.indexOf('"',b)+1,c.indexOf('"',b+8)); if(jsurl.indexOf('ets/0')!=-1) break; } | |
| i++; | |
| }; | |
| curl(jsurl,(jd2)=>{ let js=jd2.toString("binary"),b=js.indexOf('client_id:"'),a=js.indexOf('"',b+14); | |
| self._snd_cid=js.substring(js.indexOf('"',b)+1,a); | |
| cL=self._snd_cid.length; | |
| if((!cL)||cL<12||cL>48) return console.error("With client_id extractor we have problem"); | |
| curl(url+"?client_id="+_snd_cid, dunLy); // (invent way to linierize this callstack mess please) | |
| }); //end inner 1 curl call | |
| } | |
| }); //end curl call | |
| };// end get_s_trac main run function | |
| //input desired soundcloud track here into this curl function | |
| self.get_s_trac("https://soundcloud.com/while_false/wires"); | |
| //awesome banger of a track | |
| ///search/sets?q= for playlists | |
| // get_s_trac("https://soundcloud.com/krosia/rivage-1"); | |
| //get_s_trac("https://soundcloud.com/alison_synths/lightyears-1"); | |
| //use to find more tracks scj+tracs("artist name track name"); | |
| self.sch_tracs=function(tn){ | |
| curl("https://soundcloud.com/search/sounds?q="+encodeURI(tn),(dat)=>{ let sdat=dat.toString('binary'); | |
| self.search_rez_list=sdat.substring(b=sdat.indexOf('>Search '),sdat.indexOf('</noscript>',b)).split('<a href=').slice(4); | |
| console.log("got search results qty "+self.search_rez_list.length); | |
| }); | |
| }; //end sch_tracs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment