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 403 error while downloading via web service #7639

Closed
codeasashu opened this issue Nov 25, 2015 · 1 comment
Closed

HTTP 403 error while downloading via web service #7639

codeasashu opened this issue Nov 25, 2015 · 1 comment

Comments

@codeasashu
Copy link

@codeasashu codeasashu commented Nov 25, 2015

I am trying to use youtube_dl python module, and able to get it working on local machine. I am outputting formats key of JSON data obtained. This helps me to get download urls for various resolutions. However, I uploaded the same code on python enabled servers(Heroku as well as DigitalOcean), which again provided the expected output. However, whenever I try to use url that of servers ones, I get an 403 http errors while the same url on localhost for same resolutions are working fine and downloadable.

I think this might be the issue of sender's address, Hence tried to pass config param as:

yt_config = {'quiet': True, 'prefer_insecure': True, 'no_warnings': True,'source_address':'my_public_ip'}

which resulted in following error:

[Wed Nov 25 00:03:25.124811 2015] [:error] [pid 12805] [youtube] e72tG80LmsU: Downloading webpage
[Wed Nov 25 00:03:25.152316 2015] [:error] [pid 12805] ERROR: Unable to download webpage: <urlopen error [Errno 99] Cannot assign requested address> (caused by URLError(error(99, 'Cannot assign requested address'),))
[Wed Nov 25 00:03:25.153791 2015] [:error] [pid 12805] ERROR:FlaskApp:Exception on /page/e72tG80LmsU [GET]
[Wed Nov 25 00:03:25.153805 2015] [:error] [pid 12805] Traceback (most recent call last):
[Wed Nov 25 00:03:25.153809 2015] [:error] [pid 12805]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
[Wed Nov 25 00:03:25.153813 2015] [:error] [pid 12805]     response = self.full_dispatch_request()
[Wed Nov 25 00:03:25.153817 2015] [:error] [pid 12805]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
[Wed Nov 25 00:03:25.153821 2015] [:error] [pid 12805]     rv = self.handle_user_exception(e)
[Wed Nov 25 00:03:25.153825 2015] [:error] [pid 12805]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
[Wed Nov 25 00:03:25.153829 2015] [:error] [pid 12805]     reraise(exc_type, exc_value, tb)
[Wed Nov 25 00:03:25.153832 2015] [:error] [pid 12805]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
[Wed Nov 25 00:03:25.153836 2015] [:error] [pid 12805]     rv = self.dispatch_request()
[Wed Nov 25 00:03:25.153839 2015] [:error] [pid 12805]   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
[Wed Nov 25 00:03:25.153843 2015] [:error] [pid 12805]     return self.view_functions[rule.endpoint](**req.view_args)
[Wed Nov 25 00:03:25.153846 2015] [:error] [pid 12805]   File "/home/cashking/files/FlaskApp/FlaskApp/__init__.py", line 33, in page
[Wed Nov 25 00:03:25.153850 2015] [:error] [pid 12805]     result = ydl.extract_info(url,download=False)
[Wed Nov 25 00:03:25.153853 2015] [:error] [pid 12805]   File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 678, in extract_info
[Wed Nov 25 00:03:25.153857 2015] [:error] [pid 12805]     self.report_error(compat_str(de), de.format_traceback())
[Wed Nov 25 00:03:25.153860 2015] [:error] [pid 12805]   File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 538, in report_error
[Wed Nov 25 00:03:25.153885 2015] [:error] [pid 12805]     self.trouble(error_message, tb)
[Wed Nov 25 00:03:25.153889 2015] [:error] [pid 12805]   File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 508, in trouble
[Wed Nov 25 00:03:25.153892 2015] [:error] [pid 12805]     raise DownloadError(message, exc_info)
[Wed Nov 25 00:03:25.153895 2015] [:error] [pid 12805] DownloadError: ERROR: Unable to download webpage: <urlopen error [Errno 99] Cannot assign requested address> (caused by URLError(error(99, 'Cannot assign requested address'),))

I am trying to download http://youtube.com/watch?v=e72tG80LmsU

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Nov 25, 2015

That's expected: URLs are only guaranted to work on the same network and with the same cookies and headers, since we replicate what browsers do and that's how it works.

About setting the source_address option: your computer must be able to connect with that address (you can't use an arbitrary IP).

@jaimeMF jaimeMF closed this Nov 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.