Open Mrithul-E opened 7 months ago
Hi @Mrithul-E, thanks for opening this issue. I'm assuming you were using either the WEB
or WEB_REMIX
client to get the above streaming data? If so, YouTube employs a "bot guard" which means the stream is encoded/encrypted in such a way that it makes it hard to extract a usable URL. The community has been really good at reverse engineering the mechanism YouTube uses for this, so it is possible to decode. A few good references for this are yt-dlp and NewPipe.
The easiest solution is usually just to use a non-web client to fetch the streaming urls. For example, if you hit the /player
endpoint as IOS
or IOS_MUSIC
(or ANDROID
or ANDROID_MUSIC
) you should get streamable URLs.
Hope that helps!
Very thanks!, but I am so late to see this replay from @tombulled ... and now I started using pytube for decrypting the url
we can simply pass the youtube video url to pytube's Youtube() class and access the json return from youtube using streaming_data
function inside Youtube class of pytube
eg:
yt=YouTube("https://www.youtube.com/watch?v="+j)
json_respo = yt.streaming_data
The urls stored in json_respo
can used straight forward
I cant open the like got from 'IOS or ANDROID_MUSIC`
I wrote an example script a while back to demo fetching the streaming URLs, for example:
$ python examples/list-streams-for-video.py
[{'approxDurationMs': '212040',
'averageBitrate': 3024555,
'bitrate': 4534636,
'contentLength': '80165852',
'fps': 25,
'height': 1080,
'indexRange': {'end': '1241', 'start': '742'},
'initRange': {'end': '741', 'start': '0'},
'itag': 137,
'lastModified': '1706255300792263',
'mimeType': 'video/mp4; codecs="avc1.640028"',
'projectionType': 'RECTANGULAR',
'quality': 'hd1080',
'qualityLabel': '1080p',
'url': '<STREAMABLE URL HERE>',
'width': 1920},
...
]
I've replaced the URL in the above example output with <STREAMABLE URL HERE>
as the URL contains information such as the requestor's IP address. You should be able to download these URLs or view them in your browser. Importantly I believe you have to make HTTP requests for these links from the same IP address that requested them, otherwise they will not work
how to play the link got from yt music
please say how to use this lib for yt music , i want to get the music url
i got this url :
but the link from this is not playable andthe link after sig&url= is also not working
how to play the music