mirror of
https://github.com/ihabunek/twitch-dl
synced 2024-08-30 18:32:25 +00:00
Handle more gracefully when video/clip not found
This commit is contained in:
@ -219,6 +219,9 @@ def _download_clip(slug, args):
|
|||||||
print_out("<dim>Looking up clip...</dim>")
|
print_out("<dim>Looking up clip...</dim>")
|
||||||
clip = twitch.get_clip(slug)
|
clip = twitch.get_clip(slug)
|
||||||
|
|
||||||
|
if not clip:
|
||||||
|
raise ConsoleError("Clip '{}' not found".format(slug))
|
||||||
|
|
||||||
print_out("Found: <green>{}</green> by <yellow>{}</yellow>, playing <blue>{}</blue> ({})".format(
|
print_out("Found: <green>{}</green> by <yellow>{}</yellow>, playing <blue>{}</blue> ({})".format(
|
||||||
clip["title"],
|
clip["title"],
|
||||||
clip["broadcaster"]["displayName"],
|
clip["broadcaster"]["displayName"],
|
||||||
|
@ -18,8 +18,10 @@ def authenticated_get(url, params={}, headers={}):
|
|||||||
headers['Client-ID'] = CLIENT_ID
|
headers['Client-ID'] = CLIENT_ID
|
||||||
|
|
||||||
response = requests.get(url, params, headers=headers)
|
response = requests.get(url, params, headers=headers)
|
||||||
if response.status_code == 400:
|
if 400 <= response.status_code < 500:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
# TODO: this does not look nice in the console since data["message"]
|
||||||
|
# can contain a JSON encoded object.
|
||||||
raise ConsoleError(data["message"])
|
raise ConsoleError(data["message"])
|
||||||
|
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
Reference in New Issue
Block a user