From ea4a9f4d9868fb99aea2d8e0755c23af509a53cf Mon Sep 17 00:00:00 2001 From: nomevi <108267441+nomevi@users.noreply.github.com> Date: Sun, 10 Jul 2022 01:45:51 +0200 Subject: [PATCH] Correct which fields are fail inducing and crash proof --- youtube_dl/extractor/livestreamfails.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/livestreamfails.py b/youtube_dl/extractor/livestreamfails.py index 22180d986..04d533e05 100644 --- a/youtube_dl/extractor/livestreamfails.py +++ b/youtube_dl/extractor/livestreamfails.py @@ -4,6 +4,11 @@ from __future__ import unicode_literals from .common import InfoExtractor import time import calendar +from ..utils import ( + try_get, + url_or_none, +) +from ..compat import compat_str class LivestreamfailsIE(InfoExtractor): @@ -40,10 +45,10 @@ class LivestreamfailsIE(InfoExtractor): return { 'id': id, + 'url': 'https://livestreamfails-video-prod.b-cdn.net/video/' + api_response['videoId'], + 'title': api_response['label'], 'display_id': api_response.get('sourceId'), # Twitch ID of clip 'timestamp': timestamp, - 'url': 'https://livestreamfails-video-prod.b-cdn.net/video/' + api_response.get('videoId'), - 'title': api_response.get('label'), - 'creator': api_response.get('streamer', {}).get('label'), - 'thumbnail': 'https://livestreamfails-image-prod.b-cdn.net/image/' + api_response.get('imageId'), + 'creator': try_get(api_response, lambda x: x['streamer']['label'], compat_str), + 'thumbnail': url_or_none(try_get(api_response, lambda x: 'https://livestreamfails-image-prod.b-cdn.net/image/' + x['imageId'])) }