]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..compat import compat_str | |
3 | from ..utils import ( | |
4 | int_or_none, | |
5 | traverse_obj, | |
6 | try_get, | |
7 | urljoin, | |
8 | ) | |
9 | ||
10 | ||
11 | class MxplayerIE(InfoExtractor): | |
12 | _VALID_URL = r'https?://(?:www\.)?mxplayer\.in/(?P<type>movie|show/[-\w]+/[-\w]+)/(?P<display_id>[-\w]+)-(?P<id>\w+)' | |
13 | _TESTS = [{ | |
14 | 'url': 'https://www.mxplayer.in/show/watch-my-girlfriend-is-an-alien-hindi-dubbed/season-1/episode-1-online-9d2013d31d5835bb8400e3b3c5e7bb72', | |
15 | 'info_dict': { | |
16 | 'id': '9d2013d31d5835bb8400e3b3c5e7bb72', | |
17 | 'display_id': 'episode-1-online', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Episode 1', | |
20 | 'description': 'md5:62ed43eb9fec5efde5cf3bd1040b7670', | |
21 | 'season_number': 1, | |
22 | 'episode_number': 1, | |
23 | 'duration': 2451, | |
24 | 'season': 'Season 1', | |
25 | 'series': 'My Girlfriend Is An Alien (Hindi Dubbed)', | |
26 | 'episode': 'Episode 1' | |
27 | }, | |
28 | 'params': { | |
29 | 'format': 'bv', | |
30 | 'skip_download': True, | |
31 | }, | |
32 | }, { | |
33 | 'url': 'https://www.mxplayer.in/movie/watch-knock-knock-hindi-dubbed-movie-online-b9fa28df3bfb8758874735bbd7d2655a?watch=true', | |
34 | 'info_dict': { | |
35 | 'id': 'b9fa28df3bfb8758874735bbd7d2655a', | |
36 | 'display_id': 'episode-1-online', | |
37 | 'ext': 'mp4', | |
38 | 'title': 'Knock Knock (Hindi Dubbed)', | |
39 | 'description': 'md5:4160f2dfc3b87c524261366f6b736329', | |
40 | 'duration': 5970, | |
41 | }, | |
42 | 'params': { | |
43 | 'format': 'bv', | |
44 | 'skip_download': True, | |
45 | }, | |
46 | 'skip': 'No longer available', | |
47 | }, { | |
48 | 'url': 'https://www.mxplayer.in/show/watch-shaitaan/season-1/the-infamous-taxi-gang-of-meerut-online-45055d5bcff169ad48f2ad7552a83d6c', | |
49 | 'info_dict': { | |
50 | 'id': '45055d5bcff169ad48f2ad7552a83d6c', | |
51 | 'ext': 'mp4', | |
52 | 'title': 'The infamous taxi gang of Meerut', | |
53 | 'description': 'md5:033a0a7e3fd147be4fb7e07a01a3dc28', | |
54 | 'season_number': 1, | |
55 | 'episode_number': 1, | |
56 | 'duration': 2332, | |
57 | 'season': 'Season 1', | |
58 | 'series': 'Shaitaan', | |
59 | 'episode': 'Episode 1' | |
60 | }, | |
61 | 'params': { | |
62 | 'format': 'best', | |
63 | 'skip_download': True, | |
64 | }, | |
65 | 'skip': 'No longer available.' | |
66 | }, { | |
67 | 'url': 'https://www.mxplayer.in/show/watch-aashram/chapter-1/duh-swapna-online-d445579792b0135598ba1bc9088a84cb', | |
68 | 'info_dict': { | |
69 | 'id': 'd445579792b0135598ba1bc9088a84cb', | |
70 | 'display_id': 'duh-swapna-online', | |
71 | 'ext': 'mp4', | |
72 | 'title': 'Duh Swapna', | |
73 | 'description': 'md5:35ff39c4bdac403c53be1e16a04192d8', | |
74 | 'season_number': 1, | |
75 | 'episode_number': 3, | |
76 | 'duration': 2568, | |
77 | 'season': 'Season 1', | |
78 | 'series': 'Aashram', | |
79 | 'episode': 'Episode 3' | |
80 | }, | |
81 | 'params': { | |
82 | 'format': 'bv', | |
83 | 'skip_download': True, | |
84 | }, | |
85 | }, { | |
86 | 'url': 'https://www.mxplayer.in/show/watch-dangerous/season-1/chapter-1-online-5a351b4f9fb69436f6bd6ae3a1a75292', | |
87 | 'info_dict': { | |
88 | 'id': '5a351b4f9fb69436f6bd6ae3a1a75292', | |
89 | 'display_id': 'chapter-1-online', | |
90 | 'ext': 'mp4', | |
91 | 'title': 'Chapter 1', | |
92 | 'description': 'md5:233886b8598bc91648ac098abe1d288f', | |
93 | 'season_number': 1, | |
94 | 'episode_number': 1, | |
95 | 'duration': 1305, | |
96 | 'season': 'Season 1', | |
97 | 'series': 'Dangerous', | |
98 | 'episode': 'Episode 1' | |
99 | }, | |
100 | 'params': { | |
101 | 'format': 'bv', | |
102 | 'skip_download': True, | |
103 | }, | |
104 | }, { | |
105 | 'url': 'https://www.mxplayer.in/movie/watch-the-attacks-of-2611-movie-online-0452f0d80226c398d63ce7e3ea40fa2d', | |
106 | 'info_dict': { | |
107 | 'id': '0452f0d80226c398d63ce7e3ea40fa2d', | |
108 | 'ext': 'mp4', | |
109 | 'title': 'The Attacks of 26/11', | |
110 | 'description': 'md5:689bacd29e97b3f31eaf519eb14127e5', | |
111 | 'duration': 6085, | |
112 | }, | |
113 | 'params': { | |
114 | 'format': 'best', | |
115 | 'skip_download': True, | |
116 | }, | |
117 | 'skip': 'No longer available. Cannot be played on browser' | |
118 | }, { | |
119 | 'url': 'https://www.mxplayer.in/movie/watch-kitne-door-kitne-paas-movie-online-a9e9c76c566205955f70d8b2cb88a6a2', | |
120 | 'info_dict': { | |
121 | 'id': 'a9e9c76c566205955f70d8b2cb88a6a2', | |
122 | 'display_id': 'watch-kitne-door-kitne-paas-movie-online', | |
123 | 'title': 'Kitne Door Kitne Paas', | |
124 | 'duration': 8458, | |
125 | 'ext': 'mp4', | |
126 | 'description': 'md5:fb825f3c542513088024dcafef0921b4', | |
127 | }, | |
128 | 'params': { | |
129 | 'format': 'bv', | |
130 | 'skip_download': True, | |
131 | }, | |
132 | }, { | |
133 | 'url': 'https://www.mxplayer.in/show/watch-ek-thi-begum-hindi/season-2/game-of-power-online-5e5305c28f1409847cdc4520b6ad77cf', | |
134 | 'info_dict': { | |
135 | 'id': '5e5305c28f1409847cdc4520b6ad77cf', | |
136 | 'display_id': 'game-of-power-online', | |
137 | 'title': 'Game Of Power', | |
138 | 'duration': 1845, | |
139 | 'ext': 'mp4', | |
140 | 'description': 'md5:1d0948d2a5312d7013792d53542407f9', | |
141 | 'series': 'Ek Thi Begum (Hindi)', | |
142 | 'season': 'Season 2', | |
143 | 'season_number': 2, | |
144 | 'episode': 'Episode 2', | |
145 | 'episode_number': 2, | |
146 | }, | |
147 | 'params': { | |
148 | 'format': 'bv', | |
149 | 'skip_download': True, | |
150 | }, | |
151 | }, { | |
152 | 'url': 'https://www.mxplayer.in/movie/watch-deewane-huye-paagal-movie-online-4f9175c40a11c3994182a65afdd37ec6?watch=true', | |
153 | 'info_dict': { | |
154 | 'id': '4f9175c40a11c3994182a65afdd37ec6', | |
155 | 'display_id': 'watch-deewane-huye-paagal-movie-online', | |
156 | 'title': 'Deewane Huye Paagal', | |
157 | 'duration': 9037, | |
158 | 'ext': 'mp4', | |
159 | 'description': 'md5:d17bd5c651016c4ed2e6f8a4ace15534', | |
160 | }, | |
161 | 'params': {'skip_download': 'm3u8'}, | |
162 | }] | |
163 | ||
164 | def _real_extract(self, url): | |
165 | video_type, display_id, video_id = self._match_valid_url(url).group('type', 'display_id', 'id') | |
166 | if 'show' in video_type: | |
167 | video_type = 'episode' | |
168 | ||
169 | data_json = self._download_json( | |
170 | f'https://api.mxplay.com/v1/web/detail/video?type={video_type}&id={video_id}', display_id) | |
171 | ||
172 | formats, subtitles = [], {} | |
173 | m3u8_url = urljoin('https://llvod.mxplay.com/', traverse_obj( | |
174 | data_json, ('stream', (('thirdParty', 'hlsUrl'), ('hls', 'high'))), get_all=False)) | |
175 | if m3u8_url: | |
176 | formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, display_id, 'mp4', fatal=False) | |
177 | mpd_url = urljoin('https://llvod.mxplay.com/', traverse_obj( | |
178 | data_json, ('stream', (('thirdParty', 'dashUrl'), ('dash', 'high'))), get_all=False)) | |
179 | if mpd_url: | |
180 | fmts, subs = self._extract_mpd_formats_and_subtitles(mpd_url, display_id, fatal=False) | |
181 | formats.extend(fmts) | |
182 | self._merge_subtitles(subs, target=subtitles) | |
183 | ||
184 | season = traverse_obj(data_json, ('container', 'title')) | |
185 | return { | |
186 | 'id': video_id, | |
187 | 'title': data_json.get('title'), | |
188 | 'formats': formats, | |
189 | 'subtitles': subtitles, | |
190 | 'display_id': display_id, | |
191 | 'duration': data_json.get('duration'), | |
192 | 'series': traverse_obj(data_json, ('container', 'container', 'title')), | |
193 | 'description': data_json.get('description'), | |
194 | 'season': season, | |
195 | 'season_number': int_or_none( | |
196 | self._search_regex(r'Season (\d+)', season, 'Season Number', default=None)), | |
197 | 'episode_number': data_json.get('sequence') or None, | |
198 | } | |
199 | ||
200 | ||
201 | class MxplayerShowIE(InfoExtractor): | |
202 | _VALID_URL = r'https?://(?:www\.)?mxplayer\.in/show/(?P<display_id>[-\w]+)-(?P<id>\w+)/?(?:$|[#?])' | |
203 | _TESTS = [{ | |
204 | 'url': 'https://www.mxplayer.in/show/watch-chakravartin-ashoka-samrat-series-online-a8f44e3cc0814b5601d17772cedf5417', | |
205 | 'playlist_mincount': 440, | |
206 | 'info_dict': { | |
207 | 'id': 'a8f44e3cc0814b5601d17772cedf5417', | |
208 | 'title': 'Watch Chakravartin Ashoka Samrat Series Online', | |
209 | } | |
210 | }] | |
211 | ||
212 | _API_SHOW_URL = "https://api.mxplay.com/v1/web/detail/tab/tvshowseasons?type=tv_show&id={}&device-density=2&platform=com.mxplay.desktop&content-languages=hi,en" | |
213 | _API_EPISODES_URL = "https://api.mxplay.com/v1/web/detail/tab/tvshowepisodes?type=season&id={}&device-density=1&platform=com.mxplay.desktop&content-languages=hi,en&{}" | |
214 | ||
215 | def _entries(self, show_id): | |
216 | show_json = self._download_json( | |
217 | self._API_SHOW_URL.format(show_id), | |
218 | video_id=show_id, headers={'Referer': 'https://mxplayer.in'}) | |
219 | page_num = 0 | |
220 | for season in show_json.get('items') or []: | |
221 | season_id = try_get(season, lambda x: x['id'], compat_str) | |
222 | next_url = '' | |
223 | while next_url is not None: | |
224 | page_num += 1 | |
225 | season_json = self._download_json( | |
226 | self._API_EPISODES_URL.format(season_id, next_url), | |
227 | video_id=season_id, | |
228 | headers={'Referer': 'https://mxplayer.in'}, | |
229 | note='Downloading JSON metadata page %d' % page_num) | |
230 | for episode in season_json.get('items') or []: | |
231 | video_url = episode['webUrl'] | |
232 | yield self.url_result( | |
233 | 'https://mxplayer.in%s' % video_url, | |
234 | ie=MxplayerIE.ie_key(), video_id=video_url.split('-')[-1]) | |
235 | next_url = season_json.get('next') | |
236 | ||
237 | def _real_extract(self, url): | |
238 | display_id, show_id = self._match_valid_url(url).groups() | |
239 | return self.playlist_result( | |
240 | self._entries(show_id), playlist_id=show_id, | |
241 | playlist_title=display_id.replace('-', ' ').title()) |