MainSilent / Discord-Screenshare

First ever discord video screenshare SELFBOT
298 stars 80 forks source link

How to make it play other videos not on youtube? #47

Closed just-rich closed 2 years ago

just-rich commented 2 years ago

How could I make it so it could play videos not on youtube? preferably a live stream feed

MainSilent commented 2 years ago

It creates the stream from an HTML video element, You only need to show the live feed on the video element.

MainSilent commented 2 years ago

BTW you can use a direct video link, not just youtube.

just-rich commented 2 years ago

BTW you can use a direct video link, not just youtube.

Oh that's good to know.

Well I couldn't download youtube_dl because there wasn't one, but there was a youtube-dl.

First time I ran play command it said it downloaded, with no errors. But when I ran *p command it never played, and no logs in console. When I tried again I ran into these errors below, the first one is pretty self explanatory.

So I'm not sure if it's youtube-dl I'm having an issue with, or the headless browser selenium chrome. I have another bot on my raspberry pi that uses chromdriver, but had to modify the code to execute from a path that does work, like this; browser = await pyppeteer.launch({'executablePath':'/usr/bin/chromium-browser'}) image

image

Let me know if you have any suggestions

MainSilent commented 2 years ago

youtube_dl and youtube-dl are the same, If you use pip install youtube-dl or pip install youtube_dl It will download the same module. The errors are related to youtube-dl, Are you able to use it in the terminal youtube-dl 'url'?

just-rich commented 2 years ago

But isn't pip for python? I used npm install youtube-dl

Ok I tested it in terminal and i found the issue! USER ERROR lol

I was trying to play a youtube link from /short/ rather than /watch?

just-rich commented 2 years ago

Where do these videos download at? The one I should did using youtube-dl <url> where does it go?

And where do the videos go when using the bot?

(i'm using a raspberry pi with limited storage, so would like to purge these once in a while)

MainSilent commented 2 years ago

I will check other methods for playing youtube videos without a full download, When using youtube-dl you can pass the destination directory, The bot saves videos in ./client/tmp directory. It also does a full purge before downloading a new video.

just-rich commented 2 years ago

oh ok so it only keeps 1 video at a time then, thats good.

Now about this headless browser or whatever issue.. When I run *play url it downloads fine. but when I run `p it doesn't join the voice channel, so can't tell if it would even play or not.

like I mentioned before, on my raspberry pi I use chromium for something and have to specify the path it use browser = await pyppeteer.launch({'executablePath':'/usr/bin/chromium-browser'})

any suggestions on what I should do to fix this?

thank you for all the help so far!

MainSilent commented 2 years ago

This project uses selenium instead of pyppeteer, When using *p does it show any error on terminal?

just-rich commented 2 years ago

No error in terminal, just "play".

MainSilent commented 2 years ago

What is the environment? I had issues with other versions but the only environment that worked for me was ubuntu, chrome 88 and nodejs 14.

just-rich commented 2 years ago

Not sure what you mean by environments- if you haven't noticed already I'm not that savvy with all of this. (only own raspberry pi to host all my servers bots on, only good at editing configs and looking up errors with 50% chance of fixing them lol)

but hope this helps; Raspbian GNU/Linux 10 (buster) node version v16.13.0 npm version 8.1.0 Selenium version 4.1.2 (python -c "import selenium; print(selenium.__version__)") ChromeDriver 92.0.4515.98

im thinking I have to specify the path for selenium and chrome?

MainSilent commented 2 years ago

Currently, I can only guarantee the above environment, If chrome and chromedriver are in /bin directory the module will find it, You don't need to specify the path.

just-rich commented 2 years ago

well i think that was the issue last, the one in /bin doesnt work but the one in /usr/bin does- i'm almost positive this was he issue I was having with another bot and reason why I had to use path.

these are what tell it to use the chromedriver right? const webdriver = require('selenium-webdriver') const chrome = require('selenium-webdriver/chrome')

how can I tell it to use the chromedriver in /usr/bin instead?? like I did with the pyppeteer function with the other bot?

THANKS!

edit: are you on discord? if you want to add me that would be great, and faster communication. i'll also be afk for a while, 2am over here. rich#0003

MainSilent commented 2 years ago

I left discord for a while, Make sure to use a user token instead of a bot token since it's a self-bot. I believe you can find the selenium documentation, If it doesn't throw an error it means it has created the selenium socket.

just-rich commented 2 years ago

Yeah I'm using a user token. I had to change the ClientDataManager.js file because version 11 doesn't support stage channels, and you can't use a user token with version 12. might be something you want to mention in the readme, adding if(channel != null) guild.channels.set(channel.id, channel); fixes it- you prob already know that but I had no clue.

well i guess ill have one of the devs in my server see if they can get it working.

thanks

MainSilent commented 2 years ago

2 Well..., Hope you make it work.

just-rich commented 2 years ago

Before I never let the bot run for more than a few minutes after running the *play command after using *p url to download video, just thought it wasn't doing anything.

but i left it running and finally got an error. `/home/pi/discordbots/videostream/node_modules/selenium-webdriver/lib/error.js:517 let err = new ctor(data.message) ^

WebDriverError: unknown error: session deleted because of page crash from unknown error: cannot determine loading status from tab crashed (Session info: headless chrome=92.0.4515.98) at Object.throwDecodedError (/home/pi/discordbots/videostream/node_modules/selenium-webdriver/lib/error.js:517:15) at parseHttpResponse (/home/pi/discordbots/videostream/node_modules/selenium-webdriver/lib/http.js:642:13) at Executor.execute (/home/pi/discordbots/videostream/node_modules/selenium-webdriver/lib/http.js:568:28) at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5) at async thenableWebDriverProxy.execute (/home/pi/discordbots/videostream/node_modules/selenium-webdriver/lib/webdriver.js:731:17) { remoteStacktrace: '#0 0x000000a8a618 \n' + '#1 0x0000007f0894 \n' + '#2 0x0000007dd934 \n' + '#3 0x0000007dcc28 \n' + '#4 0x0000007dcfb8 \n' + '#5 0x0000007e9bd8 \n' + '#6 0x0000007ea6e8 \n' + '#7 0x0000007f7b88 \n' + '#8 0x000000852178 \n' + '#9 0x00000083fa14 \n' + '#10 0x000000818478 \n' + '#11 0x0000008193a4 \n' + '#12 0x000000ab7944 \n' + '#13 0x000000ac990c \n' + '#14 0x000000ac9550 \n' + '#15 0x000000acad40 \n' + '#16 0x000000ab8944 \n' + '#17 0x000000acafec \n' + '#18 0x000000aaf3ac \n' + '#19 0x000000ae26e8 \n' + '#20 0x000000ae2858 \n' + '#21 0x000000afcf4c \n' + '#22 0x0000b6eab494 start_thread\n' + '#23 0x000000000000 \n' } ` any idea what this is and how to fix it?

MainSilent commented 2 years ago

I'm not sure about the cause of the error, But I would recommend the suggested environment.

MainSilent commented 2 years ago

If you are still not able to set up the bot, I have pushed a Dockerfile

just-rich commented 2 years ago

I've never used Docker before but will look into it, thanks.

been wanting to get a bot like this streaming a live video stream 24/7- i got it almost running last night after some messing around. sudo mount -o remount,size=8G /dev/shm used this and stopped running other functions using chrome and was able to get it to join and screenshare but just never got it to play youtube.

then i learned I can't play youtube on regular chromium browser on the raspberry so was going to look into how others are able to do it.

but will look into this docker, thanks again

just-rich commented 2 years ago

Got it all working, but after using *p url and downloading then running *p to play nothing happened, a while later error was sent to console


      throw er; // Unhandled 'error' event
      ^

Error: WebSocket was closed before the connection was established
    at WebSocket.close (/Discord-Screenshare/node_modules/ws/lib/websocket.js:285:14)
    at WebSocketShard.destroy (/Discord-Screenshare/node_modules/discord.js-selfbot-v13/src/client/websocket/WebSocketShard.js:817:27)
    at WebSocketShard.onClose (/Discord-Screenshare/node_modules/discord.js-selfbot-v13/src/client/websocket/WebSocketShard.js:370:12)
    at WebSocket.onClose (/Discord-Screenshare/node_modules/ws/lib/event-target.js:210:18)
    at WebSocket.emit (node:events:527:28)
    at WebSocket.emitClose (/Discord-Screenshare/node_modules/ws/lib/websocket.js:258:10)
    at TLSSocket.socketOnClose (/Discord-Screenshare/node_modules/ws/lib/websocket.js:1249:15)
    at TLSSocket.emit (node:events:539:35)
    at node:net:715:12
    at TCP.done (node:_tls_wrap:582:7)
Emitted 'error' event on WebSocket instance at:
    at emitErrorAndClose (/Discord-Screenshare/node_modules/ws/lib/websocket.js:993:13)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)```
MainSilent commented 2 years ago

The discord module had an issue with the user WebSocket connection.