Forums

i am using web2py and want to use module name "pafy" and Module installed properly but it's function not working in pythonanywhere but in the localhost it is working properly

I am using Web2Py and want to use module pafy. so i first wrote the simple code in localhost which was import pafy video = pafy.new("Here i wrote the URL of the youtube video which i want to get") this is working in localhost but in pythonanywhere it is not working but module was installed by me and also import pafy does not showing any error and if i removed the code line video = pafy.new("URL") the error is also removed. the error which i got is as given below.

Traceback (most recent call last): File "/home/tushar992/web2py/gluon/restricted.py", line 227, in restricted exec ccode in environment File "/home/tushar992/web2py/applications/ytd/controllers/default.py", line 15, in <module> File "/home/tushar992/web2py/gluon/globals.py", line 412, in <lambda> self._caller = lambda f: f() File "/home/tushar992/web2py/applications/ytd/controllers/default.py", line 10, in second video = pafy.new(dlink) File "/home/tushar992/.local/lib/python2.7/site-packages/pafy/pafy.py", line 145, in new return Pafy(url, basic, gdata, signature, size, callback) File "/home/tushar992/.local/lib/python2.7/site-packages/pafy/pafy.py", line 1076, in init self.fetch_basic() File "/home/tushar992/.local/lib/python2.7/site-packages/pafy/pafy.py", line 1119, in fetch_basic self.dash = _extract_dash(self._dashurl) File "/home/tushar992/.local/lib/python2.7/site-packages/pafy/pafy.py", line 302, in _extract_dash dashdata = fetch_decode(dashurl) File "/home/tushar992/.local/lib/python2.7/site-packages/pafy/pafy.py", line 97, in fetch_decode raise e HTTPError: HTTP Error 403: Forbidden

One of the servers that Pafy uses was blocked by our proxy. I have added it to the whitelist so it should work now.

Thankyou,, It is working Now

Hi, ai am using Pafy with flask. I am getting the following error:

youtube_dl.utils.ExtractorError: Unable to download API page: <urlopen error Tunnel connection failed: 403 Forbidden> (caused by URLError(OSError('Tunnel connection failed: 403 Forbidden'))) NO MATCH During handling of the above exception, another exception occurred: NO MATCH Traceback (most recent call last): File "/home/Philomath/.local/lib/python3.8/site-packages/pafy/backend_youtube_dl.py", line 40, in _fetch_basic self._ydl_info = ydl.extract_info(self.videoid, download=False) File "/home/Philomath/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 808, in extract_info return self.__extract_info(url, ie, download, extra_info, process) File "/home/Philomath/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 824, in wrapper self.report_error(compat_str(e), e.format_traceback()) File "/home/Philomath/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 628, in report_error self.trouble(error_message, tb) File "/home/Philomath/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 598, in trouble raise DownloadError(message, exc_info) youtube_dl.utils.DownloadError: ERROR: Unable to download API page: <urlopen error Tunnel connection failed: 403 Forbidden> (caused by URLError(OSError('Tunnel connection failed: 403 Forbidden')))

I need to use pafy in this project. What can be the possible solution?

That will not work in a free account on PythonAnywhere. Youtube do not have an API for downloading videos, so they are not a candidate for the allow list.

Do all the paid versions allow modules like pafy and pytube?

We will not prevent the network access. However, that does not necessarily mean that it will work. Youtube have mechanisms that prevent that sort of use of their service so it may not work because of things that youtube does.

If I upgrade to paid version, can I downgrade it to free account later?

Yes, you can