api/youtube: use custom innertube client env & decipher for more clients

This commit is contained in:
wukko 2025-03-14 08:54:42 +06:00
parent e10fad3d4e
commit d2d098dbfb
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -41,6 +41,8 @@ const hlsCodecList = {
} }
} }
const clientsWithNoCipher = ['IOS', 'ANDROID', 'YTSTUDIO_ANDROID', 'YTMUSIC_ANDROID'];
const videoQualities = [144, 240, 360, 480, 720, 1080, 1440, 2160, 4320]; const videoQualities = [144, 240, 360, 480, 720, 1080, 1440, 2160, 4320];
const transformSessionData = (cookie) => { const transformSessionData = (cookie) => {
@ -149,7 +151,7 @@ export default async function (o) {
useHLS = false; useHLS = false;
} }
let innertubeClient = o.innertubeClient || "ANDROID"; let innertubeClient = o.innertubeClient || env.customInnertubeClient || "ANDROID";
if (cookie) { if (cookie) {
useHLS = false; useHLS = false;
@ -478,7 +480,7 @@ export default async function (o) {
urls = audio.uri; urls = audio.uri;
} }
if (innertubeClient === "WEB" && innertube) { if (!clientsWithNoCipher.includes(innertubeClient) && innertube) {
urls = audio.decipher(innertube.session.player); urls = audio.decipher(innertube.session.player);
} }
@ -513,7 +515,7 @@ export default async function (o) {
filenameAttributes.resolution = `${video.width}x${video.height}`; filenameAttributes.resolution = `${video.width}x${video.height}`;
filenameAttributes.extension = codecList[codec].container; filenameAttributes.extension = codecList[codec].container;
if (innertubeClient === "WEB" && innertube) { if (!clientsWithNoCipher.includes(innertubeClient) && innertube) {
video = video.decipher(innertube.session.player); video = video.decipher(innertube.session.player);
audio = audio.decipher(innertube.session.player); audio = audio.decipher(innertube.session.player);
} else { } else {