Open ybd-project-ver1 opened 6 days ago
@ybd-project-ver1 Can I use this in a userscript without the need for a proxy, if a proxy is absolutely needed will the links generated by this tied to proxy IP or browser IP ?
@ybd-project-ver1 Can I use this in a userscript without the need for a proxy, if a proxy is absolutely needed will the links generated by this tied to proxy IP or browser IP ?
Whether a proxy is needed or not depends on whether CORS can be bypassed; if CORS can be bypassed, it is not needed. If a proxy is required, the IP is difficult to forge.
Thanks for clarifying, can you pls. share what is the best innertube client as of now to get pre-muxed 360p link and audio only streams and does it require signature decoding and poToken to avoid HTTP403 ?
Thanks for clarifying, can you pls. share what is the best innertube client as of now to get pre-muxed 360p link and audio only streams and does it require signature decoding and poToken to avoid HTTP403 ?
There are ways to avoid 403s, such as making requests from the same IP or using a proxy. (not always effective) The iOS clients and web clients are currently the most stable clients for retrieving 360p (itag: 18) videos.
Thank you, but I believe my question was unclear. I wanted to ask if, when accessing valid downloadable streams from the WEB
or iOS
clients, do we need to decrypt the signature or supply the poToken or both?
In my userscript, I am directly accessing the Innertube API, but the iOS links are returning a 403 error when I try to download them. To clarify, these are raw links extracted by my script not from the library. My main question is: Do we need to use the poToken, decrypt the signature, or both to make the links work?
ytdl-core parses URLs as follows
function setDownloadURL(format: YT_StreamingAdaptiveFormat, decipherFunction: string | null, nTransformFunction: string | null) {
if (!decipherFunction) {
return;
}
const decipher = (url: string): string => {
const SEARCH_PARAMS = new URLSearchParams('?' + url),
PARAMS_URL = SEARCH_PARAMS.get('url')?.toString() || '',
PARAMS_S = SEARCH_PARAMS.get('s');
if (!PARAMS_S) {
return PARAMS_URL;
}
try {
const COMPONENTS = new URL(decodeURIComponent(PARAMS_URL)),
CONTEXT: Record<string, string> = {};
CONTEXT[DECIPHER_ARGUMENT] = decodeURIComponent(PARAMS_S);
COMPONENTS.searchParams.set(SEARCH_PARAMS.get('sp')?.toString() || 'sig', runInNewContext(decipherFunction, CONTEXT));
return COMPONENTS.toString();
} catch (err) {
Logger.debug(`[ Decipher ]: <error>Failed</error> to decipher URL: <error>${err}</error>`);
return PARAMS_URL;
}
},
nTransform = (url: string): string => {
const COMPONENTS = new URL(decodeURIComponent(url)),
N = COMPONENTS.searchParams.get('n');
if (!N || !nTransformFunction) {
return url;
}
const CONTEXT: Record<string, string> = {};
CONTEXT[N_ARGUMENT] = N;
COMPONENTS.searchParams.set('n', runInNewContext(nTransformFunction, CONTEXT));
return COMPONENTS.toString();
},
CIPHER = !format.url,
VIDEO_URL = format.url || format.signatureCipher || format.cipher;
if (!VIDEO_URL) {
return;
}
format.url = nTransform(CIPHER ? decipher(VIDEO_URL) : VIDEO_URL);
delete format.signatureCipher;
delete format.cipher;
}
@ybd-project-ver1 Amazing, thanks for the help :)
Description
We are currently planning to release v6.0.5 with the following specification changes. Are there any features or requests that you would like to see added?
v6.0.5
Features
decipherFormat
to YtdlCore instances.createOAuth2Credentials
to YtdlCore instances.Change
['web', 'webCreator', 'tvEmbedded', 'ios', 'android']
to['web', 'mweb', 'tv', 'ios']
.Abolition
streamType
option is obsolete and can be converted by importing thetoPipeableStream
function instead. (Default or Serverless version only)/ Or /
import { YtdlCore, toPipeableStream } from '@ybd-project/ytdl-core/serverless';