Androz2091 / discord-player

🎧 Complete framework to simplify the implementation of music commands using discord.js v14
https://discord-player.js.org/
MIT License
604 stars 192 forks source link

Custom extractors #322

Closed jameslinimk closed 3 years ago

jameslinimk commented 3 years ago

https://www.npmjs.com/package/xvideos ( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)

dongsu8142 commented 3 years ago

LOL I think it's good. But it's gonna be hard.

dongsu8142 commented 3 years ago

https://www.npmjs.com/package/get-xvideos

We've fixed a lot of errors and changed the module to the latest one. This is gonna be a lot easier, right?

twlite commented 3 years ago

There was one previously added in dev version: https://npmjs.com/package/xvdl

but we decided to remove xvideos support from this lib. Maybe in the future.

for ref, you can see #286 and 36fa63f

Androz2091 commented 3 years ago

Sorry this won't be added. But we could add a way to support "plugins", a simple file that you can require with discord-player

const { registerExtractorPlugin } = require('discord-player');

const extractorPlugin = class Plugin {

    static getData (url) {
        // do something and returns an object
    }

    static validateURL (url) {
        // returns a boolean
    }

    static getStream () {
    }
}

registerExtractorPlugin(extractorPlugin);

something like that could be interesting

Dragonizedpizza commented 3 years ago

its... Concerning... that you would want to add xvideos to a Discord music module...

twlite commented 3 years ago

This feature is done in rewrite

player.use("extractorName", {
    validate: (query) => someBooleanValue,
    getInfo: (query) => {
        // you don't need to validate query here, discord-player handles it for you :)
        // you can return null if you dont have data

        return {
            engine: yourStream,
            // other metadata
        };
    }
});

You can use player.unuse("extractorName") to remove extractor.

Default extractor names

Attachment, Facebook, Reverbnation, Vimeo

after that it should automatically use your extractor when it validates the query passed to player.play. Anything not valid here is treated as youtube search query

Dragonizedpizza commented 3 years ago

This feature is done in rewrite

did you actually add xvideos support..

twlite commented 3 years ago

@Dragonizedpizza no :) but you can add it yourself easily with Discord Player's Extractor API

Dragonizedpizza commented 3 years ago

I don't want to I am happy that you didn't add it