From 78b9b9ebc818c0f5c289b84f3b871d15973fac13 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Wed, 21 Apr 2021 14:15:40 +0545 Subject: [PATCH] more pages --- docs/extractors/extractor.md | 41 ++++++++++++++++++++++++++++++++---- docs/index.yml | 8 ++++++- docs/youtube/cookies.md | 15 +++++++++++++ docs/youtube/proxy.md | 16 ++++++++++++++ 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 docs/youtube/cookies.md create mode 100644 docs/youtube/proxy.md diff --git a/docs/extractors/extractor.md b/docs/extractors/extractor.md index c5222f0..c4c5bd0 100644 --- a/docs/extractors/extractor.md +++ b/docs/extractors/extractor.md @@ -19,17 +19,17 @@ Your extractor should have 2 methods (required): // the duration in ms duration: 20000, // the thumbnail - thumbnail: data.thumbnail, + thumbnail: "some thumbnail link", // engine, can be Readable streams or link to raw stream that gets played - engine: data.streamURL, + engine: "someStreamLink", // number of views views: 0, // author of this stream - author: data.artist.name, + author: "Some Artist", // description description: "", // link of this stream - url: data.url + url: "Some Link" } ``` - `important: boolean` @@ -40,5 +40,38 @@ Your extractor should have 2 methods (required): This should be the version of your extractor. It is not really important and is set to `0.0.0` by default. +# Loading Extractors +Discord Player Extractors can be loaded using `Player.use(ExtractorName, Extractor)` method. + +## Register Extractor + +```js +const myExtractor = { + version: "1.0.0", + important: false, + validate: (query) => true, + getInfo: async (query) => { + return { + title: "Extracted by custom extractor", + duration: 20000, + thumbnail: "some thumbnail link", + engine: "someStreamLink", + views: 0, + author: "Some Artist", + description: "", + url: "Some Link" + }; + } +}; + +player.use("GiveItSomeName", myExtractor); +``` + +## Remove Extractor + +```js +player.unuse("GiveItSomeName"); +``` + # Examples ### You can check out **[@discord-player/extractor](https://github.com/Snowflake107/discord-player-extractors)** \ No newline at end of file diff --git a/docs/index.yml b/docs/index.yml index 93b985f..f367636 100644 --- a/docs/index.yml +++ b/docs/index.yml @@ -5,4 +5,10 @@ - name: Extractors files: - name: Extractors API - path: extractor.md \ No newline at end of file + path: extractor.md +- name: YouTube + files: + - name: Using Cookies + path: cookies.md + - name: Using Proxy + path: proxy.md \ No newline at end of file diff --git a/docs/youtube/cookies.md b/docs/youtube/cookies.md new file mode 100644 index 0000000..3149972 --- /dev/null +++ b/docs/youtube/cookies.md @@ -0,0 +1,15 @@ +# Using Cookies to avoid 429 + +```js +const { Player } = require("discord-player"); + +const player = new Player(client, { + ytdlDownloadOptions: { + requestOptions: { + headers: { + cookie: "YOUR_YOUTUBE_COOKIE" + } + } + } +}); +``` \ No newline at end of file diff --git a/docs/youtube/proxy.md b/docs/youtube/proxy.md new file mode 100644 index 0000000..3dc8ba5 --- /dev/null +++ b/docs/youtube/proxy.md @@ -0,0 +1,16 @@ +# Using Proxy to avoid 429 + +```js +const { Player } = require("discord-player"); +const HttpsProxyAgent = require("https-proxy-agent"); + +// Remove "user:pass@" if you don't need to authenticate to your proxy. +const proxy = "http://user:pass@111.111.111.111:8080"; +const agent = HttpsProxyAgent(proxy); + +const player = new Player(client, { + ytdlDownloadOptions: { + requestOptions: { agent } + } +}); +``` \ No newline at end of file