[ie/facebook] Support more groups URLs (#11576)
[yt-dlp3.git] / yt_dlp / extractor / ccc.py
blob1d781cc477e927da4559d76445655f9afe7f4866
1 from .common import InfoExtractor
2 from ..utils import (
3 int_or_none,
4 parse_iso8601,
5 try_get,
6 url_or_none,
10 class CCCIE(InfoExtractor):
11 IE_NAME = 'media.ccc.de'
12 _VALID_URL = r'https?://(?:www\.)?media\.ccc\.de/v/(?P<id>[^/?#&]+)'
14 _TESTS = [{
15 'url': 'https://media.ccc.de/v/30C3_-_5443_-_en_-_saal_g_-_201312281830_-_introduction_to_processor_design_-_byterazor#video',
16 'md5': '3a1eda8f3a29515d27f5adb967d7e740',
17 'info_dict': {
18 'id': '1839',
19 'ext': 'mp4',
20 'title': 'Introduction to Processor Design',
21 'creator': 'byterazor',
22 'description': 'md5:df55f6d073d4ceae55aae6f2fd98a0ac',
23 'thumbnail': r're:^https?://.*\.jpg$',
24 'upload_date': '20131228',
25 'timestamp': 1388188800,
26 'duration': 3710,
27 'tags': list,
29 }, {
30 'url': 'https://media.ccc.de/v/32c3-7368-shopshifting#download',
31 'only_matching': True,
34 def _real_extract(self, url):
35 display_id = self._match_id(url)
36 webpage = self._download_webpage(url, display_id)
37 event_id = self._search_regex(r"data-id='(\d+)'", webpage, 'event id')
38 event_data = self._download_json(f'https://media.ccc.de/public/events/{event_id}', event_id)
40 formats = []
41 for recording in event_data.get('recordings', []):
42 recording_url = recording.get('recording_url')
43 if not recording_url:
44 continue
45 language = recording.get('language')
46 folder = recording.get('folder')
47 format_id = None
48 if language:
49 format_id = language
50 if folder:
51 if language:
52 format_id += '-' + folder
53 else:
54 format_id = folder
55 vcodec = 'h264' if 'h264' in folder else (
56 'none' if folder in ('mp3', 'opus') else None
58 formats.append({
59 'format_id': format_id,
60 'url': recording_url,
61 'width': int_or_none(recording.get('width')),
62 'height': int_or_none(recording.get('height')),
63 'filesize': int_or_none(recording.get('size'), invscale=1024 * 1024),
64 'language': language,
65 'vcodec': vcodec,
68 return {
69 'id': event_id,
70 'display_id': display_id,
71 'title': event_data['title'],
72 'creator': try_get(event_data, lambda x: ', '.join(x['persons'])),
73 'description': event_data.get('description'),
74 'thumbnail': event_data.get('thumb_url'),
75 'timestamp': parse_iso8601(event_data.get('date')),
76 'duration': int_or_none(event_data.get('length')),
77 'view_count': int_or_none(event_data.get('view_count')),
78 'tags': event_data.get('tags'),
79 'formats': formats,
83 class CCCPlaylistIE(InfoExtractor):
84 IE_NAME = 'media.ccc.de:lists'
85 _VALID_URL = r'https?://(?:www\.)?media\.ccc\.de/c/(?P<id>[^/?#&]+)'
86 _TESTS = [{
87 'url': 'https://media.ccc.de/c/30c3',
88 'info_dict': {
89 'title': '30C3',
90 'id': '30c3',
92 'playlist_count': 135,
93 }, {
94 'url': 'https://media.ccc.de/c/DS2023',
95 'info_dict': {
96 'title': 'Datenspuren 2023',
97 'id': 'DS2023',
99 'playlist_count': 37,
102 def _real_extract(self, url):
103 playlist_id = self._match_id(url)
105 conf = self._download_json(
106 'https://media.ccc.de/public/conferences/' + playlist_id,
107 playlist_id)
109 entries = []
110 for e in conf['events']:
111 event_url = url_or_none(e.get('frontend_link'))
112 if event_url:
113 entries.append(self.url_result(event_url, ie=CCCIE.ie_key()))
115 return self.playlist_result(entries, playlist_id, conf.get('title'))