]>
Commit | Line | Data |
---|---|---|
a14001a5 DR |
1 | from __future__ import unicode_literals |
2 | ||
be069839 RA |
3 | import re |
4 | ||
a14001a5 | 5 | from .common import InfoExtractor |
be069839 | 6 | from ..utils import int_or_none |
a14001a5 DR |
7 | |
8 | ||
9 | class TwentyThreeVideoIE(InfoExtractor): | |
10 | IE_NAME = '23video' | |
8bdd16b4 | 11 | _VALID_URL = r'https?://(?P<domain>[^.]+\.(?:twentythree\.net|23video\.com|filmweb\.no))/v\.ihtml/player\.html\?(?P<query>.*?\bphoto(?:_|%5f)id=(?P<id>\d+).*)' |
12 | _TESTS = [{ | |
be069839 RA |
13 | 'url': 'https://video.twentythree.net/v.ihtml/player.html?showDescriptions=0&source=site&photo%5fid=20448876&autoPlay=1', |
14 | 'md5': '75fcf216303eb1dae9920d651f85ced4', | |
15 | 'info_dict': { | |
16 | 'id': '20448876', | |
17 | 'ext': 'mp4', | |
18 | 'title': 'Video Marketing Minute: Personalized Video', | |
19 | 'timestamp': 1513855354, | |
20 | 'upload_date': '20171221', | |
21 | 'uploader_id': '12258964', | |
22 | 'uploader': 'Rasmus Bysted', | |
a14001a5 | 23 | } |
8bdd16b4 | 24 | }, { |
25 | 'url': 'https://bonnier-publications-danmark.23video.com/v.ihtml/player.html?token=f0dc46476e06e13afd5a1f84a29e31e8&source=embed&photo%5fid=36137620', | |
26 | 'only_matching': True, | |
27 | }] | |
a14001a5 | 28 | |
be069839 RA |
29 | def _real_extract(self, url): |
30 | domain, query, photo_id = re.match(self._VALID_URL, url).groups() | |
8bdd16b4 | 31 | base_url = 'https://%s' % domain |
be069839 RA |
32 | photo_data = self._download_json( |
33 | base_url + '/api/photo/list?' + query, photo_id, query={ | |
34 | 'format': 'json', | |
35 | }, transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'photo data'))['photo'] | |
36 | title = photo_data['title'] | |
a14001a5 DR |
37 | |
38 | formats = [] | |
be069839 RA |
39 | |
40 | audio_path = photo_data.get('audio_download') | |
41 | if audio_path: | |
a14001a5 | 42 | formats.append({ |
be069839 RA |
43 | 'format_id': 'audio', |
44 | 'url': base_url + audio_path, | |
45 | 'filesize': int_or_none(photo_data.get('audio_size')), | |
46 | 'vcodec': 'none', | |
47 | }) | |
48 | ||
49 | def add_common_info_to_list(l, template, id_field, id_value): | |
50 | f_base = template % id_value | |
51 | f_path = photo_data.get(f_base + 'download') | |
52 | if not f_path: | |
53 | return | |
54 | l.append({ | |
55 | id_field: id_value, | |
56 | 'url': base_url + f_path, | |
57 | 'width': int_or_none(photo_data.get(f_base + 'width')), | |
58 | 'height': int_or_none(photo_data.get(f_base + 'height')), | |
59 | 'filesize': int_or_none(photo_data.get(f_base + 'size')), | |
a14001a5 DR |
60 | }) |
61 | ||
be069839 RA |
62 | for f in ('mobile_high', 'medium', 'hd', '1080p', '4k'): |
63 | add_common_info_to_list(formats, 'video_%s_', 'format_id', f) | |
a14001a5 | 64 | |
be069839 RA |
65 | thumbnails = [] |
66 | for t in ('quad16', 'quad50', 'quad75', 'quad100', 'small', 'portrait', 'standard', 'medium', 'large', 'original'): | |
67 | add_common_info_to_list(thumbnails, '%s_', 'id', t) | |
68 | ||
69 | return { | |
70 | 'id': photo_id, | |
71 | 'title': title, | |
72 | 'timestamp': int_or_none(photo_data.get('creation_date_epoch')), | |
73 | 'duration': int_or_none(photo_data.get('video_length')), | |
74 | 'view_count': int_or_none(photo_data.get('view_count')), | |
75 | 'comment_count': int_or_none(photo_data.get('number_of_comments')), | |
76 | 'uploader_id': photo_data.get('user_id'), | |
77 | 'uploader': photo_data.get('display_name'), | |
78 | 'thumbnails': thumbnails, | |
79 | 'formats': formats, | |
80 | } |