Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Error 403: Forbidden while downloading video #192

Open
kolipavan011 opened this issue Jun 19, 2024 · 40 comments
Open

HTTP Error 403: Forbidden while downloading video #192

kolipavan011 opened this issue Jun 19, 2024 · 40 comments

Comments

@kolipavan011
Copy link

How can I solve this issue?

The package working well but whenever I am downloading video from received url, 403 error is getting

@tsu-nick
Copy link

Have the same issue, trying to figure it out, but have no results yet, if you solve it please share your solution, thanks.

@JKDos
Copy link

JKDos commented Jul 5, 2024

I'm getting the same problem with Youtube's URL through the API. The download URL is supposedly blocked if accessed by an IP address different from the one that requested it. Have you tried seeing if a proxy solves the problem? I'm stuck here because I am not turning my website into a proxy. And using methods like get_file_content() receive a 403 error too, despite having the same IP.

@acuna-public
Copy link

@JKDos unfortunately proxy didn't help(

@JKDos
Copy link

JKDos commented Jul 19, 2024

I had a feeling it wouldn't. Since others claimed it to only be downloaded from the same IP address, I did try having my server grab the file instead of the client. All methods return the 403 error back to the server. I also installed XAMPP and hosted everything from my own computer and got same problem. I think the method used here is out of date. I'm unfortunately giving up as it's taking too much work to get a working PHP downloader running on my site.

There is an alternative method. You can look into using: https://github.com/thelevicole/youtube-to-html5-loader and this https://github.com/thelevicole/youtube-to-html5-server
Audio streams are not included in formats above 720p, so if you get a downloader working, you'll need to use something to merge audio.

EDIT: I forgot to mention. Youtube is forever changing things on their backend likely to combat those of us downloading videos. If you finding a working solution, keep it mind it may be broken as soon as tomorrow. The python project for youtube-dl will probably be the best bet for finding a project that is well maintained.

@acuna-public
Copy link

acuna-public commented Jul 19, 2024

@JKDos well, it's hard to believe, but there are a few changes which is totally broke the download, I'm using it for more than 3 years and there are only twice when I needed to update it (this is a third :) ) and some people have a downloaders integrated in their projects, so using another langs projects can't be a solution but thanks for you thoughts. Btw the solution is found, wait some time when I post it.

@acuna-public
Copy link

acuna-public commented Jul 19, 2024

Take it!

Just change

"clientName" => "ANDROID",
"clientVersion" => "19.09.37",

to

"clientName" => "ANDROID_TESTSUITE",
"clientVersion" => "1.9",

and userAgent to

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

It's fixed a 403 error and together with that didn't cut the speed as a bonus but some videos (not more than 5%) can't find the download links.

I can give a glue that problem is in links decoder because all becomes working again without it because ANDROID_TESTSUITE links don't need the decoding.

@JKDos
Copy link

JKDos commented Jul 23, 2024

Thanks. That got it working. Still though, it has the other problem of missing audio on 1080p+ videos. At least with the sample video I am using. I've seen examples of solving this with FFMPEG. How to implement that in a PHP solution, is another topic.

@acuna-public
Copy link

acuna-public commented Jul 25, 2024

Glad to hear it!) Well, 1080+ videos are concidered as premium by YouTube so can even contains differ languages tracks, so you need to download a video and desired language audio separately (change "hl" => "en" in request body) and implode it with ffmpeg in your script with exec:

exec ("ffmpeg -i video.webm -i audio.webm -c copy output.webm");

Don't worry it have the same extension.

@alisaleem252
Copy link

Take it!

Just change

"clientName" => "ANDROID",
"clientVersion" => "19.09.37",

to

"clientName" => "ANDROID_TESTSUITE",
"clientVersion" => "1.9",

and userAgent to

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

It's fixed a 403 error and together with that didn't cut the speed as a bonus but some videos (not more than 5%) can't find the download links.

I can give a glue that problem is in links decoder because all becomes working again without it because ANDROID_TESTSUITE links don't need the decoding.

Thanks alot it worked.

@kolipavan011
Copy link
Author

This is working well. Thank you so much @acuna-public.

@acuna-public
Copy link

acuna-public commented Jul 30, 2024

@kolipavan011 glad! Btw funny avatar!)

@DennAgain
Copy link

so mine arent even downloading? i click fetch and it does nothing? also im trying to get

public/video_info.php?url=https://www.youtube.com/shorts/Kn05M-hYAH8

to shoot back a direct .mp4 link

@JKDos
Copy link

JKDos commented Aug 8, 2024

so mine arent even downloading? i click fetch and it does nothing? also im trying to get

public/video_info.php?url=https://www.youtube.com/shorts/Kn05M-hYAH8

to shoot back a direct .mp4 link

Can you try to encode that youtube url? public/video_info.php?url=[encoded URL]

@acuna-public
Copy link

@DennAgain YouTube reels direct links can be differ

@DennAgain
Copy link

so mine arent even downloading? i click fetch and it does nothing? also im trying to get
public/video_info.php?url=https://www.youtube.com/shorts/Kn05M-hYAH8
to shoot back a direct .mp4 link

Can you try to encode that youtube url? public/video_info.php?url=[encoded URL]

just shoots this back

{
"error": ""
}

@rajatvermaiam
Copy link

ANDROID_TESTSUITE is not working anymore, i guess

@JKDos
Copy link

JKDos commented Sep 25, 2024

ANDROID_TESTSUITE is not working anymore, i guess

I see that :(.

I've done some testing this morning. Try the following

"clientName" => "ANDROID_CREATOR",
"clientVersion" => "22.36.102",

@acuna-public
Copy link

All is working guys, I've tested it yesterday. As I mentioned earlier SOME of links CAN be unavailable, but it's about 5% of all.

@JKDos
Copy link

JKDos commented Sep 25, 2024

All is working guys, I've tested it yesterday. As I mentioned earlier SOME of links CAN be unavailable, but it's about 5% of all.

I don't think it's a 5% issue, at least not for me. No link I use with ANDROID_TESTSUITE (old or new) provides any video links links anymore. It's only returning meta data and thumbnails. Here's an example of what's being returned https://pastebin.com/3QvjUGTT

That is a sample video I use for testing. It worked when I first switched to ANDROID_TESTSUITE, and currently works for the client data I shared today.

@rajatvermaiam
Copy link

ANDROID_TESTSUITE is not working anymore , ANDROID_CREATOR is working fine . i have switched to ANDROID_CREATOR few hours ago .

@acuna-public
Copy link

@JKDos So it's working? https://www.youtube.com/watch?v=1mO3lW-FvuI It's working for me too. Can you share links which are not working for you?

@cyberpunkbln
Copy link

Hello,
great the ANDROID_CREATOR functioned very well, but only one combined format is given back. Hmm the yt-dlp client variables https://github.com/yt-dlp/yt-dlp/blob/fa2be9a7c63babede07480151363e54eee5702bd/yt_dlp/extractor/youtube.py are intresting but a few of them are very very old. Knows anybody a good client name/version list?
thx

@JKDos
Copy link

JKDos commented Sep 25, 2024

@JKDos So it's working? https://www.youtube.com/watch?v=1mO3lW-FvuI It's working for me too. Can you share links which are not working for you?

Sorry for any confusion. No link, including that one, is working for

"clientName" => "ANDROID_TESTSUITE",
"clientVersion" => "1.9",

The returned data includes only thumbnails and video meta data (e.g. name, description, creator, tags, etc). Interestingly, I see this in the returned data

  "playabilityStatus": {
    "status": "UNPLAYABLE",
    "reason": "This video is not available"
  },

While looking for an alternative today, I did have success with everything I tried so far with the following.

"clientName" => "ANDROID_CREATOR",
"clientVersion" => "22.36.102",

Perhaps there's another piece to the the puzzle outside the clientName and clientVersion to make ANDROID_TESTSUITE work.

@cyberpunkbln
Copy link

sign Youtube figtht hardly

@acuna-public
Copy link

@JKDos so did ANDROID_CREATOR resolve this issue? Because I'm just helping people with this project because I have my own downloader which is based on this one.

@acuna-public
Copy link

acuna-public commented Oct 3, 2024

@cyberpunkbln not quite like that because I know only twice (last one is the third) where it brokes downloading for its entire history.

@JKDos
Copy link

JKDos commented Oct 3, 2024

@JKDos so did ANDROID_CREATOR resolve this issue?

I've used it on a few videos so far, and it seemed to be functioning in the same manner that ANDROID_TESTSUITE. However, I tried it a couple times today, and it only returned up to 720p on the videos, even though these videos had 1080p. So I'm guessing it's not truly the winning solution. I've also seen it fail a couple times returning
"playabilityStatus": { "status": "LOGIN_REQUIRED", "reason": "Please sign in" }
and something about "Prove you're not a bot".

To be honest though, I try not to use my php downloader because the downloads are extremely slow, and larger videos will sometimes fail before finishing. I've setup youtube-dl on a raspberry pi and I'm trying to utilize that more often.

That Javascript alternative might still be worth looking into, if anyone is still interested: https://github.com/thelevicole/youtube-to-html5-loader

@modemmike
Copy link

Will composer update get us the latest fixes?

@ngarangan
Copy link

ANDROID_CREATOR not working: https://www.youtube.com/watch?v=XXYlFuWEuKI

@JKDos
Copy link

JKDos commented Oct 10, 2024

ANDROID_CREATOR not working: https://www.youtube.com/watch?v=XXYlFuWEuKI

Yes, unfortunately, now it's constantly returning "playabilityStatus": { "status": "LOGIN_REQUIRED", "reason": "Please sign in" }

I found an alternative that's working. I'm thinking the dunderheads at Youtube are reading this thread, so I might have to DM it to you

@ngarangan
Copy link

ANDROID_CREATOR not working: https://www.youtube.com/watch?v=XXYlFuWEuKI

Yes, unfortunately, now it's constantly returning "playabilityStatus": { "status": "LOGIN_REQUIRED", "reason": "Please sign in" }

I found an alternative that's working. I'm thinking the dunderheads at Youtube are reading this thread, so I might have to DM it to you

yes please mail me [email protected]

@acuna-public
Copy link

acuna-public commented Dec 20, 2024

Hi guys, whats up? Found a solution, please wait some days while I've upload it, I need some tests.

@poor-bob
Copy link

@acuna-public did you end up testing your solution? I'm also in need; to be honest, I use this tool to reverse proxy my own youtube videos in a setting where youtube.com is blocked (educational)

@acuna-public
Copy link

acuna-public commented Jan 22, 2025

@poor-bob ah, I'm so sorry, I was busy this days so forgot to wrote here. I wanted to contact @JKDos about his solution firstly because my based on another client name so I need to know which his solution is based so can you please wait about 2-3 days while we communicated and after that I'll post it there?

@acuna-public
Copy link

@JKDos hi, I've already found a solution about a month ago, can I ask you about on what is yours based? What is DM you're talking about? Or you can write me at [email protected]

@JKDos
Copy link

JKDos commented Jan 22, 2025

DM as in Direct Message. My PHP downloader might be a combination of 2-3 PHP projects I smashed together to get working as most solutions were outdated by the time I got to them. As far as I know, the last solution I found for this is still up and running.

It may not be what you want to hear, but I have since abandoned doing this via webserver / PHP.

I am now using yt-dlp on one of my Linux servers. It's lightning fast and maintained. Plus, it will automatically merge video and audio for me.

https://github.com/yt-dlp/yt-dlp/wiki/Installation

Install Example (Debian/Ubuntu):

sudo add-apt-repository ppa:tomtomtom/yt-dlp
sudo apt update                           
sudo apt install yt-dlp

@acuna-public
Copy link

acuna-public commented Jan 23, 2025

@JKDos yes, I know that DM means but I didn't know that GitHub have it) Okay, thanks but for it, but it's not a solution for me because my project on PHP. My solution stops working some days ago so I'm looking for another one. I'm freer now so I can spend my time on it.

@poor-bob I can be so busy sometimes because of main job so don't hesitate to write me in a week for example if I disappeared suddenly again.

@poor-bob
Copy link

@acuna-public thank you! But I'm actually not in need of help with this anymore. I've abandoned it.

And funnily enough, @JKDos my team looked into alternatives as well and we went with yt-dlp.

@acuna-public
Copy link

@JKDos @poor-bob thanks, but seems it's faster for me to find a solution instead of rewrite my scripts, but seems I need to use this solution if I don't find another one. Is it working? Does it needs side cookies, any tokens etc.?

@poor-bob
Copy link

it's working great for us; we implemented the change in less than 4 hours total. from what we could tell, they were doing quite a lot different at yt-dlp, it wasn't just a simple change that we could identify.

@acuna-public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests