]>
Commit | Line | Data |
---|---|---|
39ed931e | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
5 | from ..compat import ( | |
6 | compat_parse_qs, | |
7 | compat_urllib_parse_urlparse, | |
8 | ) | |
9 | from ..utils import ( | |
10 | float_or_none, | |
11 | int_or_none, | |
12 | parse_iso8601, | |
13 | remove_start, | |
14 | ) | |
15 | ||
16 | ||
17 | class ArnesIE(InfoExtractor): | |
18 | IE_NAME = 'video.arnes.si' | |
19 | IE_DESC = 'Arnes Video' | |
20 | _VALID_URL = r'https?://video\.arnes\.si/(?:[a-z]{2}/)?(?:watch|embed|api/(?:asset|public/video))/(?P<id>[0-9a-zA-Z]{12})' | |
21 | _TESTS = [{ | |
22 | 'url': 'https://video.arnes.si/watch/a1qrWTOQfVoU?t=10', | |
23 | 'md5': '4d0f4d0a03571b33e1efac25fd4a065d', | |
24 | 'info_dict': { | |
25 | 'id': 'a1qrWTOQfVoU', | |
26 | 'ext': 'mp4', | |
27 | 'title': 'Linearna neodvisnost, definicija', | |
28 | 'description': 'Linearna neodvisnost, definicija', | |
29 | 'license': 'PRIVATE', | |
30 | 'creator': 'Polona Oblak', | |
31 | 'timestamp': 1585063725, | |
32 | 'upload_date': '20200324', | |
33 | 'channel': 'Polona Oblak', | |
34 | 'channel_id': 'q6pc04hw24cj', | |
35 | 'channel_url': 'https://video.arnes.si/?channel=q6pc04hw24cj', | |
36 | 'duration': 596.75, | |
37 | 'view_count': int, | |
38 | 'tags': ['linearna_algebra'], | |
39 | 'start_time': 10, | |
40 | } | |
41 | }, { | |
42 | 'url': 'https://video.arnes.si/api/asset/s1YjnV7hadlC/play.mp4', | |
43 | 'only_matching': True, | |
44 | }, { | |
45 | 'url': 'https://video.arnes.si/embed/s1YjnV7hadlC', | |
46 | 'only_matching': True, | |
47 | }, { | |
48 | 'url': 'https://video.arnes.si/en/watch/s1YjnV7hadlC', | |
49 | 'only_matching': True, | |
50 | }, { | |
51 | 'url': 'https://video.arnes.si/embed/s1YjnV7hadlC?t=123&hideRelated=1', | |
52 | 'only_matching': True, | |
53 | }, { | |
54 | 'url': 'https://video.arnes.si/api/public/video/s1YjnV7hadlC', | |
55 | 'only_matching': True, | |
56 | }] | |
57 | _BASE_URL = 'https://video.arnes.si' | |
58 | ||
59 | def _real_extract(self, url): | |
60 | video_id = self._match_id(url) | |
61 | ||
62 | video = self._download_json( | |
63 | self._BASE_URL + '/api/public/video/' + video_id, video_id)['data'] | |
64 | title = video['title'] | |
65 | ||
66 | formats = [] | |
67 | for media in (video.get('media') or []): | |
68 | media_url = media.get('url') | |
69 | if not media_url: | |
70 | continue | |
71 | formats.append({ | |
72 | 'url': self._BASE_URL + media_url, | |
73 | 'format_id': remove_start(media.get('format'), 'FORMAT_'), | |
74 | 'format_note': media.get('formatTranslation'), | |
75 | 'width': int_or_none(media.get('width')), | |
76 | 'height': int_or_none(media.get('height')), | |
77 | }) | |
78 | self._sort_formats(formats) | |
79 | ||
80 | channel = video.get('channel') or {} | |
81 | channel_id = channel.get('url') | |
82 | thumbnail = video.get('thumbnailUrl') | |
83 | ||
84 | return { | |
85 | 'id': video_id, | |
86 | 'title': title, | |
87 | 'formats': formats, | |
88 | 'thumbnail': self._BASE_URL + thumbnail, | |
89 | 'description': video.get('description'), | |
90 | 'license': video.get('license'), | |
91 | 'creator': video.get('author'), | |
92 | 'timestamp': parse_iso8601(video.get('creationTime')), | |
93 | 'channel': channel.get('name'), | |
94 | 'channel_id': channel_id, | |
95 | 'channel_url': self._BASE_URL + '/?channel=' + channel_id if channel_id else None, | |
96 | 'duration': float_or_none(video.get('duration'), 1000), | |
97 | 'view_count': int_or_none(video.get('views')), | |
98 | 'tags': video.get('hashtags'), | |
99 | 'start_time': int_or_none(compat_parse_qs( | |
100 | compat_urllib_parse_urlparse(url).query).get('t', [None])[0]), | |
101 | } |