]>
Commit | Line | Data |
---|---|---|
1 | # coding: utf-8 | |
2 | from __future__ import unicode_literals | |
3 | ||
4 | ||
5 | from .common import InfoExtractor | |
6 | from ..utils import ( | |
7 | clean_html, | |
8 | compat_str, | |
9 | int_or_none, | |
10 | parse_iso8601, | |
11 | ) | |
12 | ||
13 | ||
14 | class LnkGoIE(InfoExtractor): | |
15 | _VALID_URL = r'https?://(?:www\.)?lnk(?:go)?\.(?:alfa\.)?lt/(?:visi-video/[^/]+|video)/(?P<id>[A-Za-z0-9-]+)(?:/(?P<episode_id>\d+))?' | |
16 | _TESTS = [{ | |
17 | 'url': 'http://www.lnkgo.lt/visi-video/aktualai-pratesimas/ziurek-putka-trys-klausimai', | |
18 | 'info_dict': { | |
19 | 'id': '10809', | |
20 | 'ext': 'mp4', | |
21 | 'title': "Put'ka: Trys Klausimai", | |
22 | 'upload_date': '20161216', | |
23 | 'description': 'Seniai matytas Put’ka užduoda tris klausimėlius. Pabandykime surasti atsakymus.', | |
24 | 'age_limit': 18, | |
25 | 'duration': 117, | |
26 | 'thumbnail': r're:^https?://.*\.jpg$', | |
27 | 'timestamp': 1481904000, | |
28 | }, | |
29 | 'params': { | |
30 | 'skip_download': True, # HLS download | |
31 | }, | |
32 | }, { | |
33 | 'url': 'http://lnkgo.alfa.lt/visi-video/aktualai-pratesimas/ziurek-nerdas-taiso-kompiuteri-2', | |
34 | 'info_dict': { | |
35 | 'id': '10467', | |
36 | 'ext': 'mp4', | |
37 | 'title': 'Nėrdas: Kompiuterio Valymas', | |
38 | 'upload_date': '20150113', | |
39 | 'description': 'md5:7352d113a242a808676ff17e69db6a69', | |
40 | 'age_limit': 18, | |
41 | 'duration': 346, | |
42 | 'thumbnail': r're:^https?://.*\.jpg$', | |
43 | 'timestamp': 1421164800, | |
44 | }, | |
45 | 'params': { | |
46 | 'skip_download': True, # HLS download | |
47 | }, | |
48 | }, { | |
49 | 'url': 'https://lnk.lt/video/neigalieji-tv-bokste/37413', | |
50 | 'only_matching': True, | |
51 | }] | |
52 | _AGE_LIMITS = { | |
53 | 'N-7': 7, | |
54 | 'N-14': 14, | |
55 | 'S': 18, | |
56 | } | |
57 | _M3U8_TEMPL = 'https://vod.lnk.lt/lnk_vod/lnk/lnk/%s:%s/playlist.m3u8%s' | |
58 | ||
59 | def _real_extract(self, url): | |
60 | display_id, video_id = self._match_valid_url(url).groups() | |
61 | ||
62 | video_info = self._download_json( | |
63 | 'https://lnk.lt/api/main/video-page/%s/%s/false' % (display_id, video_id or '0'), | |
64 | display_id)['videoConfig']['videoInfo'] | |
65 | ||
66 | video_id = compat_str(video_info['id']) | |
67 | title = video_info['title'] | |
68 | prefix = 'smil' if video_info.get('isQualityChangeAvailable') else 'mp4' | |
69 | formats = self._extract_m3u8_formats( | |
70 | self._M3U8_TEMPL % (prefix, video_info['videoUrl'], video_info.get('secureTokenParams') or ''), | |
71 | video_id, 'mp4', 'm3u8_native') | |
72 | self._sort_formats(formats) | |
73 | ||
74 | poster_image = video_info.get('posterImage') | |
75 | ||
76 | return { | |
77 | 'id': video_id, | |
78 | 'display_id': display_id, | |
79 | 'title': title, | |
80 | 'formats': formats, | |
81 | 'thumbnail': 'https://lnk.lt/all-images/' + poster_image if poster_image else None, | |
82 | 'duration': int_or_none(video_info.get('duration')), | |
83 | 'description': clean_html(video_info.get('htmlDescription')), | |
84 | 'age_limit': self._AGE_LIMITS.get(video_info.get('pgRating'), 0), | |
85 | 'timestamp': parse_iso8601(video_info.get('airDate')), | |
86 | 'view_count': int_or_none(video_info.get('viewsCount')), | |
87 | } |