match: add freebind support for youtube and instagram

This commit is contained in:
dumbmoron 2024-05-12 16:12:45 +00:00
parent 0114e686b8
commit c306a944d9
No known key found for this signature in database
2 changed files with 19 additions and 2 deletions

View file

@ -41,5 +41,8 @@
"undici": "^6.7.0", "undici": "^6.7.0",
"url-pattern": "1.0.3", "url-pattern": "1.0.3",
"youtubei.js": "^9.3.0" "youtubei.js": "^9.3.0"
},
"optionalDependencies": {
"freebind": "^0.2.2"
} }
} }

View file

@ -25,9 +25,21 @@ import streamable from "./services/streamable.js";
import twitch from "./services/twitch.js"; import twitch from "./services/twitch.js";
import rutube from "./services/rutube.js"; import rutube from "./services/rutube.js";
import dailymotion from "./services/dailymotion.js"; import dailymotion from "./services/dailymotion.js";
import { env } from '../config.js';
let freebind;
export default async function(host, patternMatch, url, lang, obj) { export default async function(host, patternMatch, url, lang, obj) {
assert(url instanceof URL); assert(url instanceof URL);
let dispatcher, requestIP;
if (env.freebindCIDR) {
if (!freebind) {
freebind = await import('freebind');
}
requestIP = freebind.ip.random(env.freebindCIDR);
dispatcher = freebind.dispatcherFromIP(requestIP, { strict: false });
}
try { try {
let r, isAudioOnly = !!obj.isAudioOnly, disableMetadata = !!obj.disableMetadata; let r, isAudioOnly = !!obj.isAudioOnly, disableMetadata = !!obj.disableMetadata;
@ -66,7 +78,8 @@ export default async function(host, patternMatch, url, lang, obj) {
format: obj.vCodec, format: obj.vCodec,
isAudioOnly: isAudioOnly, isAudioOnly: isAudioOnly,
isAudioMuted: obj.isAudioMuted, isAudioMuted: obj.isAudioMuted,
dubLang: obj.dubLang dubLang: obj.dubLang,
dispatcher
} }
if (url.hostname === 'music.youtube.com' || isAudioOnly === true) { if (url.hostname === 'music.youtube.com' || isAudioOnly === true) {
@ -122,7 +135,8 @@ export default async function(host, patternMatch, url, lang, obj) {
case "instagram": case "instagram":
r = await instagram({ r = await instagram({
...patternMatch, ...patternMatch,
quality: obj.vQuality quality: obj.vQuality,
dispatcher
}) })
break; break;
case "vine": case "vine":