sealedtx / java-youtube-downloader

Simple, almost zero-dependency java parser for retrieving youtube video metadata
Other
426 stars 117 forks source link

The downloader returns a null response. #118

Closed viwre closed 1 year ago

viwre commented 1 year ago

Hello! I am just finishing high school and I decided on a project for the summer and this library is going to come in very useful. Problem is when I try to use It I don't get VideoInfo back but instead a null response. (just as a heads up I'm not exactly a master programmer since as I said I am finishing high school but bear with me I suppose). I tried locating the issue and it lead me to the parseVideoAndroid method. After the POST request gets sent and response is received from the youtube servers, the response is this:

issue ^this is after the response is made into a JSONObject

"playabilityStatus": { "status": "ERROR", "reason": "This video is unavailable", "errorScreen": { "playerErrorMessageRenderer": { "subreason": { "runs": [ { "text": "Watch on the latest version of YouTube.", "navigationEndpoint": { "clickTrackingParams": "CAAQu2kiEwik1pjrr-D-AhVN5REIHde6DP4=", "urlEndpoint": { "url": "market://details?id=com.google.android.youtube&url=https%3A%2F%Fwww.youtube.com%2Fwatch%3Fv%3DNhsK5WExrnE", "target": "TARGET_NEW_WINDOW" } } } ] }, ^this is just from the response

Since I have practically no idea how to fix this (I tried to change the client version in the POST request body to the most recent version of youtube but since to be honest I don't even know if that's what is meant by "clientVersion"( and also it did not work), I concluded: Well I suppose now is a good time to make my first post on github.

YoutubeDownloader downloader = new YoutubeDownloader(); RequestVideoInfo request = new RequestVideoInfo("NhsK5WExrnE"); Response response = downloader.getVideoInfo(request); VideoInfo video = response.data(); System.out.println(video); ^ this is in my main method (the id of the video is valid so that isn't the problem)

sealedtx commented 1 year ago

@viwre please verify that you are using latest version of java-youtube-downloader - 3.2.3 Seems like this issue was already solved in https://github.com/sealedtx/java-youtube-downloader/issues/114

viwre commented 1 year ago

@sealedtx alright, thanks! That did the job. I was worried I was just doing something wrong. By the way If I may ask you, how did you come up with all this? I can understand most of what's happening fortunately, but the cipher just straight up killed me. I read a little bit and found out its because of some video signature that youtube sends you which you have to send back so youtube can start sending you the video, but I can't even begin to wrap my head around those regexes. Are they looking for the function calls that make up the cipher in the .js file? Even if they do how do you recreate the order of the calls? And I mean the rest of the code as well, reading it is comprehensible but writing it for me would be a nightmare pretty much. Like how do you know what you need to send to youtube and receive from them to make a proper connection or where to look for the javascript file? I am pretty new to the concept of real world applications since I have been writing mostly just exercises for my school and whenever I see something like this it just baffles me. It may not mean a lot coming from me considering my lack of experience but this is a very well written program in my opinion.

sealedtx commented 1 year ago

@viwre this is power of open source community :) this code was written mostly by me, but lot of complex stuff like regex, JS spoofing, etc was inspired by other people implementations, mostly in different languages like Python or Ruby (youtube-dl as one of most popular) lot of people spent their time investigating the process of how youtube works, monitoring actual requests, reviewing responses and reverse-engineering youtube applications to find loopholes to download video

viwre commented 1 year ago

well damn, Imagine if people made a habit of working together. Alright, I'll keep that in mind :) thanks!