diff options
author | James Taylor <user234683@users.noreply.github.com> | 2019-12-20 20:35:05 -0800 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2019-12-20 20:35:05 -0800 |
commit | d2ba9be7a7d463bddc87dc30205eaee49752bafd (patch) | |
tree | dd949f0b967ed3599f1e0061d745b58d8f6fb441 /youtube | |
parent | 98fbdf77cb7af6d49bbd981765ac84824fe114c2 (diff) | |
download | yt-local-d2ba9be7a7d463bddc87dc30205eaee49752bafd.tar.lz yt-local-d2ba9be7a7d463bddc87dc30205eaee49752bafd.tar.xz yt-local-d2ba9be7a7d463bddc87dc30205eaee49752bafd.zip |
Better error handling for incorrect watch page urls
- Correctly handle /embed, /watch with no video ids
- Correctly report error for this and for too short video ids
Diffstat (limited to 'youtube')
-rw-r--r-- | youtube/watch.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/youtube/watch.py b/youtube/watch.py index 75ee7e9..7a57873 100644 --- a/youtube/watch.py +++ b/youtube/watch.py @@ -272,12 +272,14 @@ def format_bytes(bytes): @yt_app.route('/watch') +@yt_app.route('/embed') @yt_app.route('/embed/<video_id>') def get_watch_page(video_id=None): video_id = request.args.get('v') or video_id + if not video_id: + return flask.render_template('error.html', error_message='Missing video id'), 404 if len(video_id) < 11: - flask.abort(404) - flask.abort(flask.Response('Incomplete video id (too short): ' + video_id)) + return flask.render_template('error.html', error_message='Incomplete video id (too short): ' + video_id), 404 lc = request.args.get('lc', '') tasks = ( |