]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/digiteka.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / digiteka.py
CommitLineData
3073a6d5 1from .common import InfoExtractor
6aeba407 2from ..utils import int_or_none
3073a6d5
S
3
4
aecfcd4e 5class DigitekaIE(InfoExtractor):
3da39996 6 _VALID_URL = r'''(?x)
942d4619 7 https?://(?:www\.)?(?:digiteka\.net|ultimedia\.com)/
3da39996 8 (?:
9 deliver/
10 (?P<embed_type>
11 generic|
12 musique
13 )
14 (?:/[^/]+)*/
15 (?:
16 src|
17 article
18 )|
19 default/index/video
20 (?P<site_type>
21 generic|
22 music
23 )
24 /id
25 )/(?P<id>[\d+a-z]+)'''
bfd973ec 26 _EMBED_REGEX = [r'<(?:iframe|script)[^>]+src=["\'](?P<url>(?:https?:)?//(?:www\.)?ultimedia\.com/deliver/(?:generic|musique)(?:/[^/]+)*/(?:src|article)/[\d+a-z]+)']
3073a6d5
S
27 _TESTS = [{
28 # news
3da39996 29 'url': 'https://www.ultimedia.com/default/index/videogeneric/id/s8uk0r',
3073a6d5
S
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',
ec85ded8 35 'thumbnail': r're:^https?://.*\.jpg',
6aeba407 36 'duration': 74,
3073a6d5 37 'upload_date': '20150317',
6aeba407 38 'timestamp': 1426604939,
39 'uploader_id': '3fszv',
3073a6d5
S
40 },
41 }, {
42 # music
3da39996 43 'url': 'https://www.ultimedia.com/default/index/videomusic/id/xvpfp8',
3073a6d5
S
44 'md5': '2ea3513813cf230605c7e2ffe7eca61c',
45 'info_dict': {
46 'id': 'xvpfp8',
47 'ext': 'mp4',
6aeba407 48 'title': 'Two - C\'est La Vie (clip)',
ec85ded8 49 'thumbnail': r're:^https?://.*\.jpg',
6aeba407 50 'duration': 233,
3073a6d5 51 'upload_date': '20150224',
6aeba407 52 'timestamp': 1424760500,
53 'uploader_id': '3rfzk',
3073a6d5 54 },
942d4619
S
55 }, {
56 'url': 'https://www.digiteka.net/deliver/generic/iframe/mdtk/01637594/src/lqm3kl/zone/1/showtitle/1/autoplay/yes',
57 'only_matching': True,
3073a6d5
S
58 }]
59
6aeba407 60 def _real_extract(self, url):
5ad28e7f 61 mobj = self._match_valid_url(url)
3da39996 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'
3073a6d5 66
6aeba407 67 deliver_info = self._download_json(
add96eb9 68 f'http://www.ultimedia.com/deliver/video?video={video_id}&topic={video_type}',
6aeba407 69 video_id)
3073a6d5 70
6aeba407 71 yt_id = deliver_info.get('yt_id')
72 if yt_id:
73 return self.url_result(yt_id, 'Youtube')
73900846 74
6aeba407 75 jwconf = deliver_info['jwconf']
3073a6d5 76
b30ef07c 77 formats = []
6aeba407 78 for source in jwconf['playlist'][0]['sources']:
b30ef07c 79 formats.append({
6aeba407 80 'url': source['file'],
81 'format_id': source.get('label'),
b30ef07c 82 })
3073a6d5 83
6aeba407 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')
3073a6d5
S
89
90 return {
91 'id': video_id,
92 'title': title,
3073a6d5 93 'thumbnail': thumbnail,
6aeba407 94 'duration': duration,
95 'timestamp': timestamp,
96 'uploader_id': uploader_id,
3073a6d5
S
97 'formats': formats,
98 }