]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | ||
3 | from ..utils import ( | |
4 | int_or_none, | |
5 | traverse_obj, | |
6 | try_get, | |
7 | unified_timestamp, | |
8 | ) | |
9 | ||
10 | ||
11 | class BeegIE(InfoExtractor): | |
12 | _VALID_URL = r'https?://(?:www\.)?beeg\.(?:com(?:/video)?)/-?(?P<id>\d+)' | |
13 | _TESTS = [{ | |
14 | 'url': 'https://beeg.com/-0983946056129650', | |
15 | 'md5': '51d235147c4627cfce884f844293ff88', | |
16 | 'info_dict': { | |
17 | 'id': '0983946056129650', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'sucked cock and fucked in a private plane', | |
20 | 'duration': 927, | |
21 | 'tags': list, | |
22 | 'age_limit': 18, | |
23 | 'upload_date': '20220131', | |
24 | 'timestamp': 1643656455, | |
25 | 'display_id': 2540839, | |
26 | } | |
27 | }, { | |
28 | 'url': 'https://beeg.com/-0599050563103750?t=4-861', | |
29 | 'md5': 'bd8b5ea75134f7f07fad63008db2060e', | |
30 | 'info_dict': { | |
31 | 'id': '0599050563103750', | |
32 | 'ext': 'mp4', | |
33 | 'title': 'Bad Relatives', | |
34 | 'duration': 2060, | |
35 | 'tags': list, | |
36 | 'age_limit': 18, | |
37 | 'description': 'md5:b4fc879a58ae6c604f8f259155b7e3b9', | |
38 | 'timestamp': 1643623200, | |
39 | 'display_id': 2569965, | |
40 | 'upload_date': '20220131', | |
41 | } | |
42 | }, { | |
43 | # api/v6 v2 | |
44 | 'url': 'https://beeg.com/1941093077?t=911-1391', | |
45 | 'only_matching': True, | |
46 | }, { | |
47 | # api/v6 v2 w/o t | |
48 | 'url': 'https://beeg.com/1277207756', | |
49 | 'only_matching': True, | |
50 | }] | |
51 | ||
52 | def _real_extract(self, url): | |
53 | video_id = self._match_id(url) | |
54 | ||
55 | webpage = self._download_webpage(url, video_id) | |
56 | ||
57 | video = self._download_json( | |
58 | 'https://store.externulls.com/facts/file/%s' % video_id, | |
59 | video_id, 'Downloading JSON for %s' % video_id) | |
60 | ||
61 | fc_facts = video.get('fc_facts') | |
62 | first_fact = {} | |
63 | for fact in fc_facts: | |
64 | if not first_fact or try_get(fact, lambda x: x['id'] < first_fact['id']): | |
65 | first_fact = fact | |
66 | ||
67 | resources = traverse_obj(video, ('file', 'hls_resources')) or first_fact.get('hls_resources') | |
68 | ||
69 | formats = [] | |
70 | for format_id, video_uri in resources.items(): | |
71 | if not video_uri: | |
72 | continue | |
73 | height = int_or_none(self._search_regex(r'fl_cdn_(\d+)', format_id, 'height', default=None)) | |
74 | current_formats = self._extract_m3u8_formats(f'https://video.beeg.com/{video_uri}', video_id, ext='mp4', m3u8_id=str(height)) | |
75 | for f in current_formats: | |
76 | f['height'] = height | |
77 | formats.extend(current_formats) | |
78 | ||
79 | self._sort_formats(formats) | |
80 | ||
81 | return { | |
82 | 'id': video_id, | |
83 | 'display_id': first_fact.get('id'), | |
84 | 'title': traverse_obj(video, ('file', 'stuff', 'sf_name')), | |
85 | 'description': traverse_obj(video, ('file', 'stuff', 'sf_story')), | |
86 | 'timestamp': unified_timestamp(first_fact.get('fc_created')), | |
87 | 'duration': int_or_none(traverse_obj(video, ('file', 'fl_duration'))), | |
88 | 'tags': traverse_obj(video, ('tags', ..., 'tg_name')), | |
89 | 'formats': formats, | |
90 | 'age_limit': self._rta_search(webpage), | |
91 | } |