func stream_yt_json(id) { ret "{\"videoId\": \""+ id + "\",\"context\": {\"client\": {\"clientName\": \"ANDROID\",\"clientVersion\": \"17.10.35\",\"androidSdkVersion\": 30,\"hl\": \"en\",\"gl\": \"US\",\"utcOffsetMinutes\": 0}}}"; } func tytd_streams_get(id) { streams = create.dict(); streams.success = false; str = stream_yt_json(id); curl = net.curl(); curl.method = "POST"; //curl.url = "http://127.0.0.1:9999/"; curl.url = "https://www.youtube.com/youtubei/v1/player?key=AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w"; jsonStr=""; curl.followlocation = true; headers = create.array(); headers.add("Connection: close"); headers.add("Content-Type: application/json"); headers.add("User-Agent: com.google.android.youtube/17.10.35 (Linux; U; Android 12; GB) gzip"); headers.add("Cookie: CONSENT=YES+cb; YSC=DwKYllHNwuw"); curl.requestheaders = headers; curl.postfields = str; console.writeln(str); curl.writefunction = func(buffer,length) { for(i = 0;i",false,2); a2 = a[1]; a3 = a2.split("",false,2); ret a3[0]; } ret "Unknown"; } func download_video(id) { title = tytd_title(id); console.writeln("Downloading: " + title); strms=tytd_streams_get(id); if(strms.success && strms.data) { each(strms.data.streamingData.formats) { if(item.itag == 22) { fileName = title + "-" + id + ".mp4"; curl = net.curl(); curl.url = item.url; f = fs.create(fileName); curl.writefunction = f.write; curl.perform(); f.close(); console.writeln("Downloaded: " + title); } } } } func main($$args) { each(args) { download_video(item); } }