I'm trying to make a youtube downloader by pyscript
but I got this error
<py-env>
- pytube
</py-env>
<py-script >
from pytube import YouTube
url="https://www.youtube.com/watch?v=7BXJIjfJCsA&t=111s"
my_video=YouTube(url)
print(my_video.title)
</py-script>
JsException(PythonError: Traceback (most recent call last):
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 429,
in eval_code .run(globals, locals)
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 300,
in run coroutine = eval(self.code, globals, locals)
File "", line 4,
in
File "/lib/python3.10/site-packages/pytube/__main__.py", line 341,
in title self._title = self.vid_info['videoDetails']['title']
File "/lib/python3.10/site-packages/pytube/__main__.py", line 246,
in vid_info innertube_response = innertube.player(self.video_id)
File "/lib/python3.10/site-packages/pytube/innertube.py", line 300,
in player return self._call_api(endpoint, query, self.base_data)
File "/lib/python3.10/site-packages/pytube/innertube.py", line 242,
in _call_api response = request._execute_request(
File "/lib/python3.10/site-packages/pytube/request.py", line 37,
in _execute_request return urlopen(request, timeout=timeout) # nosec
File "/lib/python3.10/urllib/request.py", line 216,
in urlopen return opener.open(url, data, timeout)
File "/lib/python3.10/urllib/request.py", line 519,
in open response = self._open(req, data)
File "/lib/python3.10/urllib/request.py", line 541,
in _open return self._call_chain(self.handle_open, 'unknown',
File "/lib/python3.10/urllib/request.py", line 496,
in _call_chain result = func(*args)
File "/lib/python3.10/urllib/request.py", line 1419,
in unknown_open raise URLError('unknown url type: %s' % type) urllib.error.URLError:
Web browsers do not allow applications to open TCP sockets. Your application depends on urllib
which requires TCP sockets. The package urllib
is not supported by any web browser due to the browser's security sandbox.
Your application and its dependencies must be modified to use supported browser APIs such as fetch
.