2015-08-12 08:59:04 -06:00
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
2015-10-02 10:29:15 -06:00
|
|
|
int_or_none,
|
|
|
|
orderedSet,
|
|
|
|
parse_duration,
|
2022-12-10 01:44:43 -07:00
|
|
|
parse_iso8601,
|
2021-08-22 13:02:00 -06:00
|
|
|
parse_qs,
|
2015-10-02 10:29:15 -06:00
|
|
|
qualities,
|
2023-05-29 09:20:07 -06:00
|
|
|
traverse_obj,
|
2015-10-02 10:29:15 -06:00
|
|
|
unified_strdate,
|
2024-05-26 13:27:21 -06:00
|
|
|
xpath_text,
|
2015-08-12 08:59:04 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class EuropaIE(InfoExtractor):
|
2024-03-08 17:02:45 -07:00
|
|
|
_WORKING = False
|
2015-10-02 11:22:53 -06:00
|
|
|
_VALID_URL = r'https?://ec\.europa\.eu/avservices/(?:video/player|audio/audioDetails)\.cfm\?.*?\bref=(?P<id>[A-Za-z0-9-]+)'
|
2015-10-02 10:29:15 -06:00
|
|
|
_TESTS = [{
|
2015-08-12 08:59:04 -06:00
|
|
|
'url': 'http://ec.europa.eu/avservices/video/player.cfm?ref=I107758',
|
2015-10-02 10:29:15 -06:00
|
|
|
'md5': '574f080699ddd1e19a675b0ddf010371',
|
2015-08-12 08:59:04 -06:00
|
|
|
'info_dict': {
|
|
|
|
'id': 'I107758',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'TRADE - Wikileaks on TTIP',
|
|
|
|
'description': 'NEW LIVE EC Midday press briefing of 11/08/2015',
|
2017-01-02 05:08:07 -07:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2015-10-02 10:29:15 -06:00
|
|
|
'upload_date': '20150811',
|
|
|
|
'duration': 34,
|
|
|
|
'view_count': int,
|
|
|
|
'formats': 'mincount:3',
|
2024-06-11 17:09:58 -06:00
|
|
|
},
|
2015-10-02 10:29:15 -06:00
|
|
|
}, {
|
|
|
|
'url': 'http://ec.europa.eu/avservices/video/player.cfm?sitelang=en&ref=I107786',
|
|
|
|
'only_matching': True,
|
2015-10-02 11:22:53 -06:00
|
|
|
}, {
|
|
|
|
'url': 'http://ec.europa.eu/avservices/audio/audioDetails.cfm?ref=I-109295&sitelang=en',
|
|
|
|
'only_matching': True,
|
2015-10-02 10:29:15 -06:00
|
|
|
}]
|
2015-08-12 08:59:04 -06:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
2015-10-02 10:29:15 -06:00
|
|
|
playlist = self._download_xml(
|
2024-06-11 17:09:58 -06:00
|
|
|
f'http://ec.europa.eu/avservices/video/player/playlist.cfm?ID={video_id}', video_id)
|
2015-08-12 08:59:04 -06:00
|
|
|
|
2015-10-02 10:29:15 -06:00
|
|
|
def get_item(type_, preference):
|
|
|
|
items = {}
|
2024-06-11 17:09:58 -06:00
|
|
|
for item in playlist.findall(f'./info/{type_}/item'):
|
2015-10-02 10:29:15 -06:00
|
|
|
lang, label = xpath_text(item, 'lg', default=None), xpath_text(item, 'label', default=None)
|
|
|
|
if lang and label:
|
|
|
|
items[lang] = label.strip()
|
|
|
|
for p in preference:
|
|
|
|
if items.get(p):
|
|
|
|
return items[p]
|
2015-08-12 08:59:04 -06:00
|
|
|
|
2021-08-22 13:02:00 -06:00
|
|
|
query = parse_qs(url)
|
2015-10-02 10:29:15 -06:00
|
|
|
preferred_lang = query.get('sitelang', ('en', ))[0]
|
2015-08-12 08:59:04 -06:00
|
|
|
|
2015-10-02 10:29:15 -06:00
|
|
|
preferred_langs = orderedSet((preferred_lang, 'en', 'int'))
|
2015-08-12 08:59:04 -06:00
|
|
|
|
2015-10-02 10:29:15 -06:00
|
|
|
title = get_item('title', preferred_langs) or video_id
|
|
|
|
description = get_item('description', preferred_langs)
|
2020-11-21 07:50:42 -07:00
|
|
|
thumbnail = xpath_text(playlist, './info/thumburl', 'thumbnail')
|
2015-10-02 10:29:15 -06:00
|
|
|
upload_date = unified_strdate(xpath_text(playlist, './info/date', 'upload date'))
|
|
|
|
duration = parse_duration(xpath_text(playlist, './info/duration', 'duration'))
|
2015-10-02 14:40:35 -06:00
|
|
|
view_count = int_or_none(xpath_text(playlist, './info/views', 'views'))
|
2015-08-12 08:59:04 -06:00
|
|
|
|
2015-10-02 10:29:15 -06:00
|
|
|
language_preference = qualities(preferred_langs[::-1])
|
2015-08-12 08:59:04 -06:00
|
|
|
|
2015-10-02 10:29:15 -06:00
|
|
|
formats = []
|
|
|
|
for file_ in playlist.findall('./files/file'):
|
|
|
|
video_url = xpath_text(file_, './url')
|
|
|
|
if not video_url:
|
|
|
|
continue
|
|
|
|
lang = xpath_text(file_, './lg')
|
|
|
|
formats.append({
|
|
|
|
'url': video_url,
|
|
|
|
'format_id': lang,
|
|
|
|
'format_note': xpath_text(file_, './lglabel'),
|
2024-06-11 17:09:58 -06:00
|
|
|
'language_preference': language_preference(lang),
|
2015-10-02 10:29:15 -06:00
|
|
|
})
|
2015-08-12 08:59:04 -06:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
2015-10-02 10:29:15 -06:00
|
|
|
'title': title,
|
|
|
|
'description': description,
|
2020-11-21 07:50:42 -07:00
|
|
|
'thumbnail': thumbnail,
|
2015-10-02 10:29:15 -06:00
|
|
|
'upload_date': upload_date,
|
|
|
|
'duration': duration,
|
|
|
|
'view_count': view_count,
|
2024-06-11 17:09:58 -06:00
|
|
|
'formats': formats,
|
2015-08-12 08:59:04 -06:00
|
|
|
}
|
2022-12-10 01:44:43 -07:00
|
|
|
|
|
|
|
|
|
|
|
class EuroParlWebstreamIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'''(?x)
|
2024-05-11 15:50:59 -06:00
|
|
|
https?://multimedia\.europarl\.europa\.eu/
|
|
|
|
(?:\w+/)?webstreaming/(?:[\w-]+_)?(?P<id>[\w-]+)
|
2022-12-10 01:44:43 -07:00
|
|
|
'''
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://multimedia.europarl.europa.eu/pl/webstreaming/plenary-session_20220914-0900-PLENARY',
|
|
|
|
'info_dict': {
|
2023-05-29 09:20:07 -06:00
|
|
|
'id': '62388b15-d85b-4add-99aa-ba12ccf64f0d',
|
2024-05-11 15:50:59 -06:00
|
|
|
'display_id': '20220914-0900-PLENARY',
|
2022-12-10 01:44:43 -07:00
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Plenary session',
|
2023-05-29 09:20:07 -06:00
|
|
|
'release_timestamp': 1663139069,
|
2022-12-10 01:44:43 -07:00
|
|
|
'release_date': '20220914',
|
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
2024-06-11 17:09:58 -06:00
|
|
|
},
|
2022-12-10 01:44:43 -07:00
|
|
|
}, {
|
2023-05-29 09:20:07 -06:00
|
|
|
# live webstream
|
|
|
|
'url': 'https://multimedia.europarl.europa.eu/en/webstreaming/euroscola_20221115-1000-SPECIAL-EUROSCOLA',
|
2022-12-10 01:44:43 -07:00
|
|
|
'info_dict': {
|
|
|
|
'ext': 'mp4',
|
2023-05-29 09:20:07 -06:00
|
|
|
'id': '510eda7f-ba72-161b-7ee7-0e836cd2e715',
|
|
|
|
'release_timestamp': 1668502800,
|
|
|
|
'title': 'Euroscola 2022-11-15 19:21',
|
|
|
|
'release_date': '20221115',
|
|
|
|
'live_status': 'is_live',
|
2022-12-10 01:44:43 -07:00
|
|
|
},
|
2024-06-11 17:09:58 -06:00
|
|
|
'skip': 'not live anymore',
|
2022-12-10 01:44:43 -07:00
|
|
|
}, {
|
2023-05-29 09:20:07 -06:00
|
|
|
'url': 'https://multimedia.europarl.europa.eu/en/webstreaming/committee-on-culture-and-education_20230301-1130-COMMITTEE-CULT',
|
2022-12-10 01:44:43 -07:00
|
|
|
'info_dict': {
|
2023-05-29 09:20:07 -06:00
|
|
|
'id': '7355662c-8eac-445e-4bb9-08db14b0ddd7',
|
2024-05-11 15:50:59 -06:00
|
|
|
'display_id': '20230301-1130-COMMITTEE-CULT',
|
2022-12-10 01:44:43 -07:00
|
|
|
'ext': 'mp4',
|
2023-05-29 09:20:07 -06:00
|
|
|
'release_date': '20230301',
|
|
|
|
'title': 'Committee on Culture and Education',
|
|
|
|
'release_timestamp': 1677666641,
|
2024-06-11 17:09:58 -06:00
|
|
|
},
|
2022-12-10 01:44:43 -07:00
|
|
|
}, {
|
2023-05-29 09:20:07 -06:00
|
|
|
# live stream
|
|
|
|
'url': 'https://multimedia.europarl.europa.eu/en/webstreaming/committee-on-environment-public-health-and-food-safety_20230524-0900-COMMITTEE-ENVI',
|
2022-12-10 01:44:43 -07:00
|
|
|
'info_dict': {
|
2023-05-29 09:20:07 -06:00
|
|
|
'id': 'e4255f56-10aa-4b3c-6530-08db56d5b0d9',
|
2022-12-10 01:44:43 -07:00
|
|
|
'ext': 'mp4',
|
2023-05-29 09:20:07 -06:00
|
|
|
'release_date': '20230524',
|
|
|
|
'title': r're:Committee on Environment, Public Health and Food Safety \d{4}-\d{2}-\d{2}\s\d{2}:\d{2}',
|
|
|
|
'release_timestamp': 1684911541,
|
2022-12-10 01:44:43 -07:00
|
|
|
'live_status': 'is_live',
|
|
|
|
},
|
2024-06-11 17:09:58 -06:00
|
|
|
'skip': 'Not live anymore',
|
2024-05-11 15:50:59 -06:00
|
|
|
}, {
|
|
|
|
'url': 'https://multimedia.europarl.europa.eu/en/webstreaming/20240320-1345-SPECIAL-PRESSER',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'c1f11567-5b52-470a-f3e1-08dc3c216ace',
|
|
|
|
'display_id': '20240320-1345-SPECIAL-PRESSER',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'release_date': '20240320',
|
|
|
|
'title': 'md5:7c6c814cac55dea5e2d87bf8d3db2234',
|
|
|
|
'release_timestamp': 1710939767,
|
2024-06-11 17:09:58 -06:00
|
|
|
},
|
2024-05-11 15:50:59 -06:00
|
|
|
}, {
|
|
|
|
'url': 'https://multimedia.europarl.europa.eu/webstreaming/briefing-for-media-on-2024-european-elections_20240429-1000-SPECIAL-OTHER',
|
|
|
|
'only_matching': True,
|
2022-12-10 01:44:43 -07:00
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
display_id = self._match_id(url)
|
2023-05-29 09:20:07 -06:00
|
|
|
webpage = self._download_webpage(url, display_id)
|
|
|
|
|
|
|
|
webpage_nextjs = self._search_nextjs_data(webpage, display_id)['props']['pageProps']
|
2022-12-10 01:44:43 -07:00
|
|
|
|
|
|
|
json_info = self._download_json(
|
2023-05-29 09:20:07 -06:00
|
|
|
'https://acs-api.europarl.connectedviews.eu/api/FullMeeting', display_id,
|
2022-12-10 01:44:43 -07:00
|
|
|
query={
|
2023-05-29 09:20:07 -06:00
|
|
|
'api-version': 1.0,
|
|
|
|
'tenantId': 'bae646ca-1fc8-4363-80ba-2c04f06b4968',
|
2024-06-11 17:09:58 -06:00
|
|
|
'externalReference': display_id,
|
2022-12-10 01:44:43 -07:00
|
|
|
})
|
|
|
|
|
2023-05-29 09:20:07 -06:00
|
|
|
formats, subtitles = [], {}
|
|
|
|
for hls_url in traverse_obj(json_info, ((('meetingVideo'), ('meetingVideos', ...)), 'hlsUrl')):
|
|
|
|
fmt, subs = self._extract_m3u8_formats_and_subtitles(hls_url, display_id)
|
|
|
|
formats.extend(fmt)
|
|
|
|
self._merge_subtitles(subs, target=subtitles)
|
2022-12-10 01:44:43 -07:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': json_info['id'],
|
2024-05-11 15:50:59 -06:00
|
|
|
'display_id': display_id,
|
2023-05-29 09:20:07 -06:00
|
|
|
'title': traverse_obj(webpage_nextjs, (('mediaItem', 'title'), ('title', )), get_all=False),
|
2022-12-10 01:44:43 -07:00
|
|
|
'formats': formats,
|
|
|
|
'subtitles': subtitles,
|
2023-05-29 09:20:07 -06:00
|
|
|
'release_timestamp': parse_iso8601(json_info.get('startDateTime')),
|
2024-06-11 17:09:58 -06:00
|
|
|
'is_live': traverse_obj(webpage_nextjs, ('mediaItem', 'mediaSubType')) == 'Live',
|
2022-12-10 01:44:43 -07:00
|
|
|
}
|