discord-player-youtubei
Advanced tools
Comparing version 1.3.4 to 1.3.5
@@ -1,2 +0,2 @@ | ||
import { Track, BaseExtractor, ExtractorStreamable, SearchQueryType, ExtractorSearchContext, ExtractorInfo, Playlist, GuildQueueHistory } from 'discord-player'; | ||
import { SearchQueryType, Track, BaseExtractor, ExtractorStreamable, ExtractorSearchContext, ExtractorInfo, Playlist, GuildQueueHistory } from 'discord-player'; | ||
import Innertube, { OAuth2Tokens } from 'youtubei.js'; | ||
@@ -28,2 +28,5 @@ import { InnerTubeClient, DownloadOptions, InnerTubeConfig, FormatOptions } from 'youtubei.js/dist/src/types'; | ||
}; | ||
type QueryBridgeModes = Partial<Record<SearchQueryType, "yt" | "ytmusic">> & { | ||
default?: "yt" | "ytmusic"; | ||
}; | ||
interface YoutubeiOptions { | ||
@@ -35,3 +38,3 @@ authentication?: string; | ||
streamOptions?: StreamOptions; | ||
overrideBridgeMode?: "ytmusic" | "yt"; | ||
overrideBridgeMode?: "ytmusic" | "yt" | QueryBridgeModes; | ||
disablePlayer?: boolean; | ||
@@ -185,6 +188,4 @@ ignoreSignInErrors?: boolean; | ||
declare function poTokenExtraction(innertube: Innertube): Promise<PoTokenResult>; | ||
declare function generateOauthTokens(): Promise<void>; | ||
export { type AsyncTrackingContext, ChatMessageType, Errors, type If, LiveChatEvents, type RefreshInnertubeOptions, type StreamOptions, type TrustedTokenConfig, YoutubeiExtractor, type YoutubeiOptions, generateOauthTokens, getLiveChat, getYoutubeiInstance, objectToToken, poTokenExtraction, stream, tokenToObject, validateURL }; | ||
export { type AsyncTrackingContext, ChatMessageType, Errors, type If, LiveChatEvents, type QueryBridgeModes, type RefreshInnertubeOptions, type StreamOptions, type TrustedTokenConfig, YoutubeiExtractor, type YoutubeiOptions, generateOauthTokens, getLiveChat, getYoutubeiInstance, objectToToken, stream, tokenToObject, validateURL }; |
@@ -41,3 +41,2 @@ "use strict"; | ||
objectToToken: () => objectToToken, | ||
poTokenExtraction: () => poTokenExtraction, | ||
stream: () => stream, | ||
@@ -339,4 +338,10 @@ tokenToObject: () => tokenToObject, | ||
if (this.options.overrideBridgeMode) { | ||
protocol = this.options.overrideBridgeMode; | ||
} else { | ||
if (typeof this.options.overrideBridgeMode === "string") { | ||
protocol = this.options.overrideBridgeMode; | ||
} else if (track.queryType) { | ||
const opts = this.options.overrideBridgeMode; | ||
protocol = opts[track.queryType] ?? opts.default; | ||
} | ||
} | ||
if (!protocol) { | ||
if (this.innerTube.session.logged_in) protocol = "ytmusic"; | ||
@@ -361,9 +366,7 @@ else protocol = "yt"; | ||
); | ||
const stream2 = await this.bridgeFromYT(query, track); | ||
return stream2; | ||
return await this.bridgeFromYT(query, track); | ||
} | ||
} | ||
default: { | ||
const stream2 = await this.bridgeFromYT(query, track); | ||
return stream2; | ||
return await this.bridgeFromYT(query, track); | ||
} | ||
@@ -853,36 +856,2 @@ } | ||
// lib/experimental/PoToken.ts | ||
var import_bgutils_js = require("bgutils-js"); | ||
var import_happy_dom = require("happy-dom"); | ||
var HARD_CODED_REQ_KEY = "O43z0dpjhgX20SCx4KAo"; | ||
async function poTokenExtraction(innertube) { | ||
const visitorData = innertube.session.context.client.visitorData; | ||
if (!visitorData) | ||
throw new Error("Innertube instance does not contain visitor data"); | ||
const window = new import_happy_dom.Window(); | ||
Object.assign(globalThis, { | ||
document: window.document, | ||
window | ||
}); | ||
const bgConfig = { | ||
// excuse my variable naming | ||
fetch: (i, a) => fetch(i, a), | ||
globalObj: globalThis, | ||
identifier: visitorData, | ||
requestKey: HARD_CODED_REQ_KEY | ||
}; | ||
const challenge = await import_bgutils_js.BG.Challenge.create(bgConfig); | ||
if (!challenge) | ||
throw new Error("Unable to retrieve challenge data from botguard"); | ||
const jsInter = challenge.interpreterJavascript.privateDoNotAccessOrElseSafeScriptWrappedValue; | ||
if (jsInter) { | ||
new Function(jsInter)(); | ||
} else throw new Error("Unable to load botguard's VM"); | ||
return import_bgutils_js.BG.PoToken.generate({ | ||
bgConfig, | ||
program: challenge.program, | ||
globalName: challenge.globalName | ||
}); | ||
} | ||
// lib/index.ts | ||
@@ -928,3 +897,2 @@ var exit = (message, clean) => { | ||
objectToToken, | ||
poTokenExtraction, | ||
stream, | ||
@@ -931,0 +899,0 @@ tokenToObject, |
{ | ||
"name": "discord-player-youtubei", | ||
"version": "1.3.4", | ||
"version": "1.3.5", | ||
"description": "An unofficial package to test the use of youtubei in discord-player v6.", | ||
@@ -15,4 +15,6 @@ "main": "dist/index.js", | ||
"@types/node": "^22.7.5", | ||
"bgutils-js": "^3.1.0", | ||
"discord-player": "^6.7.1", | ||
"discord.js": "^14.16.3", | ||
"happy-dom": "^15.7.4", | ||
"prettier": "^3.3.3", | ||
@@ -23,4 +25,2 @@ "tsup": "^8.2.4", | ||
"dependencies": { | ||
"bgutils-js": "^3.1.0", | ||
"happy-dom": "^15.7.4", | ||
"tiny-typed-emitter": "^2.1.0", | ||
@@ -31,3 +31,3 @@ "undici": "^6.20.0", | ||
"scripts": { | ||
"build": "tsup", | ||
"build": "npm run format && tsup", | ||
"prepare": "npm run build", | ||
@@ -37,3 +37,7 @@ "format": "prettier --write \"{lib,examples,bin}/**/*.{js,ts}\"" | ||
"bin": "bin/index.js", | ||
"packageManager": "yarn@4.3.1" | ||
"packageManager": "yarn@4.3.1", | ||
"exports": { | ||
".": "./dist/index.js", | ||
"./experimental": "./dist/experimental/index.js" | ||
} | ||
} |
55320
3
8
1131
9
- Removedbgutils-js@^3.1.0
- Removedhappy-dom@^15.7.4
- Removedbgutils-js@3.1.3(transitive)
- Removedentities@4.5.0(transitive)
- Removedhappy-dom@15.11.7(transitive)
- Removedwebidl-conversions@7.0.0(transitive)
- Removedwhatwg-mimetype@3.0.0(transitive)