npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-player-youtubei

v1.3.2

Published

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

Downloads

3,303

Readme

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.

  • Warning: the documentation on GitHub is for the edge version of this package. Refer to this for more information

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()
/**
 * getOauthTokens is not a real function exported by discord-player-youtubei.
 * It is simply a placeholder for the actual oauth tokens
 * 
 * Do not just put in access token. Put in the entire string.
 */
const oauthTokens = getOauthTokens() // The tokens printed from step above

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

Types

StreamOptions

| name | type | description | required | | ---- | ---- | ----------- | -------- | | useClient | InnerTubeClient | Which client to get the stream from | false | | highWaterMark | number | How many bytes the stream can hold. The more bytes allocated, the smoother the stream at the cost of more memory usage | false |

YoutubeiOptions

| name | type | description | | ---- | ---- | ----------- | | authentication | string | The auth token | | overrideDownloadOptions | DownloadOptions | Override the default download options | | createStream | fn (q, ext): Promise<string|Readable> | Override the streaming function | | signOutOnDeactive | boolean | Revoke the tokens after deactivation | | overrideBridgeMode | "ytmusic" or "yt" | Override the bridging behavior | | streamOptions | StreamOptions | Configure streaming behavior | | disablePlayer | boolean | Disable the JavaScript player. Use ANDORID client for streaming when using this | | innertubeConfigRaw | InntertubeConfigRaw | Options passed to .create() | | trustedTokens | TrustedTokenConfig | The trusted tokens passed to YouTube to avoid bans | | cookie | string | The cookies passed to innertube similar to ytdl cookies |

TrustedTokenConfig

Rename of GeneratorReturnData
All properties are required

| name | type | description | | ---- | ---- | ----------- | | visitorData | string | The visitor data of the PoToken | | poToken | string | The trusted token of the YouTube client |

Raw Types

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;
}

Functions

| class | function | params | static | description | | ----- | -------- | ------ | ------ | ----------- | | YoutubeiExtractor | setClientMode | InnerTubeClient | true | Set the innertube client on the fly |

Something isn't working?

Try installing an alpha or a beta build using npm install discord-player-youtubei@alpha or npm install discord-player-youtubei@beta. If no beta has been released, you can test the edge version by installing directly from github using npm install github:retrouser955/discord-player-youtubei --save If this still does not work or you installed a version that is lower than the main version, feel free to open an issue on our GitHub page

If you know how to fix it, please clone this repository and send us a pull request. As this is an open source project, any contributions are welcome!

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.