Skip to content

Commit

Permalink
403
Browse files Browse the repository at this point in the history
  • Loading branch information
khaouitiabdelhakim committed Jun 24, 2024
1 parent a1cb6e5 commit a1fd20d
Show file tree
Hide file tree
Showing 8 changed files with 173,620 additions and 12 deletions.
9 changes: 4 additions & 5 deletions axioso.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

// Set logging mode
let LOGGING = false;
let LOGGING = true;
const axios = require("axios");
// Map of YouTube format codes to format details
const FORMAT_MAP = {
Expand Down Expand Up @@ -50,12 +50,11 @@ let decipherFunctionName = null;

// User agent string for HTTP requests
const USER_AGENT =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36";
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";

// Create an Axios instance with the User-Agent header
const axiosInstance = axios.create({
headers: {
"User-Agent": USER_AGENT,
"User-Agent": USER_AGENT
},
});

Expand Down Expand Up @@ -195,7 +194,7 @@ async function testHttp403Code(url) {
return true;
}
} catch (error) {
if (LOGGING) console.error('An error occurred:', error);
if (LOGGING) console.error("An error occurred:", error);
}
return false;
}
Expand Down
39 changes: 39 additions & 0 deletions decode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var BPa = function (a) {
a = a.split("");
LO.HI(a, 2);
LO.kf(a, 56);
LO.HI(a, 3);
LO.Gl(a, 10);
LO.HI(a, 2);
LO.Gl(a, 41);
LO.Gl(a, 37);
return a.join("");
};
var LO = {
Gl: function (a, b) {
var c = a[0];
a[0] = a[b % a.length];
a[b % a.length] = c;
},
kf: function (a) {
a.reverse();
},
HI: function (a, b) {
a.splice(0, b);
},
};

const patSigEncUrl = /url=(.+?)(\u0026|$)/;
const patSignature = /s=(.+?)(\u0026|$)/;

urlo = `s=%3Dg%3Dg5aNic06Y4EQywoc3FBV69QuljZ9xSMFObXzWm_qJH1AEiAji8xb4sUq5teTkO3niA-_gC12aA4xLXGZKLcY3NyHVNAhIgqwsSdQfJqJRqJR&sp=sig&url=https://rr5---sn-f5o5-jhoz.googlevideo.com/videoplayback%3Fexpire%3D1719268770%26ei%3DQqF5ZquWK_e4p-oPp_mzmA0%26ip%3D105.73.96.62%26id%3Do-AOYAmb4-l3DpBCLj8PxevWSKEAORHZcJheXzqR2TALBi%26itag%3D251%26source%3Dyoutube%26requiressl%3Dyes%26xpc%3DEgVo2aDSNQ%253D%253D%26mh%3Dlu%26mm%3D31%252C29%26mn%3Dsn-f5o5-jhoz%252Csn-h5qzened%26ms%3Dau%252Crdu%26mv%3Dm%26mvi%3D5%26pl%3D25%26initcwndbps%3D580000%26bui%3DAbKP-1MoUnBIyQL87WHC05UmLxS9U4sAlIPuSI6lAqQj7vgJuDQhUBk9sbdSVwohlr6rNVGNSxHSPtSt%26spc%3DUWF9f7UPZ9uweVHIe4tuPRGX6v-Hk8kUEtJPzmDfI-eV0RGooQ%26vprv%3D1%26svpuc%3D1%26mime%3Daudio%252Fwebm%26ns%3Dka9lDisc9dxDnP6yX38Qhp0Q%26rqh%3D1%26gir%3Dyes%26clen%3D4414846%26dur%3D260.321%26lmt%3D1714877283035474%26mt%3D1719246782%26fvip%3D4%26keepalive%3Dyes%26c%3DWEB_REMIX%26sefc%3D1%26txp%3D4502434%26n%3DMS3zR3E9l2I4N7wT9U%26sparams%3Dexpire%252Cei%252Cip%252Cid%252Citag%252Csource%252Crequiressl%252Cxpc%252Cbui%252Cspc%252Cvprv%252Csvpuc%252Cmime%252Cns%252Crqh%252Cgir%252Cclen%252Cdur%252Clmt%26lsparams%3Dmh%252Cmm%252Cmn%252Cms%252Cmv%252Cmvi%252Cpl%252Cinitcwndbps%26lsig%3DAHlkHjAwRgIhAMua7Ghhsro_6M2__PONQwgtLZRrwvHpNKdDHs1SqnxTAiEAxfbjfiDknd60u401z0mPxeYwidSIgqtzoMNGKapq5P4%253D`


const mat = patSigEncUrl.exec(urlo);
const matSig = patSignature.exec(urlo);
if (mat && matSig) {
let url = decodeURIComponent(mat[1]);
const signature = decodeURIComponent(matSig[1]);
url += `&sig=${BPa(signature)}`;
console.log(url);
}
32,984 changes: 32,984 additions & 0 deletions index.html

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

// Set logging mode
let LOGGING = false;
let LOGGING = true;

// Map of YouTube format codes to format details
const FORMAT_MAP = {
Expand Down Expand Up @@ -125,6 +125,8 @@ async function exract(videoID) {
}

const signature = decipheredSignature;
console.log("signature: ",signature);

if (!signature) {
if (LOGGING) console.error("Could not decipher signature");
return null;
Expand Down Expand Up @@ -174,6 +176,9 @@ function parseFormats(
if (mat && matSig) {
const url = decodeURIComponent(mat[1]);
const signature = decodeURIComponent(matSig[1]);
console.log(`${url}&sig=${signature}`)
console.log("signature: ",signature);

file.type = FORMAT_MAP[itag];
file.url = url;
if (LOGGING) console.log(`file: ${file.url}`);
Expand Down Expand Up @@ -370,7 +375,7 @@ async function getStreamUrl(videoID) {
const file = await exract(videoID);
if (file) {
if (testHttp403Code(file.url)) {
if (LOGGING) console.log("file:", file);
if (LOGGING) console.log("file:", file);
ok = true;
return file;
}
Expand All @@ -382,7 +387,15 @@ async function getStreamUrl(videoID) {
} catch (error) {
if (LOGGING) console.error("An error occurred:", error);
}
return null;
return null;
}

module.exports = getStreamUrl;

const videoID = "JlyqnRaihSI";

// Main execution block
(async () => {
const file = await exract(videoID);
console.log(file);
})();
140,569 changes: 140,569 additions & 0 deletions labs.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,13 @@ async function getStreamUrls(videoID) {
let i = 0;
for (let key of encSignatures.keys()) {
let url = file.url;
console.log(`url: ${url}`);
url += `&sig=${sigs[i]}`;
file.type = FORMAT_MAP[key];
file.url = url;
console.log(`file: ${sigs[i]}`);
i++;
c
}
}
}
Expand Down Expand Up @@ -162,6 +165,7 @@ function parseFormats(
if (mat && matSig) {
const url = decodeURIComponent(mat[1]);
const signature = decodeURIComponent(matSig[1]);
console.log(`sign: ${signature}`);
file.type = FORMAT_MAP[itag];
file.url = url;
if(LOGGING) console.log(`file: ${file.url}`);
Expand Down Expand Up @@ -347,7 +351,7 @@ async function decipherSignature(encSignatures) {
return true;
}

const videoID = "rMHx_iUAGd0";
const videoID = "tZLDEUFtnX0";

(async () => {
let ok = false;
Expand Down
2 changes: 1 addition & 1 deletion try.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ async function decipherSignature(encSignatures) {
return true;
}

const videoID = "Kr8w28_SfJo";
const videoID = "tZLDEUFtnX0";
const LOG_TAG = true;

(async () => {
Expand Down
4 changes: 2 additions & 2 deletions use.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// use.js
const getStreamUrl = require("./axioso");
const getStreamUrl = require("./index");

// Video ID for testing
const videoID = "3TYwrnJCBdg";
const videoID = "cIvfeuLq7eM";

// Main execution block
(async () => {
Expand Down

0 comments on commit a1fd20d

Please sign in to comment.