pythonpythonanywhereyoutube-dlpafy

Pafy module causing error in PythonAnywhere


I am using pafy in a Flask app. It is working fine on my local machine. But when I am trying to deploy and run on PythonAnywhere, it is throwing an error. Upon execution, it is showing the following ewrror:

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 have also removed the lines for dislike count in backend_yoututbe_dl in PythonAnywhere (from bash). Still, no use.


Solution

  • That will not work on PythonAnywhere. Any youtube video downloads use unofficial methods and so PythonAnywhere will not add youtube to the allowlist for free accounts.