From 844086505f7d27bd17eae20cd21a8656a2137ebd Mon Sep 17 00:00:00 2001 From: nomevi <108267441+nomevi@users.noreply.github.com> Date: Wed, 29 Jun 2022 00:11:38 +0000 Subject: [PATCH] [extractor/livestreamfails] Add extractor (#4204) Authored by: nomevi --- yt_dlp/extractor/_extractors.py | 1 + yt_dlp/extractor/livestreamfails.py | 34 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 yt_dlp/extractor/livestreamfails.py diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py index b2a072fc1..f1ef46d0a 100644 --- a/yt_dlp/extractor/_extractors.py +++ b/yt_dlp/extractor/_extractors.py @@ -837,6 +837,7 @@ from .livestream import ( LivestreamOriginalIE, LivestreamShortenerIE, ) +from .livestreamfails import LivestreamfailsIE from .lnkgo import ( LnkGoIE, LnkIE, diff --git a/yt_dlp/extractor/livestreamfails.py b/yt_dlp/extractor/livestreamfails.py new file mode 100644 index 000000000..d6f626a99 --- /dev/null +++ b/yt_dlp/extractor/livestreamfails.py @@ -0,0 +1,34 @@ +from .common import InfoExtractor +from ..utils import format_field, traverse_obj, unified_timestamp + + +class LivestreamfailsIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?livestreamfails\.com/clip/(?P[0-9]+)' + _TESTS = [{ + 'url': 'https://livestreamfails.com/clip/139200', + 'md5': '8a03aea1a46e94a05af6410337463102', + 'info_dict': { + 'id': '139200', + 'ext': 'mp4', + 'display_id': 'ConcernedLitigiousSalmonPeteZaroll-O8yo9W2L8OZEKhV2', + 'title': 'Streamer jumps off a trampoline at full speed', + 'creator': 'paradeev1ch', + 'thumbnail': r're:^https?://.+', + 'timestamp': 1656271785, + 'upload_date': '20220626', + } + }] + + def _real_extract(self, url): + video_id = self._match_id(url) + api_response = self._download_json(f'https://api.livestreamfails.com/clip/{video_id}', video_id) + + return { + 'id': video_id, + 'display_id': api_response.get('sourceId'), + 'timestamp': unified_timestamp(api_response.get('createdAt')), + 'url': f'https://livestreamfails-video-prod.b-cdn.net/video/{api_response["videoId"]}', + 'title': api_response.get('label'), + 'creator': traverse_obj(api_response, ('streamer', 'label')), + 'thumbnail': format_field(api_response, 'imageId', 'https://livestreamfails-image-prod.b-cdn.net/image/%s') + }