]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/digiteka.py
[extractor/rtvsl] Add extractor (#2586)
[yt-dlp.git] / yt_dlp / extractor / digiteka.py
CommitLineData
b30ef07c
S
1import re
2
3073a6d5 3from .common import InfoExtractor
6aeba407 4from ..utils import int_or_none
3073a6d5
S
5
6
aecfcd4e 7class DigitekaIE(InfoExtractor):
3da39996 8 _VALID_URL = r'''(?x)
942d4619 9 https?://(?:www\.)?(?:digiteka\.net|ultimedia\.com)/
3da39996 10 (?:
11 deliver/
12 (?P<embed_type>
13 generic|
14 musique
15 )
16 (?:/[^/]+)*/
17 (?:
18 src|
19 article
20 )|
21 default/index/video
22 (?P<site_type>
23 generic|
24 music
25 )
26 /id
27 )/(?P<id>[\d+a-z]+)'''
3073a6d5
S
28 _TESTS = [{
29 # news
3da39996 30 'url': 'https://www.ultimedia.com/default/index/videogeneric/id/s8uk0r',
3073a6d5
S
31 'md5': '276a0e49de58c7e85d32b057837952a2',
32 'info_dict': {
33 'id': 's8uk0r',
34 'ext': 'mp4',
35 'title': 'Loi sur la fin de vie: le texte prévoit un renforcement des directives anticipées',
ec85ded8 36 'thumbnail': r're:^https?://.*\.jpg',
6aeba407 37 'duration': 74,
3073a6d5 38 'upload_date': '20150317',
6aeba407 39 'timestamp': 1426604939,
40 'uploader_id': '3fszv',
3073a6d5
S
41 },
42 }, {
43 # music
3da39996 44 'url': 'https://www.ultimedia.com/default/index/videomusic/id/xvpfp8',
3073a6d5
S
45 'md5': '2ea3513813cf230605c7e2ffe7eca61c',
46 'info_dict': {
47 'id': 'xvpfp8',
48 'ext': 'mp4',
6aeba407 49 'title': 'Two - C\'est La Vie (clip)',
ec85ded8 50 'thumbnail': r're:^https?://.*\.jpg',
6aeba407 51 'duration': 233,
3073a6d5 52 'upload_date': '20150224',
6aeba407 53 'timestamp': 1424760500,
54 'uploader_id': '3rfzk',
3073a6d5 55 },
942d4619
S
56 }, {
57 'url': 'https://www.digiteka.net/deliver/generic/iframe/mdtk/01637594/src/lqm3kl/zone/1/showtitle/1/autoplay/yes',
58 'only_matching': True,
3073a6d5
S
59 }]
60
6aeba407 61 @staticmethod
62 def _extract_url(webpage):
63 mobj = re.search(
64 r'<(?:iframe|script)[^>]+src=["\'](?P<url>(?:https?:)?//(?:www\.)?ultimedia\.com/deliver/(?:generic|musique)(?:/[^/]+)*/(?:src|article)/[\d+a-z]+)',
65 webpage)
66 if mobj:
67 return mobj.group('url')
3073a6d5 68
6aeba407 69 def _real_extract(self, url):
5ad28e7f 70 mobj = self._match_valid_url(url)
3da39996 71 video_id = mobj.group('id')
72 video_type = mobj.group('embed_type') or mobj.group('site_type')
73 if video_type == 'music':
74 video_type = 'musique'
3073a6d5 75
6aeba407 76 deliver_info = self._download_json(
77 'http://www.ultimedia.com/deliver/video?video=%s&topic=%s' % (video_id, video_type),
78 video_id)
3073a6d5 79
6aeba407 80 yt_id = deliver_info.get('yt_id')
81 if yt_id:
82 return self.url_result(yt_id, 'Youtube')
73900846 83
6aeba407 84 jwconf = deliver_info['jwconf']
3073a6d5 85
b30ef07c 86 formats = []
6aeba407 87 for source in jwconf['playlist'][0]['sources']:
b30ef07c 88 formats.append({
6aeba407 89 'url': source['file'],
90 'format_id': source.get('label'),
b30ef07c 91 })
3073a6d5 92
6aeba407 93 self._sort_formats(formats)
3073a6d5 94
6aeba407 95 title = deliver_info['title']
96 thumbnail = jwconf.get('image')
97 duration = int_or_none(deliver_info.get('duration'))
98 timestamp = int_or_none(deliver_info.get('release_time'))
99 uploader_id = deliver_info.get('owner_id')
3073a6d5
S
100
101 return {
102 'id': video_id,
103 'title': title,
3073a6d5 104 'thumbnail': thumbnail,
6aeba407 105 'duration': duration,
106 'timestamp': timestamp,
107 'uploader_id': uploader_id,
3073a6d5
S
108 'formats': formats,
109 }