Clean up unneeded export, variables and assignment after reverse()

This commit is contained in:
absidue 2021-11-04 19:05:02 +01:00
parent 4c8162ecdd
commit 28b429f5ed
3 changed files with 7 additions and 11 deletions

View File

@ -207,7 +207,7 @@ export class Stream {
this.stream.push(c); this.stream.push(c);
}); });
stream.once('error', async (err) => { stream.once('error', async () => {
this.cleanup(); this.cleanup();
await this.retry(); await this.retry();
this.timer.reuse(); this.timer.reuse();

View File

@ -42,7 +42,7 @@ const swap_regexp = new RegExp(`(?:^|,)(${key_js})${swap_function}`, 'm');
* @param body body data of html5player. * @param body body data of html5player.
* @returns Array of tokens. * @returns Array of tokens.
*/ */
export function js_tokens(body: string) { function js_tokens(body: string) {
const function_action = function_regexp.exec(body); const function_action = function_regexp.exec(body);
const object_action = obj_regexp.exec(body); const object_action = obj_regexp.exec(body);
if (!function_action || !object_action) return null; if (!function_action || !object_action) return null;
@ -104,7 +104,7 @@ function deciper_signature(tokens: string[], signature: string) {
sig = swappositions(sig, pos); sig = swappositions(sig, pos);
break; break;
case 'rv': case 'rv':
sig = sig.reverse(); sig.reverse();
break; break;
case 'sl': case 'sl':
pos = parseInt(token.slice(2)); pos = parseInt(token.slice(2));
@ -137,11 +137,9 @@ function swappositions(array: string[], position: number) {
* @returns void * @returns void
*/ */
function download_url(format: formatOptions, sig: string) { function download_url(format: formatOptions, sig: string) {
let decoded_url;
if (!format.url) return; if (!format.url) return;
decoded_url = format.url;
decoded_url = decodeURIComponent(decoded_url); const decoded_url = decodeURIComponent(format.url);
const parsed_url = new URL(decoded_url); const parsed_url = new URL(decoded_url);
parsed_url.searchParams.set('ratebypass', 'yes'); parsed_url.searchParams.set('ratebypass', 'yes');
@ -168,9 +166,8 @@ export async function format_decipher(formats: formatOptions[], html5player: str
delete format.signatureCipher; delete format.signatureCipher;
delete format.cipher; delete format.cipher;
} }
let sig;
if (tokens && format.s) { if (tokens && format.s) {
sig = deciper_signature(tokens, format.s); const sig = deciper_signature(tokens, format.s);
download_url(format, sig); download_url(format, sig);
delete format.s; delete format.s;
delete format.sp; delete format.sp;

View File

@ -375,7 +375,6 @@ function parseDuration(duration: string): number {
* @returns token * @returns token
*/ */
export function getContinuationToken(data: any): string { export function getContinuationToken(data: any): string {
const continuationToken = data.find((x: any) => Object.keys(x)[0] === 'continuationItemRenderer') return data.find((x: any) => Object.keys(x)[0] === 'continuationItemRenderer')?.continuationItemRenderer
?.continuationItemRenderer.continuationEndpoint?.continuationCommand?.token; .continuationEndpoint?.continuationCommand?.token;
return continuationToken;
} }