Update src/libpoketube/libpoketube-core.js
This commit is contained in:
parent
258130fbea
commit
e66b20b25c
@ -6,7 +6,6 @@
|
|||||||
* Please don't remove this comment while sharing this code.
|
* Please don't remove this comment while sharing this code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { toJson } = require("xml2json");
|
|
||||||
const { curly } = require("node-libcurl");
|
const { curly } = require("node-libcurl");
|
||||||
const getdislikes = require("../libpoketube/libpoketube-dislikes.js");
|
const getdislikes = require("../libpoketube/libpoketube-dislikes.js");
|
||||||
const getColors = require("get-image-colors");
|
const getColors = require("get-image-colors");
|
||||||
@ -231,26 +230,6 @@ class InnerTubePokeVidious {
|
|||||||
return ["#0ea5e9", "#111827"];
|
return ["#0ea5e9", "#111827"];
|
||||||
}
|
}
|
||||||
|
|
||||||
async curlGetWithRetry(url, httpHeader, outerSignal) {
|
|
||||||
let lastErr = null;
|
|
||||||
for (let i = 0; i <= 4; i++) {
|
|
||||||
if (outerSignal?.aborted) throw outerSignal.reason || new Error("aborted");
|
|
||||||
try {
|
|
||||||
const res = await curly.get(url, {
|
|
||||||
httpHeader,
|
|
||||||
timeoutMs: 12000,
|
|
||||||
connectTimeoutMs: 6000,
|
|
||||||
});
|
|
||||||
const code = res?.statusCode;
|
|
||||||
if (code >= 200 && code < 300 && res?.data) return res;
|
|
||||||
if (!this.shouldRetryStatus(code)) return res;
|
|
||||||
} catch (e) { lastErr = e; }
|
|
||||||
await this.wait(this.backoff(i, 160, 8000));
|
|
||||||
}
|
|
||||||
if (lastErr) throw lastErr;
|
|
||||||
throw new Error("curlGetWithRetry failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
isvalidvideo(v) {
|
isvalidvideo(v) {
|
||||||
if (v != "assets" && v != "cdn-cgi" && v != "404") return /^([a-zA-Z0-9_-]{11})$/.test(v);
|
if (v != "assets" && v != "cdn-cgi" && v != "404") return /^([a-zA-Z0-9_-]{11})$/.test(v);
|
||||||
return false;
|
return false;
|
||||||
@ -264,7 +243,6 @@ class InnerTubePokeVidious {
|
|||||||
}
|
}
|
||||||
const cached = this.cache.get(v);
|
const cached = this.cache.get(v);
|
||||||
if (cached && Date.now() - cached.timestamp < 3600000) return cached.result;
|
if (cached && Date.now() - cached.timestamp < 3600000) return cached.result;
|
||||||
const headers = { "User-Agent": this.useragent };
|
|
||||||
const bases = [this.config.invapi, this.config.invapi_alt];
|
const bases = [this.config.invapi, this.config.invapi_alt];
|
||||||
const b64ts = Buffer.from(String(Date.now())).toString("base64");
|
const b64ts = Buffer.from(String(Date.now())).toString("base64");
|
||||||
const q = `hl=${contentlang}®ion=${contentregion}&h=${b64ts}`;
|
const q = `hl=${contentlang}®ion=${contentregion}&h=${b64ts}`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user