[ie/twitter:spaces] Support video spaces (#10789)
[yt-dlp3.git] / yt_dlp / extractor / digiteka.py
blobe56ec63e867b3776c3b7ac1a0bf067576aae42cf
1 from .common import InfoExtractor
2 from ..utils import int_or_none
5 class DigitekaIE(InfoExtractor):
6 _VALID_URL = r'''(?x)
7 https?://(?:www\.)?(?:digiteka\.net|ultimedia\.com)/
8 (?:
9 deliver/
10 (?P<embed_type>
11 generic|
12 musique
14 (?:/[^/]+)*/
15 (?:
16 src|
17 article
19 default/index/video
20 (?P<site_type>
21 generic|
22 music
24 /id
25 )/(?P<id>[\d+a-z]+)'''
26 _EMBED_REGEX = [r'<(?:iframe|script)[^>]+src=["\'](?P<url>(?:https?:)?//(?:www\.)?ultimedia\.com/deliver/(?:generic|musique)(?:/[^/]+)*/(?:src|article)/[\d+a-z]+)']
27 _TESTS = [{
28 # news
29 'url': 'https://www.ultimedia.com/default/index/videogeneric/id/s8uk0r',
30 'md5': '276a0e49de58c7e85d32b057837952a2',
31 'info_dict': {
32 'id': 's8uk0r',
33 'ext': 'mp4',
34 'title': 'Loi sur la fin de vie: le texte prévoit un renforcement des directives anticipées',
35 'thumbnail': r're:^https?://.*\.jpg',
36 'duration': 74,
37 'upload_date': '20150317',
38 'timestamp': 1426604939,
39 'uploader_id': '3fszv',
41 }, {
42 # music
43 'url': 'https://www.ultimedia.com/default/index/videomusic/id/xvpfp8',
44 'md5': '2ea3513813cf230605c7e2ffe7eca61c',
45 'info_dict': {
46 'id': 'xvpfp8',
47 'ext': 'mp4',
48 'title': 'Two - C\'est La Vie (clip)',
49 'thumbnail': r're:^https?://.*\.jpg',
50 'duration': 233,
51 'upload_date': '20150224',
52 'timestamp': 1424760500,
53 'uploader_id': '3rfzk',
55 }, {
56 'url': 'https://www.digiteka.net/deliver/generic/iframe/mdtk/01637594/src/lqm3kl/zone/1/showtitle/1/autoplay/yes',
57 'only_matching': True,
60 def _real_extract(self, url):
61 mobj = self._match_valid_url(url)
62 video_id = mobj.group('id')
63 video_type = mobj.group('embed_type') or mobj.group('site_type')
64 if video_type == 'music':
65 video_type = 'musique'
67 deliver_info = self._download_json(
68 f'http://www.ultimedia.com/deliver/video?video={video_id}&topic={video_type}',
69 video_id)
71 yt_id = deliver_info.get('yt_id')
72 if yt_id:
73 return self.url_result(yt_id, 'Youtube')
75 jwconf = deliver_info['jwconf']
77 formats = []
78 for source in jwconf['playlist'][0]['sources']:
79 formats.append({
80 'url': source['file'],
81 'format_id': source.get('label'),
84 title = deliver_info['title']
85 thumbnail = jwconf.get('image')
86 duration = int_or_none(deliver_info.get('duration'))
87 timestamp = int_or_none(deliver_info.get('release_time'))
88 uploader_id = deliver_info.get('owner_id')
90 return {
91 'id': video_id,
92 'title': title,
93 'thumbnail': thumbnail,
94 'duration': duration,
95 'timestamp': timestamp,
96 'uploader_id': uploader_id,
97 'formats': formats,