From fb7755bb1ed7ac0cc7e430f609723d019ede5ce5 Mon Sep 17 00:00:00 2001 From: dirkf Date: Fri, 17 Dec 2021 12:38:12 +0000 Subject: [PATCH] [parliamentlive] Support current page structure --- youtube_dl/extractor/parliamentliveuk.py | 70 ++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/parliamentliveuk.py b/youtube_dl/extractor/parliamentliveuk.py index bdd5ff565..f992b0129 100644 --- a/youtube_dl/extractor/parliamentliveuk.py +++ b/youtube_dl/extractor/parliamentliveuk.py @@ -2,6 +2,15 @@ from __future__ import unicode_literals from .common import InfoExtractor +from ..compat import compat_str + +from ..utils import ( + get_element_by_id, + int_or_none, + parse_iso8601, + try_get, +) + class ParliamentLiveUKIE(InfoExtractor): IE_NAME = 'parliamentlive.tv' @@ -11,12 +20,15 @@ class ParliamentLiveUKIE(InfoExtractor): _TESTS = [{ 'url': 'http://parliamentlive.tv/Event/Index/c1e9d44d-fd6c-4263-b50f-97ed26cc998b', 'info_dict': { - 'id': '1_af9nv9ym', + 'id': 'c1e9d44d-fd6c-4263-b50f-97ed26cc998b', 'ext': 'mp4', 'title': 'Home Affairs Committee', - 'uploader_id': 'FFMPEG-01', - 'timestamp': 1422696664, - 'upload_date': '20150131', + 'timestamp': 1622916432, + 'upload_date': '20210605', + 'description': 'Tue, 18 Mar 2014 14:44:32 GMT', + }, + 'params': { + 'format': 'bestvideo/best', }, }, { 'url': 'http://parliamentlive.tv/event/index/3f24936f-130f-40bf-9a5d-b3d6479da6a4', @@ -25,6 +37,56 @@ class ParliamentLiveUKIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) + video_data = self._download_json( + 'https://exposure.api.redbee.live/v2/customer/UKParliament/businessunit/ParliamentLive/entitlement/%s/play?' % video_id, + video_id, fatal=False, + headers={'Authorization': 'Bearer 5qIxfu04iGfVXniravNWzlcxk|5qIxfu04iGfVXniravNWzlcxk|5qIxfu04iGfVXniravNWzlcxk|null|1639618587134|1642210587134|true|82293e3a-a0ea-fac9-385d-bfad5829b9c1|WEB||||YipgM4RjyCVP0UqxE29scVZio+L5yUzzCF0Xtp6ToMM=', }) + if video_data: + webpage = self._download_webpage(url, video_id) + pub_id = try_get(video_data, 'publicationId', compat_str) or ('%s_0D62A9b' % video_id) + video_metadata = self._download_json( + 'https://exposure.api.redbee.live/v1/customer/UKParliament/businessunit/ParliamentLive/content/asset/%s?fieldSet=ALL' % pub_id, + video_id, fatal=False, note='Downloading additional JSON metadata') or {} + title = (try_get(video_metadata, lambda x: x['localized'][0]['title'], compat_str) + or self._html_search_regex(r']*>([^<]+)