New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

discord-player-youtubei

Package Overview
Dependencies
Maintainers
0
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-player-youtubei - npm Package Compare versions

Comparing version 1.3.7 to 1.4.0

64

dist/index.js

@@ -216,3 +216,2 @@ "use strict";

// lib/utils/index.ts
var import_undici = require("undici");
var import_youtubei5 = require("youtubei.js");

@@ -425,12 +424,2 @@

} else {
try {
const rotator = player.routePlanner?.getIP();
if (rotator?.ip) {
const dispatch = new import_undici.Agent({
localAddress: rotator.ip
});
requestInit.dispatcher = dispatch;
}
} catch {
}
return import_youtubei5.Platform.shim.fetch(input, requestInit);

@@ -668,12 +657,53 @@ }

context.type = import_discord_player.QueryType.YOUTUBE_VIDEO;
if (context.type === import_discord_player.QueryType.YOUTUBE_PLAYLIST) {
const url = new URL(query);
if (url.searchParams.has("v") && url.searchParams.has("list"))
context.type = import_discord_player.QueryType.YOUTUBE_VIDEO;
}
switch (context.type) {
case import_discord_player.QueryType.YOUTUBE_PLAYLIST: {
let playlist;
const playlistUrl = new URL(query);
const plId = playlistUrl.searchParams.get("list");
let playlist = await this.innerTube.getPlaylist(plId);
const videoId = playlistUrl.searchParams.get("v");
if (videoId && plId) {
const endpoint = new import_youtubei6.YTNodes.NavigationEndpoint({
continuationCommand: {
videoId,
playlistId: plId
}
});
const mixVidInfo = await this.innerTube.getInfo(endpoint);
if (!mixVidInfo?.playlist)
throw new Error("Mix playlist not found or invalid");
playlist = {
info: {
title: mixVidInfo.playlist.title?.toString() ?? "UNKNOWN TITLE",
thumbnails: mixVidInfo.playlist.contents?.[0]?.thumbnail ?? [],
description: "",
author: {
name: mixVidInfo.playlist.author?.toString() ?? "UNKNOWN AUTHOR",
url: ""
}
},
channels: [
{
author: {
name: mixVidInfo.playlist.author?.toString() ?? "UNKNOWN AUTHOR",
url: ""
}
}
],
videos: mixVidInfo.playlist.contents.map((item) => ({
type: "PlaylistVideo",
id: item.video_id,
title: { text: item.title?.toString() ?? "UNKNOWN TITLE" },
duration: { seconds: item.duration?.seconds ?? 0 },
thumbnails: item.thumbnail?.map((t) => ({ url: t.url })) ?? [],
author: { name: item.author ?? "UNKNOWN AUTHOR", url: "" },
is_live: false
})),
has_continuation: false,
async getContinuation() {
throw new Error("Mixes do not support continuation");
}
};
} else {
playlist = await this.innerTube.getPlaylist(plId);
}
const pl = new import_discord_player.Playlist(this.context.player, {

@@ -680,0 +710,0 @@ title: playlist.info.title ?? "UNKNOWN PLAYLIST",

{
"name": "discord-player-youtubei",
"version": "1.3.7",
"version": "1.4.0",
"description": "An unofficial package to test the use of youtubei in discord-player v6.",

@@ -13,6 +13,6 @@ "main": "dist/index.js",

"devDependencies": {
"@discord-player/extractor": "^4.5.0",
"@discord-player/extractor": "^7.1.0",
"@types/node": "^22.7.5",
"bgutils-js": "^3.1.0",
"discord-player": "^6.7.1",
"discord-player": "^7.1.0",
"discord.js": "^14.16.3",

@@ -19,0 +19,0 @@ "googlevideo": "^2.0.0",

@@ -47,2 +47,5 @@ # Discord Player YouTubei

> [!WARNING]
> Recent developments have lead to the follow piece of code not working as intended. Please use cookies instead.
First run the following command

@@ -97,2 +100,4 @@ ```bash

| cookie | string | The cookies passed to innertube similar to ytdl cookies |
| proxy | [ProxyAgent](https://undici.nodejs.org/#/docs/api/ProxyAgent.md) | Define a proxy to route all the requests |
| peers | [PeerInfo](#peerinfo) | Stream from peers allowing to bypass some IP block |

@@ -109,18 +114,69 @@ ### TrustedTokenConfig

### PeerInfo
| name | type | description |
| ---- | ---- | ----------- |
| url | string | The base URL of the peer |
| parse | [`ParserFunction`](#parserfunction)? | Parse the URL for the peer for streaming |
### ParserFunction
RAW: `(url: string, id: string) => string`
#### Parameters
| name | index | type | description |
| ---- | ----- | ---- | ----------- |
| url | 0 | string | The base URL of the peer |
| id | 1 | string | The YouTube video ID |
#### Return
The function must return a `string` that is a URL that returns an audio stream when requested
## Raw Types
```ts
interface YoutubeiOptions {
authentication?: string;
overrideDownloadOptions?: DownloadOptions;
createStream?: (q: Track, extractor: BaseExtractor<object>) => Promise<string | Readable>;
signOutOnDeactive?: boolean;
streamOptions?: StreamOptions;
overrideBridgeMode?: "ytmusic" | "yt";
disablePlayer?: boolean;
ignoreSignInErrors?: boolean;
innertubeConfigRaw?: Omit<Omit<Omit<InnertubeConfig, "retrieve_player">, "visitor_data">, "cookie">;
trustedTokens?: TrustedTokenConfig;
cookie?: string;
export interface StreamOptions {
useClient?: InnerTubeClient;
highWaterMark?: number;
}
export interface RefreshInnertubeOptions {
filePath: string;
interval?: number;
}
export interface PeerInfo {
url: string;
parse?: (url: string, id: string) => string;
}
export type TrustedTokenConfig = {
poToken: string;
visitorData: string;
};
export type QueryBridgeModes = Partial<
Record<SearchQueryType, "yt" | "ytmusic">
> & { default?: "yt" | "ytmusic" };
export interface YoutubeiOptions {
authentication?: string;
overrideDownloadOptions?: DownloadOptions;
createStream?: (
q: Track,
extractor: YoutubeiExtractor,
) => Promise<string | Readable>;
signOutOnDeactive?: boolean;
streamOptions?: StreamOptions;
overrideBridgeMode?: "ytmusic" | "yt" | QueryBridgeModes;
disablePlayer?: boolean;
ignoreSignInErrors?: boolean;
innertubeConfigRaw?: InnerTubeConfig;
trustedTokens?: TrustedTokenConfig;
cookie?: string;
proxy?: ProxyAgent;
peers?: PeerInfo[];
}
```

@@ -127,0 +183,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc