hbmartin / pytube3

Deprecated, please see https://github.com/pytube3/pytube3
3 stars 1 forks source link

error 500 Internal Server Error Internal Server Error. #8

Open streamgamers opened 2 years ago

streamgamers commented 2 years ago

Trying to fetch youtube video data using pytube but getting error below, Here is my code

from pytube import YouTube
from flask import request
from flask import Flask
import jsonpickle

app = Flask(__name__)
@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
           url = request.form["d_url"]
           yt_video = YouTube(url)
           videos = yt_video.streams
           res_list = list(videos)
           return jsonpickle.encode(res_list)
    else:
        return request.args.get('d_url')
if __name__ == "__main__":
    app.run(debug =True)

I'm getting error below in Log File, I don't know what's the issue, but that code working fine in my localhost, but When I tried to run on Heroku It gives error below

Traceback (most recent call last):
2022-08-07T07:48:45.427991+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/flask/app.py", line 2525, in wsgi_app
2022-08-07T07:48:45.427991+00:00 app[web.1]:     response = self.full_dispatch_request()
2022-08-07T07:48:45.427992+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/flask/app.py", line 1822, in full_dispatch_request
2022-08-07T07:48:45.427992+00:00 app[web.1]:     rv = self.handle_user_exception(e)
2022-08-07T07:48:45.427993+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/flask/app.py", line 1820, in full_dispatch_request
2022-08-07T07:48:45.427993+00:00 app[web.1]:     rv = self.dispatch_request()
2022-08-07T07:48:45.427993+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/flask/app.py", line 1796, in dispatch_request
2022-08-07T07:48:45.427994+00:00 app[web.1]:     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
2022-08-07T07:48:45.427994+00:00 app[web.1]:   File "/app/app.py", line 11, in login
2022-08-07T07:48:45.427994+00:00 app[web.1]:     yt_video = YouTube(str(request.form["d_url"]))
2022-08-07T07:48:45.427995+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/pytube/__main__.py", line 91, in __init__
2022-08-07T07:48:45.427995+00:00 app[web.1]:     self.prefetch()
2022-08-07T07:48:45.427996+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/pytube/__main__.py", line 181, in prefetch
2022-08-07T07:48:45.427996+00:00 app[web.1]:     self.vid_info_raw = request.get(self.vid_info_url)
2022-08-07T07:48:45.427996+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/pytube/request.py", line 36, in get
2022-08-07T07:48:45.427997+00:00 app[web.1]:     return _execute_request(url).read().decode("utf-8")
2022-08-07T07:48:45.427997+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/pytube/request.py", line 24, in _execute_request
2022-08-07T07:48:45.427998+00:00 app[web.1]:     return urlopen(request)  # nosec
2022-08-07T07:48:45.427998+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/urllib/request.py", line 216, in urlopen
2022-08-07T07:48:45.427998+00:00 app[web.1]:     return opener.open(url, data, timeout)
2022-08-07T07:48:45.427998+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/urllib/request.py", line 525, in open
2022-08-07T07:48:45.427998+00:00 app[web.1]:     response = meth(req, response)
2022-08-07T07:48:45.427999+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/urllib/request.py", line 634, in http_response
2022-08-07T07:48:45.427999+00:00 app[web.1]:     response = self.parent.error(
2022-08-07T07:48:45.427999+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/urllib/request.py", line 557, in error
2022-08-07T07:48:45.428000+00:00 app[web.1]:     result = self._call_chain(*args)
2022-08-07T07:48:45.428000+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/urllib/request.py", line 496, in _call_chain
2022-08-07T07:48:45.428000+00:00 app[web.1]:     result = func(*args)
2022-08-07T07:48:45.428000+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/urllib/request.py", line 749, in http_error_302
2022-08-07T07:48:45.428001+00:00 app[web.1]:     return self.parent.open(new, timeout=req.timeout)
2022-08-07T07:48:45.428001+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/urllib/request.py", line 525, in open
2022-08-07T07:48:45.428001+00:00 app[web.1]:     response = meth(req, response)
2022-08-07T07:48:45.428002+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/urllib/request.py", line 634, in http_response
2022-08-07T07:48:45.428002+00:00 app[web.1]:     response = self.parent.error(
2022-08-07T07:48:45.428002+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/urllib/request.py", line 563, in error
2022-08-07T07:48:45.428002+00:00 app[web.1]:     return self._call_chain(*args)
2022-08-07T07:48:45.428003+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/urllib/request.py", line 496, in _call_chain
2022-08-07T07:48:45.428003+00:00 app[web.1]:     result = func(*args)
2022-08-07T07:48:45.428003+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.10/urllib/request.py", line 643, in http_error_default
2022-08-07T07:48:45.428003+00:00 app[web.1]:     raise HTTPError(req.full_url, code, msg, hdrs, fp)