• If you need help or want to discuss things, you now can also join us on our Discord Server!

Bug EqueueYt doesn't work atm

Do you think it's a good idea ?


  • Total voters
    4
Status
Not open for further replies.

DJMaxx_

Member
Hi, I would like to pitch my fload idea:

It would be a command allowing at the same time to download and save a music from YouTube-dl but also put it in the queue because at the moment we can only or save the music and directly play it or put it in queue but not save it.

EDIT: The command will be !qytdl or !qdl
 
Last edited:

SimoBot

Insider
Insider
You can make your own script, it's pretty easy, do you have any idea on how to do it?
I'm telling you that because there is a function called media.enqueueYtdl(url : String) which does what you wrote
 

SimoBot

Insider
Insider
I'm not at home now, but if you really need it you can wait me or easily download the youtube search script, and set it as you want.
 

DJMaxx_

Member
Yup, I really need it.
I don't know how to develop an addon for sinusbot, so I can't do it actually.
Could you make it ?
 

SimoBot

Insider
Insider
Here you go, it's pretty basic because it's summer ahah, anyway it does what you want, simply download this, put it in your script folder (should be something like /opt/sinusbot/script/), reboot sinusbot, go in the web interface under settings,scripts, tick "qytdl" and save. Now if you write something like !qytdl RandomVid, it will download the song and play after :) The script is very easy, if you want to change something, like the command, or the phrase when it download you can do it by modifying the script by yourself. Here if the code if you want to see it before downloading
Code:
registerPlugin({
    name: 'qYtdl',
    version: '1.0',
    description: 'qYtdl',
    author: 'SimoTheBest',
    vars: []
}, function(sinusbot, config) {
        var event = require('event');
        var media = require('media');
        var backend = require('backend');
        event.on('chat', function(ev) {
            var tes;
            var exp =/(?:!qytdl)\s+(?:\[url\])?(?:http|https)\:\/\/(?:www\.youtube\.com\/watch\?v\=|youtu\.be\/)([\w\-]+)/i;
            if ((tes = exp.exec(ev.text)) != null) {
                backend.getCurrentChannel().chat("Downloading song and queuing");
                media.ytdl("https://www.youtube.com/watch?v="+tes[1],true);
            }
        });
    }
);
 

Attachments

  • qytdl.js
    631 bytes · Views: 3

irgendwr

no longer active, "retired" staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Code:
media.ytdl("https://www.youtube.com/watch?v="+tes[1],true);
YouTube-dl - contrary to its name - downloads more than just YouTube videos so I'd suggest not messing with the url and just passing it directly.
 

irgendwr

no longer active, "retired" staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Update:
media.ytdl(..., true) doesn't enqueue the media but plays it directly.
media.enqueueYtdl(...) would be the correct way to do it but it doesn't seem to enqueue the video atm due to a bug
TL;DR: downloading and enqueuing doesn't work atm

but when it gets fixed in a further release you could to it like this:
Code:
registerPlugin({
    name: 'queue ytdl',
    version: '1.0',
    description: 'adds the command !qytdl (or !qdl for short) to queue YouTube videos',
    author: 'irgendwer',
    vars: []
}, function(sinusbot, config) {
        var event = require('event');
        var media = require('media');
        var backend = require('backend');

        var bbcode = new RegExp('\\[/?URL\\]', 'ig');

        event.on('chat', function(ev) {
            if (ev.client.isSelf())
                return;

            var args = ev.text.split(' ');

            if (args[0] == '!qytdl' || args[0] == '!qdl') {
                if (args.length == 1) {
                    ev.client.chat('syntax error, argument expected');
                } else {
                    var url = args[1].replace(bbcode, '');
                    ev.client.chat('downloading and enqueuing url...');
                    media.enqueueYtdl(url);
                }
            }
        });
    }
);
 

Attachments

  • qytdl.js
    962 bytes · Views: 7

SimoBot

Insider
Insider
Well, you are right, I tried enqueueYtdl before and it didn't work, i didn't read back the docs about the ytdl, i remembered that the boolean queued it, but it plays the song.. Oh thanks for letting me discover that youtube-dl works in a lot of sites ( ͡° ͜ʖ ͡°) ahah
 
Status
Not open for further replies.
Top