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
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-player-youtubei

An unofficial package to test the use of youtubei in discord-player v6.

  • 1.2.5-beta.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
915
decreased by-28.63%
Maintainers
1
Weekly downloads
 
Created
Source

Discord Player YouTubei

This is a preview the v7 version of the YouTube system that discord-player will be using made backwards compatiable with v6.

Installation

$ npm install discord-player-youtubei
# ----------- or -----------
$ yarn add discord-player-youtubei

Usage

Typescript and ESM
import { YoutubeiExtractor } from "discord-player-youtubei"

const player = useMainPlayer() // or new Player()

player.extractors.register(YoutubeiExtractor, {})
CommonJS
const { YoutubeiExtractor } = require("discord-player-youtubei")

const player = useMainPlayer() // or new Player()

player.extractors.register(YoutubeiExtractor, {})

I have seen many people registering the extractor in their commands. DO NOT DO THIS

How Discord Player Youtubei handles bridging

As of 1.2.1, discord-player-youtubei will detect if you are signed in or not and will use YouTube music streaming system. If this is not available, the extractor will use normal YouTube.

You can override this behavior using the overrideBridgeMode option. See the extractor options below for more information regarding the types

Signing into YouTube

First run the following command

$ npx --no discord-player-youtubei

The token will be printed out shortly

In case of errors, you can directly run the generateOauthTokens function exported by discord-player-youtubei

import { YoutubeiExtractor } from "discord-player-youtubei"

const player = useMainPlayer()
const oauthTokens = getOauthTokens() // The tokens printed from step above

player.extractors.register(YoutubeiExtractor, {
    authentication: oauthTokens
})

Rotating your token

Since Youtube has a hard limt (which is not that strict), we can provide a rotator config when registering the extractor. View Rotator

Types

RotatorShardOptions
nametyperequired
authenticationsArray of stringtrue
rotationStrategy"shard"true
currentShardnumbertrue
RotatorRandomOptions
nametyperequired
authenticationsArray of stringtrue
rotationStrategy"random"true
RotatorConfig
type RotatorConfig = RotatorShardOptions | RotatorRandomOptions
StreamOptions
nametypedescriptionrequired
useClientInnerTubeClientWhich client to get the stream fromfalse
YoutubeiOptions
nametypedescription
authenticationstringThe auth token
overrideDownloadOptionsDownloadOptionsOverride the default download options
createStreamfn (q, ext): Promise<string|Readable>Override the streaming function
signOutOnDeactivebooleanRevoke the tokens after deactivation
rotatorRotatorConfigThe config of the rotator
overrideBridgeMode"ytmusic" or "yt"Override the bridging behavior
streamOptionsStreamOptionsConfigure streaming behavior
disablePlayerbooleanDisable the JavaScript player. Use ANDORID client for streaming when using this

Raw Types

interface RotatorShardOptions {
	authentications: string[];
	rotationStrategy: "shard";
	currentShard: number;
}

interface RotatorRandomOptions {
	authentications: string[];
	rotationStrategy: "random";
}

type RotatorConfig = RotatorShardOptions | RotatorRandomOptions

interface YoutubeiOptions {
	authentication?: string;
	overrideDownloadOptions?: DownloadOptions;
	createStream?: (q: Track, extractor: BaseExtractor<object>) => Promise<string | Readable>;
	signOutOnDeactive?: boolean;
	streamOptions?: {
		useClient?: InnerTubeClient
	};
	rotator?: RotatorConfig;
	overrideBridgeMode?: "ytmusic" | "yt"
}

Functions

classfunctionparamsstaticdescription
YoutubeiExtractorsetClientModeInnerTubeClienttrueSet the innertube client on the fly

Want to support us?

Just star this repo!

Notice Regarding YouTube Streaming

Streaming from YouTube is against their Terms of Service (ToS). Refer to LEGAL.md to view the risks using YouTube.

FAQs

Package last updated on 02 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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