omansak / libvideo

A lightweight .NET library to download YouTube videos.
BSD 2-Clause "Simplified" License
553 stars 164 forks source link

403 (Forbidden) #283

Closed doesch closed 4 months ago

doesch commented 4 months ago

I use the following code which makes problems since the last two weeks:

        public string Download(string url, string downloadFolder)
        {
            var youtube = YouTube.Default;
            var vid = youtube.GetVideo(url);
            var path = Path.Combine(downloadFolder, vid.FullName);

            System.IO.File.WriteAllBytes(path, vid.GetBytes());

            return path;
        }

The codeline System.IO.File.WriteAllBytes(path, vid.GetBytes()); produces the following error:

System.Net.Http.HttpRequestException: 'Response status code does not indicate success: 403 (Forbidden).'

The YouTube URL is: https://music.youtube.com/watch?v=SuXoyuVePcY I tried multiple links. No link is working any more. Nuget-Package: VideoLibrary V3.2.3

kizuki1749 commented 4 months ago

same issue

mediaexplorer74 commented 4 months ago

same issue

Ohh... bad news. I need this library for my own Youtube App replica :( I tried to explore libvideo src code but I have no skills to fix this problem. And I cannot to use YoutubeExplode (no compatibility to .NET Standard 1.4)

The problem is: Youtube url generation (video "descrambling"?) damaged. For example, generated link https://rr18---sn-n8v7kne7.googlevideo.com/videoplayback?expire=1718747657&ei=qa1xZo3ILKHNv_IPudCqkAw&id=o-ADPE0LTMNJf0Botm6Sg-PP6kLXXYBU9zW3_3QTNAq_Z_&itag=18&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=Pk&mm=31%2C26&mn=sn-n8v7kne7%2Csn-5goeen7y&ms=au%2Conr&mv=m&mvi=18&pl=23&initcwndbps=2356250&bui=AbKP-1NifHAiUoaDmYGCpYaegq_wuU1DIHppQ77IX0GOHZIbJkSNJsTIZF-AeUIFqDS4VJUd6yRoKcpe&spc=UWF9fxyBXSiRK5rfrs3KJHch_n0lPlz1YAqoEjTrNmhthQqiaK9Ct24La7YT&vprv=1&svpuc=1&mime=video%2Fmp4&ns=UvcRNEnuBtbfWXu8FGqfzbUQ&rqh=1&cnr=14&ratebypass=yes&dur=563.060&lmt=1699273836324638&mt=1718725750&fvip=4&c=WEB&sefc=1&txp=6218224&n=7i0jk-SE_67l7jsM-Q&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Ccnr%2Cratebypass%2Cdur%2Clmt&sig=AJfQdSswRQIhAIj1gskWsGTkFTm0YlZB9hL2QDIKJfBvNfAISkaRemKiAiB_iYIM7TMk4Z14XvpJHat_HEYRqy8r83BWbmxrGeUuLA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHlkHjAwRgIhAN8ze7cLW6jyt6bqCPQiIR2_eWbjRqNi7oERi00oziqXAiEArtD4aN1h9zVycNC4UW6h5zvqoW6v94s-F5geZTKta_U%3D gets error:

Access to rr18---sn-n8v7kne7.googlevideo.com was denied
You don't have authorization to view this page.
HTTP ERROR 403
kizuki1749 commented 4 months ago

In my environment, downgrading VideoLibrary to the older version 3.1.9 worked as before. I wonder if the URL generation logic has changed since 3.2.0.

mediaexplorer74 commented 4 months ago

In my environment, downgrading VideoLibrary to the older version 3.1.9 worked as before. I wonder if the URL generation logic has changed since 3.2.0.

Interesting finding / notice. Ok, I'll compare 3.1.9 & 3.2.0 (maybe, old JS Engine was more universal... idk). Thank you for quick reply.

Best, [m]edia[e]xplorer Old Big Windows 10 Mobile fanboy

doesch commented 4 months ago

In my environment, downgrading VideoLibrary to the older version 3.1.9 worked as before. I wonder if the URL generation logic has changed since 3.2.0.

Unfortunately an downgrade to V3.1.9 doesn´t solve the issue in my application. I get still:

System.Net.Http.HttpRequestException: 'Response status code does not indicate success: 403 (Forbidden).

kizuki1749 commented 4 months ago

In my environment, downgrading VideoLibrary to the older version 3.1.9 worked as before. I wonder if the URL generation logic has changed since 3.2.0.

Unfortunately an downgrade to V3.1.9 doesn´t solve the issue in my application. I get still:

System.Net.Http.HttpRequestException: 'Response status code does not indicate success: 403 (Forbidden).

Either way, as Google is in the process of changing YouTube's specs, the previous version might not work anymore. I've checked and this library works with .NET Framework 4.8.1, so it might not work with more recent versions. To get to the bottom of this, we need to take a closer look at the source code to see how this library generates direct links.

(Sorry for the poor writing, I'm using translations)

omansak commented 4 months ago

Hello guys, sorry for lately responding and solving. I have just published new version, can anyone try this ?

doesch commented 4 months ago

Tested -> fixed!