From f963eea8beb0f56f0b7f01b526f5d75bdc171011 Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 29 Dec 2020 10:57:30 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20CI:=20Bumped=20codecov?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vidgear/gears/camgear.py | 35 +++++++++---------- .../tests/videocapture_tests/test_camgear.py | 2 +- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/vidgear/gears/camgear.py b/vidgear/gears/camgear.py index 95abc478e..ba5810ea1 100644 --- a/vidgear/gears/camgear.py +++ b/vidgear/gears/camgear.py @@ -193,27 +193,24 @@ def __init__( # set parameters for key, value in stream_params: session.set_option(key, value) - # select valid stream resolutions - if streams: - # check whether stream-resolution was specified and available - if not stream_resolution in streams.keys(): - # if unavailable - logger.warning( - "Specified stream-resolution `{}` is not available. Reverting to `best`!".format( - stream_resolution - ) - ) - # revert to best - stream_resolution = "best" - # extract url - source = streams[stream_resolution].url - else: - # raise error if something is wrong with URL. - raise RuntimeError( - "[CamGear:ERROR] :: Invalid `{}` URL cannot be processed!".format( - source + # select streams are available + assert ( + streams + ), "[CamGear:ERROR] :: Invalid `{}` URL cannot be processed!".format( + source + ) + # check whether stream-resolution was specified and available + if not stream_resolution in streams.keys(): + # if unavailable + logger.warning( + "Specified stream-resolution `{}` is not available. Reverting to `best`!".format( + stream_resolution ) ) + # revert to best + stream_resolution = "best" + # extract url + source = streams[stream_resolution].url except Exception as e: # raise error if something went wrong raise ValueError( diff --git a/vidgear/tests/videocapture_tests/test_camgear.py b/vidgear/tests/videocapture_tests/test_camgear.py index 34a4143c4..5a18edd69 100644 --- a/vidgear/tests/videocapture_tests/test_camgear.py +++ b/vidgear/tests/videocapture_tests/test_camgear.py @@ -135,7 +135,7 @@ def test_threaded_queue_mode(source, options): [ ("https://youtu.be/uCy5OuSQnyA", "best", "invalid"), ("https://youtu.be/NMre6IAAAiU", "invalid", {"nocheckcertificate": True}), - ("https://www.dailymotion.com/video/x7xsoud", "720p", {"hls-live-edge": 3.0}), + ("https://www.dailymotion.com/video/x7xsoud", "invalid", {"hls-live-edge": 3.0}), ("im_not_a_url", "", {}), ], )