Raptor123471 / DingoLingo

A Discord music bot written in Python with support for Youtube, SoundCloud, Spotify, Bandcamp, Twitter, and custom files.
GNU General Public License v3.0
282 stars 165 forks source link

Unable to play stream form YouTube #59

Closed miniboy0624 closed 2 years ago

miniboy0624 commented 2 years ago

[youtube] XDgl5kTvw7M: Downloading webpage [youtube] XDgl5kTvw7M: Downloading m3u8 information [youtube] XDgl5kTvw7M: Downloading MPD manifest ERROR: requested format not available [youtube] XDgl5kTvw7M: Downloading webpage [youtube] XDgl5kTvw7M: Downloading m3u8 information [youtube] XDgl5kTvw7M: Downloading MPD manifest skipping 20 segments ahead, expired from playlists

Hi, thanks for the music robot, I have a question: When I play the stream music from YouTube, it shows the code above and the music stops playing after a few seconds. Is this music robot cant play streams?

Raptor123471 commented 2 years ago

Can you send me the link to the livestream? It is currently working on my instance.

miniboy0624 commented 2 years ago

I mean any livestream from YouTube. When I played the livestream, it showed the following result and started the livestream for a few seconds, then no sound came out. image

PythonicBoat commented 2 years ago

Live streams ain't supported by youtube-dl to incorporate playback of https links @Raptor123471 trying adding lavalink.py/wavelink to your repo. These libraries ensure playback of songs/streams by running parallel to the main source code. @miniboy0624 as you say it plays for some time and stops, it is due to the fact that youtube-dl downloads/extracts audio first and then streams it to the vc.

Raptor123471 commented 2 years ago

I am not able to reproduce this issue on my instance. The live stream you provided has been playing for 30mins now. Is that the full output with the issue you are having? Try updating all of your dependencies if you have not already.

PythonicBoat commented 2 years ago

@miniboy0624 try adding this under commands/music.py

    @commands.command()
    async def stream(self, ctx, *, url):
        """Streams from a url (same as yt, but doesn't predownload)"""

        async with ctx.typing():
            player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)
            ctx.voice_client.play(player, after=lambda e: print(f'Player error: {e}') if e else None)

        await ctx.send(f'Now playing: {player.title}')

This will stream audio from the provided url rather than downloading it, hope it helps!

Raptor123471 commented 2 years ago

@PythonicBoat youtube-dl does support live-streams and my current instance has no problem with the livestream provided. I believe @miniboy0624 may have outdated dependancies.

PythonicBoat commented 2 years ago

well with doesn't 'suppport', I had meant the way in which audio playback was. The play command in your repo, by default fetches the url, downloads, extracts and then play it. Doing so for livestreams might be buggy (it completely depends upon your hosting server and network connection) as it will have to continuously fetch and stream it. Thus, alternatively i had mentioned the use of wavelink/lavalink. Though my above post contains a stream command, which instead of downloading the stream will play it directly.

miniboy0624 commented 2 years ago

Thank you for help, I will try to use the way u guys said. :)