rustube
rustube copied to clipboard
Adapt to YouTube api v1 (#30)
This fixes the problem that YouTube apparently dropped support for /get_video_info
.
Closes #30
The current implementation works for some videos like G7UDTG7wtSo
, but not for others like 5jlI4uzZGjU
.
When having a look at the videoplayback
URLs, the URLs YouTube uses and the URLs rustube uses are different:
G7UDTG7wtSo (used by youtube.com)
https://r5---sn-hoxu-h0je.googlevideo.com/videoplayback?expire=1621515083&ei=6wamYLlDhYDH8A-IgZuADw&ip=2001%3Aa61%3A2bd2%3Ab301%3A83c%3Ab40a%3A4cac%3A6d1a&id=o-AMTD6O4vJviYW6CycIm8lgjAU04LmzA5OdfxDsA0cLeA&itag=398&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C278%2C394%2C395%2C396%2C397%2C398%2C399&source=youtube&requiressl=yes&mh=GQ&mm=31%2C29&mn=sn-hoxu-h0je%2Csn-h0jeenek&ms=au%2Crdu&mv=m&mvi=5&pl=42&gcr=de&vprv=1&mime=video%2Fmp4&ns=o5aXdVWqCba--nOXLNSYF5cF&gir=yes&clen=27872679&dur=229.270&lmt=1618090633134537&mt=1621493333&fvip=5&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=5531432&n=Kv4CTed5Bb_-fQ&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cgcr%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl&lsig=AG3C_xAwRQIgaVbiuaZvpvq8LyyYwlzyEKRD9QbAwGDrTKrIwtgItoYCIQDjZi0MOTBUG_H5tkbfWxKTYCBCoq4zmoORckvsUIo1YA%3D%3D&alr=yes&sig=AOq0QJ8wRAIgJYetkRBTQnyAJ-fYibWJY3Aoxbmno4F6Z18NDlGfwIoCICT0xNTul3AiS_2P2-hMLKrY2_8eas8jo61pYBqNwwkB&cpn=NHnVsw9idoqT0mm1&cver=2.20210518.07.00&range=0-287697&rn=1&rbuf=0&altitags=397%2C396
G7UDTG7wtSo (used by rustube)
https://r8---sn-hoxu-h0jl.googlevideo.com/videoplayback?expire=1621515385&ei=GQimYMSpIqGAx_AP_MeLuAs&ip=2001%3Aa61%3A2bd2%3Ab301%3A83c%3Ab40a%3A4cac%3A6d1a&id=o-AIMfe6TdWcyHdEffcQd3OGqCORQ8UxyaUy4BhvLNX9Oh&itag=22&source=youtube&requiressl=yes&mh=CS&mm=31%2C29&mn=sn-hoxu-h0jl%2Csn-h0jeen76&ms=au%2Crdu&mv=m&mvi=8&pl=42&vprv=1&mime=video%2Fmp4&ns=2AZF5gNlCKJWN58dXdx8m5wF&ratebypass=yes&dur=1692.525&lmt=1621429741985096&mt=1621493571&fvip=4&fexp=24001373%2C24007246&c=WEB&txp=7216222&n=Kb77uzXilpR5jI6Bd&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRAIgfKpnwenzH2pIAZyAsDX8JHmg5pA7HmYYpKr39iEx8-ACIDvTgX6KTKiM76TAwH4Vh5mIMWPQ5-w3n27gsiMsRKWb&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl&lsig=AG3C_xAwRQIhAP9OOIID5QqVWjUGoQmpgpUcb3zP5ZUztaj9ilyR4xiYAiBDeCZzQ8cbtDHE_2WSvwOp96U5n0nXIlgnhvylzb8IMA%3D%3D
5jlI4uzZGjU (used by youtube.com)
https://r5---sn-hoxu-h0je.googlevideo.com/videoplayback?expire=1621515083&ei=6wamYLlDhYDH8A-IgZuADw&ip=2001%3Aa61%3A2bd2%3Ab301%3A83c%3Ab40a%3A4cac%3A6d1a&id=o-AMTD6O4vJviYW6CycIm8lgjAU04LmzA5OdfxDsA0cLeA&itag=398&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C278%2C394%2C395%2C396%2C397%2C398%2C399&source=youtube&requiressl=yes&mh=GQ&mm=31%2C29&mn=sn-hoxu-h0je%2Csn-h0jeenek&ms=au%2Crdu&mv=m&mvi=5&pl=42&gcr=de&vprv=1&mime=video%2Fmp4&ns=o5aXdVWqCba--nOXLNSYF5cF&gir=yes&clen=27872679&dur=229.270&lmt=1618090633134537&mt=1621493333&fvip=5&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=5531432&n=Kv4CTed5Bb_-fQ&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cgcr%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl&lsig=AG3C_xAwRQIgaVbiuaZvpvq8LyyYwlzyEKRD9QbAwGDrTKrIwtgItoYCIQDjZi0MOTBUG_H5tkbfWxKTYCBCoq4zmoORckvsUIo1YA%3D%3D&alr=yes&sig=AOq0QJ8wRAIgJYetkRBTQnyAJ-fYibWJY3Aoxbmno4F6Z18NDlGfwIoCICT0xNTul3AiS_2P2-hMLKrY2_8eas8jo61pYBqNwwkB&cpn=NHnVsw9idoqT0mm1&cver=2.20210518.07.00&range=0-287697&rn=1&rbuf=0&altitags=397%2C396
5jlI4uzZGjU (used by rustube)
https://r5---sn-hoxu-h0je.googlevideo.com/videoplayback?expire=1621514787&ei=wwWmYMjAM6Knx_APzNWH8Ao&ip=2001%3Aa61%3A2bd2%3Ab301%3A83c%3Ab40a%3A4cac%3A6d1a&id=o-ACTHPs68ClKqUXEyOxDPHSXR3iFb_Rdu2CRYbhvPkFGl&itag=18&source=youtube&requiressl=yes&mh=GQ&mm=31%2C29&mn=sn-hoxu-h0je%2Csn-4g5edne7&ms=au%2Crdu&mv=m&mvi=5&pl=40&gcr=de&initcwndbps=1393750&vprv=1&mime=video%2Fmp4&ns=0CAvsyVmurHNL4aOpH9RhREF&gir=yes&clen=20330488&ratebypass=yes&dur=229.320&lmt=1579181722517430&mt=1621493092&fvip=5&fexp=24001373%2C24007246&c=WEB&txp=5531432&n=d4JpYjhmgoipvSSnF&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cgcr%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhAP6RCWnwL_BVwCKqYe2_UHjQjWbjBCCeeXm2LXa_8l8MAiATyZeElO9_mohtWG4OZc_J-MqgyzRVU8qrHap9othRnA%3D%3D&sig=cAWZo8pWI8xPiOCWhh8GudArdmObtI4QtUOPnATzJCyAEiARutIojOxCJAvKl3vVNS6L7WGs__zlrA7le51HNIxgvJAhIgRw8JQ0qOee
Comparison between the rustube parameters (left) and the youtube query parameters (right)
@DzenanJupic One thing I don't understand is, why the duration between both requests should be so different. 1692.525 to 229.270 just seems a bit strange.
For the video 5jlI4uzZGjU
: Using another youtube player, called NewPipe, I experienced that it couldn't play Music videos, but could play other videos at the same time. That's why I think, that youtube has more or less strict blocking policy's for third party players depending on the type of video. I also ran into an captcha-wall when trying to play a newly released music video while using this player, but not by using youtube.com.
@DzenanJupic One thing I don't understand is, why the duration between both requests should be so different. 1692.525 to 229.270 just seems a bit strange.
My bad, I mixed the URLs up. I now updated the image.
For the video
5jlI4uzZGjU
: Using another youtube player, called NewPipe, I experienced that it couldn't play Music videos, but could play other videos at the same time. That's why I think, that youtube has more or less strict blocking policy's for third party players depending on the type of video. I also ran into an captcha-wall when trying to play a newly released music video while using this player, but not by using youtube.com.
Interesting! Though, since we are (hopefully) using the same API as youtube.com
and not the API for third party players we should also see the same behaviour as when using youtube.com
.
But nevertheless, the current implementation definitely differs from the JavaScript implementation that youtube.com
uses.
I just looked through their source code (the app is still working), and at least at one location they still use get_video_info url's. I don't know if this is their actual way, but they used it in a different way than us. https://github.com/TeamNewPipe/NewPipeExtractor/blob/3a3ade20f48cf37526eb970a7df56ee2405125fc/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java#L978. I unfortunately can't test this as I haven't really figured out how to obtain a sts, defined here
Seems like they use the get_video_info
URL we use for age restricted videos.
I just tested to set is_age_restricted
to true all the time, but unfortunately that doesn't solve the issue.
This PR from pytube
worked for me with the video 5jlI4uzZGjU
.