youtube-ext
Advanced tools
Comparing version 1.1.21 to 1.1.22
@@ -7,9 +7,7 @@ export declare class CookieJar { | ||
static stringifyCookieMap(cookies: Record<string, string>): string; | ||
static parseCookieString(cookie: string, options?: { | ||
ignoredKeys?: string[]; | ||
cookieMap?: Record<string, string>; | ||
}): Record<string, string>; | ||
static setCookieIgnoredKeys: string[]; | ||
static parseCookieString(cookie: string, cookieMap?: Record<string, string>): Record<string, string>; | ||
static parseSetCookie(cookies: string | string[], cookieMap?: Record<string, string>): Record<string, string>; | ||
static ignoredCookieKeys: string[]; | ||
static shouldIgnoreCookie(key: string, value: string): boolean; | ||
} | ||
export declare const cookieJar: CookieJar; |
@@ -28,9 +28,6 @@ "use strict"; | ||
} | ||
static parseCookieString(cookie, options) { | ||
var _a; | ||
const cookieMap = (_a = options === null || options === void 0 ? void 0 : options.cookieMap) !== null && _a !== void 0 ? _a : {}; | ||
static parseCookieString(cookie, cookieMap = {}) { | ||
return cookie.split(";").reduce((pv, cv) => { | ||
var _a; | ||
const [k, v] = cv.trim().split("="); | ||
if (!k || !v || ((_a = options === null || options === void 0 ? void 0 : options.ignoredKeys) === null || _a === void 0 ? void 0 : _a.includes(k.toLowerCase()))) { | ||
if (!k || !v || CookieJar.shouldIgnoreCookie(k, v)) { | ||
return pv; | ||
@@ -45,17 +42,16 @@ } | ||
for (const x of cookies) { | ||
CookieJar.parseCookieString(x, { | ||
ignoredKeys: CookieJar.setCookieIgnoredKeys, | ||
cookieMap, | ||
}); | ||
CookieJar.parseCookieString(x, cookieMap); | ||
} | ||
return cookieMap; | ||
} | ||
return CookieJar.parseCookieString(cookies, { | ||
ignoredKeys: CookieJar.setCookieIgnoredKeys, | ||
cookieMap, | ||
}); | ||
return CookieJar.parseCookieString(cookies, cookieMap); | ||
} | ||
static shouldIgnoreCookie(key, value) { | ||
return (value === "EXPIRED" || | ||
key.startsWith("__Secure-") || | ||
CookieJar.ignoredCookieKeys.includes(key.toLowerCase())); | ||
} | ||
} | ||
exports.CookieJar = CookieJar; | ||
CookieJar.setCookieIgnoredKeys = [ | ||
CookieJar.ignoredCookieKeys = [ | ||
"expires", | ||
@@ -70,3 +66,4 @@ "max-age", | ||
"priority", | ||
"login_info", | ||
]; | ||
exports.cookieJar = new CookieJar(); |
{ | ||
"name": "youtube-ext", | ||
"version": "1.1.21", | ||
"version": "1.1.22", | ||
"description": "A simple YouTube scraper and downloader.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
86111
1626