Skip to content

Commit

Permalink
feat: add "WEB" client to default player option
Browse files Browse the repository at this point in the history
  • Loading branch information
skick1234 committed Dec 17, 2024
1 parent 3077709 commit 4dff8bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions lib/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ exports.getInfo = async (id, options) => {
const html5player = new URL(info.html5player, BASE_URL).toString();

try {
if (options.playerClients.includes("WEB")) {
funcs.push(sig.decipherFormats(parseFormats(info.player_response), html5player, options));
funcs.push(...parseAdditionalManifests(info.player_response));
}
if (info.videoDetails.age_restricted) throw Error("Cannot download age restricted videos with mobile clients");
const promises = [];
if (options.playerClients.includes("WEB_CREATOR")) promises.push(fetchWebCreatorPlayer(id, html5player, options));
Expand All @@ -270,15 +274,7 @@ exports.getInfo = async (id, options) => {
funcs.push(...parseAdditionalManifests(resp.value, options));
}
}

if (options.playerClients.includes("WEB")) {
funcs.push(sig.decipherFormats(parseFormats(info.player_response), html5player, options));
funcs.push(...parseAdditionalManifests(info.player_response));
}
} catch (_) {
funcs.push(sig.decipherFormats(parseFormats(info.player_response), html5player, options));
funcs.push(...parseAdditionalManifests(info.player_response));
}
} catch (_) {}

let results = await Promise.all(funcs);
info.formats = Object.values(Object.assign({}, ...results));
Expand Down Expand Up @@ -307,7 +303,7 @@ const LOCALE = { hl: "en", timeZone: "UTC", utcOffsetMinutes: 0 },
const WEB_CREATOR_CONTEXT = {
client: {
clientName: "WEB_CREATOR",
clientVersion: "1.20241023.00.01",
clientVersion: "1.20241215.03.00",
...LOCALE,
},
};
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,6 @@ exports.generateClientPlaybackNonce = length => {

exports.applyPlayerClients = options => {
if (!options.playerClients || options.playerClients.length === 0) {
options.playerClients = ["WEB_CREATOR", "IOS"];
options.playerClients = ["WEB", "WEB_CREATOR", "IOS"];
}
};

0 comments on commit 4dff8bc

Please sign in to comment.