]>
Commit | Line | Data |
---|---|---|
f963b7ab HTL |
1 | import json |
2 | ||
3 | from .common import InfoExtractor | |
4 | from ..utils import ( | |
5 | int_or_none, | |
6 | js_to_json, | |
7 | parse_iso8601, | |
8 | str_or_none, | |
9 | traverse_obj, | |
10 | ) | |
11 | ||
12 | ||
13 | class LikeeIE(InfoExtractor): | |
14 | IE_NAME = 'likee' | |
15 | _VALID_URL = r'(?x)https?://(www\.)?likee\.video/(?:(?P<channel_name>[^/]+)/video/|v/)(?P<id>\w+)' | |
16 | _TESTS = [{ | |
17 | 'url': 'https://likee.video/@huynh_hong_quan_/video/7093444807096327263', | |
18 | 'info_dict': { | |
19 | 'id': '7093444807096327263', | |
20 | 'ext': 'mp4', | |
21 | 'title': '🤴🤴🤴', | |
22 | 'description': 'md5:9a7ebe816f0e78722ee5ed76f75983b4', | |
23 | 'thumbnail': r're:^https?://.+\.jpg', | |
24 | 'uploader': 'Huỳnh Hồng Quân ', | |
25 | 'play_count': int, | |
26 | 'download_count': int, | |
27 | 'artist': 'Huỳnh Hồng Quân ', | |
28 | 'timestamp': 1651571320, | |
29 | 'upload_date': '20220503', | |
30 | 'view_count': int, | |
31 | 'uploader_id': 'huynh_hong_quan_', | |
32 | 'duration': 12374, | |
33 | 'comment_count': int, | |
34 | 'like_count': int, | |
35 | }, | |
36 | }, { | |
37 | 'url': 'https://likee.video/@649222262/video/7093167848050058862', | |
38 | 'info_dict': { | |
39 | 'id': '7093167848050058862', | |
40 | 'ext': 'mp4', | |
41 | 'title': 'likee video #7093167848050058862', | |
42 | 'description': 'md5:3f971c8c6ee8a216f2b1a9094c5de99f', | |
43 | 'thumbnail': r're:^https?://.+\.jpg', | |
44 | 'comment_count': int, | |
45 | 'like_count': int, | |
46 | 'uploader': 'Vương Phước Nhi', | |
47 | 'download_count': int, | |
48 | 'timestamp': 1651506835, | |
49 | 'upload_date': '20220502', | |
50 | 'duration': 60024, | |
51 | 'play_count': int, | |
52 | 'artist': 'Vương Phước Nhi', | |
53 | 'uploader_id': '649222262', | |
54 | 'view_count': int, | |
55 | }, | |
56 | }, { | |
57 | 'url': 'https://likee.video/@fernanda_rivasg/video/6932224568407629502', | |
58 | 'info_dict': { | |
59 | 'id': '6932224568407629502', | |
60 | 'ext': 'mp4', | |
61 | 'title': 'Un trend viejito🔥 #LIKEE #Ferlovers #trend ', | |
62 | 'description': 'md5:c42b903a72a99d6d8b73e3d1126fbcef', | |
63 | 'thumbnail': r're:^https?://.+\.jpg', | |
64 | 'comment_count': int, | |
65 | 'duration': 9684, | |
66 | 'uploader_id': 'fernanda_rivasg', | |
67 | 'view_count': int, | |
68 | 'play_count': int, | |
69 | 'artist': 'La Cami La✨', | |
70 | 'download_count': int, | |
71 | 'like_count': int, | |
72 | 'uploader': 'Fernanda Rivas🎶', | |
73 | 'timestamp': 1614034308, | |
74 | 'upload_date': '20210222', | |
75 | }, | |
76 | }, { | |
77 | 'url': 'https://likee.video/v/k6QcOp', | |
78 | 'info_dict': { | |
79 | 'id': 'k6QcOp', | |
80 | 'ext': 'mp4', | |
81 | 'title': '#AguaChallenge tú ya lo intentaste?😱🤩', | |
82 | 'description': 'md5:b0cc462689d4ff2b624daa4dba7640d9', | |
83 | 'thumbnail': r're:^https?://.+\.jpg', | |
84 | 'comment_count': int, | |
85 | 'duration': 18014, | |
86 | 'play_count': int, | |
87 | 'view_count': int, | |
88 | 'timestamp': 1611694774, | |
89 | 'like_count': int, | |
90 | 'uploader': 'Fernanda Rivas🎶', | |
91 | 'uploader_id': 'fernanda_rivasg', | |
92 | 'download_count': int, | |
93 | 'artist': 'ʟᴇʀɪᴋ_ᴜɴɪᴄᴏʀɴ♡︎', | |
94 | 'upload_date': '20210126', | |
95 | }, | |
96 | }, { | |
97 | 'url': 'https://www.likee.video/@649222262/video/7093167848050058862', | |
98 | 'only_matching': True, | |
99 | }, { | |
100 | 'url': 'https://www.likee.video/v/k6QcOp', | |
101 | 'only_matching': True, | |
102 | }] | |
103 | ||
104 | def _real_extract(self, url): | |
105 | video_id = self._match_id(url) | |
106 | webpage = self._download_webpage(url, video_id) | |
107 | info = self._parse_json( | |
108 | self._search_regex(r'window\.data\s=\s({.+?});', webpage, 'video info'), | |
109 | video_id, transform_source=js_to_json) | |
110 | video_url = traverse_obj(info, 'video_url', ('originVideoInfo', 'video_url')) | |
111 | if not video_url: | |
112 | self.raise_no_formats('Video was deleted', expected=True) | |
113 | formats = [{ | |
114 | 'format_id': 'mp4-with-watermark', | |
115 | 'url': video_url, | |
116 | 'height': info.get('video_height'), | |
117 | 'width': info.get('video_width'), | |
118 | }, { | |
119 | 'format_id': 'mp4-without-watermark', | |
120 | 'url': video_url.replace('_4', ''), | |
121 | 'height': info.get('video_height'), | |
122 | 'width': info.get('video_width'), | |
123 | 'quality': 1, | |
124 | }] | |
f963b7ab HTL |
125 | return { |
126 | 'id': video_id, | |
127 | 'title': info.get('msgText'), | |
128 | 'description': info.get('share_desc'), | |
129 | 'view_count': int_or_none(info.get('video_count')), | |
130 | 'like_count': int_or_none(info.get('likeCount')), | |
131 | 'play_count': int_or_none(info.get('play_count')), | |
132 | 'download_count': int_or_none(info.get('download_count')), | |
133 | 'comment_count': int_or_none(info.get('comment_count')), | |
134 | 'uploader': str_or_none(info.get('nick_name')), | |
135 | 'uploader_id': str_or_none(info.get('likeeId')), | |
136 | 'artist': str_or_none(traverse_obj(info, ('sound', 'owner_name'))), | |
137 | 'timestamp': parse_iso8601(info.get('uploadDate')), | |
138 | 'thumbnail': info.get('coverUrl'), | |
139 | 'duration': int_or_none(traverse_obj(info, ('option_data', 'dur'))), | |
140 | 'formats': formats, | |
141 | } | |
142 | ||
143 | ||
144 | class LikeeUserIE(InfoExtractor): | |
145 | IE_NAME = 'likee:user' | |
146 | _VALID_URL = r'https?://(www\.)?likee\.video/(?P<id>[^/]+)/?$' | |
147 | _TESTS = [{ | |
148 | 'url': 'https://likee.video/@fernanda_rivasg', | |
149 | 'info_dict': { | |
150 | 'id': '925638334', | |
151 | 'title': 'fernanda_rivasg', | |
152 | }, | |
153 | 'playlist_mincount': 500, | |
154 | }, { | |
155 | 'url': 'https://likee.video/@may_hmoob', | |
156 | 'info_dict': { | |
157 | 'id': '2943949041', | |
158 | 'title': 'may_hmoob', | |
159 | }, | |
160 | 'playlist_mincount': 80, | |
161 | }] | |
162 | _PAGE_SIZE = 50 | |
163 | _API_GET_USER_VIDEO = 'https://api.like-video.com/likee-activity-flow-micro/videoApi/getUserVideo' | |
164 | ||
165 | def _entries(self, user_name, user_id): | |
166 | last_post_id = '' | |
167 | while True: | |
168 | user_videos = self._download_json( | |
169 | self._API_GET_USER_VIDEO, user_name, | |
170 | data=json.dumps({ | |
171 | 'uid': user_id, | |
172 | 'count': self._PAGE_SIZE, | |
173 | 'lastPostId': last_post_id, | |
174 | 'tabType': 0, | |
175 | }).encode('utf-8'), | |
176 | headers={'content-type': 'application/json'}, | |
177 | note=f'Get user info with lastPostId #{last_post_id}') | |
178 | items = traverse_obj(user_videos, ('data', 'videoList')) | |
179 | if not items: | |
180 | break | |
181 | for item in items: | |
182 | last_post_id = item['postId'] | |
183 | yield self.url_result(f'https://likee.video/{user_name}/video/{last_post_id}') | |
184 | ||
185 | def _real_extract(self, url): | |
186 | user_name = self._match_id(url) | |
187 | webpage = self._download_webpage(url, user_name) | |
188 | info = self._parse_json( | |
189 | self._search_regex(r'window\.data\s*=\s*({.+?});', webpage, 'user info'), | |
190 | user_name, transform_source=js_to_json) | |
191 | user_id = traverse_obj(info, ('userinfo', 'uid')) | |
192 | return self.playlist_result(self._entries(user_name, user_id), user_id, traverse_obj(info, ('userinfo', 'user_name'))) |