]>
Commit | Line | Data |
---|---|---|
04e88ca2 | 1 | from .common import InfoExtractor |
e7e3ec82 | 2 | from .vk import VKIE |
5625e607 B |
3 | from ..compat import compat_b64decode |
4 | from ..utils import ( | |
5 | int_or_none, | |
6 | js_to_json, | |
7 | traverse_obj, | |
8 | unified_timestamp, | |
e7e3ec82 | 9 | ) |
04e88ca2 | 10 | |
11 | ||
12 | class BIQLEIE(InfoExtractor): | |
13 | _VALID_URL = r'https?://(?:www\.)?biqle\.(?:com|org|ru)/watch/(?P<id>-?\d+_\d+)' | |
14 | _TESTS = [{ | |
5625e607 B |
15 | 'url': 'https://biqle.ru/watch/-2000421746_85421746', |
16 | 'md5': 'ae6ef4f04d19ac84e4658046d02c151c', | |
04e88ca2 | 17 | 'info_dict': { |
5625e607 | 18 | 'id': '-2000421746_85421746', |
04e88ca2 | 19 | 'ext': 'mp4', |
5625e607 B |
20 | 'title': 'Forsaken By Hope Studio Clip', |
21 | 'description': 'Forsaken By Hope Studio Clip — Смотреть онлайн', | |
22 | 'upload_date': '19700101', | |
23 | 'thumbnail': r're:https://[^/]+/impf/7vN3ACwSTgChP96OdOfzFjUCzFR6ZglDQgWsIw/KPaACiVJJxM\.jpg\?size=800x450&quality=96&keep_aspect_ratio=1&background=000000&sign=b48ea459c4d33dbcba5e26d63574b1cb&type=video_thumb', | |
24 | 'timestamp': 0, | |
e7e3ec82 | 25 | }, |
04e88ca2 | 26 | }, { |
e7e3ec82 | 27 | 'url': 'http://biqle.org/watch/-44781847_168547604', |
04e88ca2 | 28 | 'md5': '7f24e72af1db0edf7c1aaba513174f97', |
29 | 'info_dict': { | |
220828f2 | 30 | 'id': '-44781847_168547604', |
04e88ca2 | 31 | 'ext': 'mp4', |
32 | 'title': 'Ребенок в шоке от автоматической мойки', | |
5625e607 | 33 | 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн', |
e7e3ec82 | 34 | 'timestamp': 1396633454, |
e7e3ec82 | 35 | 'upload_date': '20140404', |
5625e607 | 36 | 'thumbnail': r're:https://[^/]+/c535507/u190034692/video/l_b84df002\.jpg', |
d7120712 | 37 | }, |
04e88ca2 | 38 | }] |
39 | ||
40 | def _real_extract(self, url): | |
41 | video_id = self._match_id(url) | |
42 | webpage = self._download_webpage(url, video_id) | |
5625e607 B |
43 | |
44 | title = self._html_search_meta('name', webpage, 'Title', fatal=False) | |
45 | timestamp = unified_timestamp(self._html_search_meta('uploadDate', webpage, 'Upload Date', default=None)) | |
46 | description = self._html_search_meta('description', webpage, 'Description', default=None) | |
47 | ||
48 | global_embed_url = self._search_regex( | |
49 | r'<script[^<]+?window.globEmbedUrl\s*=\s*\'((?:https?:)?//(?:daxab\.com|dxb\.to|[^/]+/player)/[^\']+)\'', | |
50 | webpage, 'global Embed url') | |
51 | hash = self._search_regex( | |
52 | r'<script id="data-embed-video[^<]+?hash: "([^"]+)"[^<]*</script>', webpage, 'Hash') | |
53 | ||
54 | embed_url = global_embed_url + hash | |
55 | ||
e7e3ec82 RA |
56 | if VKIE.suitable(embed_url): |
57 | return self.url_result(embed_url, VKIE.ie_key(), video_id) | |
58 | ||
f5863a3e | 59 | embed_page = self._download_webpage( |
5625e607 B |
60 | embed_url, video_id, 'Downloading embed webpage', headers={'Referer': url}) |
61 | ||
62 | glob_params = self._parse_json(self._search_regex( | |
63 | r'<script id="globParams">[^<]*window.globParams = ([^;]+);[^<]+</script>', | |
64 | embed_page, 'Global Parameters'), video_id, transform_source=js_to_json) | |
65 | host_name = compat_b64decode(glob_params['server'][::-1]).decode() | |
66 | ||
e7e3ec82 | 67 | item = self._download_json( |
5625e607 B |
68 | f'https://{host_name}/method/video.get/{video_id}', video_id, |
69 | headers={'Referer': url}, query={ | |
70 | 'token': glob_params['video']['access_token'], | |
e7e3ec82 | 71 | 'videos': video_id, |
5625e607 B |
72 | 'ckey': glob_params['c_key'], |
73 | 'credentials': glob_params['video']['credentials'], | |
e7e3ec82 | 74 | })['response']['items'][0] |
e7e3ec82 RA |
75 | |
76 | formats = [] | |
77 | for f_id, f_url in item.get('files', {}).items(): | |
78 | if f_id == 'external': | |
79 | return self.url_result(f_url) | |
80 | ext, height = f_id.split('_') | |
5625e607 B |
81 | height_extra_key = traverse_obj(glob_params, ('video', 'partial', 'quality', height)) |
82 | if height_extra_key: | |
83 | formats.append({ | |
84 | 'format_id': f'{height}p', | |
85 | 'url': f'https://{host_name}/{f_url[8:]}&videos={video_id}&extra_key={height_extra_key}', | |
86 | 'height': int_or_none(height), | |
87 | 'ext': ext, | |
88 | }) | |
e7e3ec82 RA |
89 | |
90 | thumbnails = [] | |
91 | for k, v in item.items(): | |
92 | if k.startswith('photo_') and v: | |
93 | width = k.replace('photo_', '') | |
94 | thumbnails.append({ | |
95 | 'id': width, | |
96 | 'url': v, | |
97 | 'width': int_or_none(width), | |
98 | }) | |
04e88ca2 | 99 | |
100 | return { | |
e7e3ec82 RA |
101 | 'id': video_id, |
102 | 'title': title, | |
103 | 'formats': formats, | |
104 | 'comment_count': int_or_none(item.get('comments')), | |
5625e607 | 105 | 'description': description, |
e7e3ec82 RA |
106 | 'duration': int_or_none(item.get('duration')), |
107 | 'thumbnails': thumbnails, | |
5625e607 | 108 | 'timestamp': timestamp, |
e7e3ec82 | 109 | 'view_count': int_or_none(item.get('views')), |
04e88ca2 | 110 | } |