Darkempire78 / Music-Discord-Bot

A music Discord bot with more than 30+ commands which allows to play music on your server efficiently. Supports Youtube, Spotify, Deezer and Soundcloud links. Skips intros and blanks in the music with Sponsorblock.

Home Page:https://top.gg/bot/796749718217555978

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use StreamURLFetcher & PyTube instead of youtube_dl

alexmercerind opened this issue · comments

Hi there!

I recently saw this project from you.
I'm maintainer of youtube-search-python & I made few additions to my project which you might like.

As you might be aware, that youtube_dl or vanilla PyTube is kinda slow to get video URLs as they make "additional web requests" for getting the exact same response which you already have when displaying it to the user.

from youtubesearchpython import *
fetcher = StreamURLFetcher() # Instantiate this class only once (makes web requests).

video = Video.get("https://www.youtube.com/watch?v=aqz-KE-bpKQ") # Let's assume you get information of this video for displaying.
url = fetcher.get(video, 251) # You can use same response to get its stream URL (Very fast, does not make any requests).
print(url)

See more here.

Thankyou, I just wanted to let you know.

NOTE: I'm not sure how stable it is at the moment, but is definitely worth trying.
You may close (or delete) this issue, once you read.

I will check this.
Thanks!

@alexmercerind It's perhaps stupid, but i do not really find how get the video length 🤔

@Darkempire78 it is present in "streamingData" of the Video.get.
And, in case of Search classes, its present in "duration".

It does not work with YouTube live contrary to Youtube_dl, so i need to check if the link is a live when stream_url is None i think

changed!