]>
Commit | Line | Data |
---|---|---|
097b056c | 1 | from .common import InfoExtractor |
87c3d062 | 2 | from ..compat import compat_str |
1722099d | 3 | from ..utils import try_get |
097b056c AC |
4 | |
5 | ||
097b056c | 6 | class MxplayerIE(InfoExtractor): |
1722099d | 7 | _VALID_URL = r'https?://(?:www\.)?mxplayer\.in/(?P<type>movie|show/[-\w]+/[-\w]+)/(?P<display_id>[-\w]+)-(?P<id>\w+)' |
1caaf92d | 8 | _TESTS = [{ |
1722099d AG |
9 | 'url': 'https://www.mxplayer.in/show/watch-my-girlfriend-is-an-alien-hindi-dubbed/season-1/episode-1-online-9d2013d31d5835bb8400e3b3c5e7bb72', |
10 | 'info_dict': { | |
11 | 'id': '9d2013d31d5835bb8400e3b3c5e7bb72', | |
12 | 'ext': 'mp4', | |
13 | 'title': 'Episode 1', | |
14 | 'description': 'md5:62ed43eb9fec5efde5cf3bd1040b7670', | |
15 | 'season_number': 1, | |
16 | 'episode_number': 1, | |
17 | 'duration': 2451, | |
18 | 'season': 'Season 1', | |
19 | 'series': 'My Girlfriend Is An Alien (Hindi Dubbed)', | |
20 | 'thumbnail': 'https://qqcdnpictest.mxplay.com/pic/9d2013d31d5835bb8400e3b3c5e7bb72/en/16x9/320x180/9562f5f8df42cad09c9a9c4e69eb1567_1920x1080.webp', | |
21 | 'episode': 'Episode 1' | |
22 | }, | |
23 | 'params': { | |
24 | 'format': 'bv', | |
25 | 'skip_download': True, | |
26 | }, | |
27 | }, { | |
097b056c AC |
28 | 'url': 'https://www.mxplayer.in/movie/watch-knock-knock-hindi-dubbed-movie-online-b9fa28df3bfb8758874735bbd7d2655a?watch=true', |
29 | 'info_dict': { | |
30 | 'id': 'b9fa28df3bfb8758874735bbd7d2655a', | |
31 | 'ext': 'mp4', | |
1caaf92d | 32 | 'title': 'Knock Knock (Hindi Dubbed)', |
1722099d AG |
33 | 'description': 'md5:b195ba93ff1987309cfa58e2839d2a5b', |
34 | 'season_number': 0, | |
35 | 'episode_number': 0, | |
36 | 'duration': 5970, | |
37 | 'season': 'Season 0', | |
38 | 'series': None, | |
39 | 'thumbnail': 'https://qqcdnpictest.mxplay.com/pic/b9fa28df3bfb8758874735bbd7d2655a/en/16x9/320x180/test_pic1588676032011.webp', | |
40 | 'episode': 'Episode 0' | |
097b056c AC |
41 | }, |
42 | 'params': { | |
1722099d | 43 | 'format': 'bv', |
097b056c | 44 | 'skip_download': True, |
1722099d | 45 | }, |
1caaf92d A |
46 | }, { |
47 | 'url': 'https://www.mxplayer.in/show/watch-shaitaan/season-1/the-infamous-taxi-gang-of-meerut-online-45055d5bcff169ad48f2ad7552a83d6c', | |
48 | 'info_dict': { | |
49 | 'id': '45055d5bcff169ad48f2ad7552a83d6c', | |
1722099d | 50 | 'ext': 'mp4', |
1caaf92d A |
51 | 'title': 'The infamous taxi gang of Meerut', |
52 | 'description': 'md5:033a0a7e3fd147be4fb7e07a01a3dc28', | |
1722099d AG |
53 | 'season_number': 1, |
54 | 'episode_number': 1, | |
55 | 'duration': 2332, | |
1caaf92d | 56 | 'season': 'Season 1', |
1722099d AG |
57 | 'series': 'Shaitaan', |
58 | 'thumbnail': 'https://qqcdnpictest.mxplay.com/pic/45055d5bcff169ad48f2ad7552a83d6c/en/16x9/320x180/voot_8e7d5f8d8183340869279c732c1e3a43.webp', | |
59 | 'episode': 'Episode 1' | |
1caaf92d A |
60 | }, |
61 | 'params': { | |
1722099d | 62 | 'format': 'best', |
1caaf92d | 63 | 'skip_download': True, |
1722099d | 64 | }, |
1caaf92d A |
65 | }, { |
66 | 'url': 'https://www.mxplayer.in/show/watch-aashram/chapter-1/duh-swapna-online-d445579792b0135598ba1bc9088a84cb', | |
67 | 'info_dict': { | |
68 | 'id': 'd445579792b0135598ba1bc9088a84cb', | |
69 | 'ext': 'mp4', | |
70 | 'title': 'Duh Swapna', | |
71 | 'description': 'md5:35ff39c4bdac403c53be1e16a04192d8', | |
1722099d AG |
72 | 'season_number': 1, |
73 | 'episode_number': 3, | |
74 | 'duration': 2568, | |
1caaf92d | 75 | 'season': 'Chapter 1', |
1722099d AG |
76 | 'series': 'Aashram', |
77 | 'thumbnail': 'https://qqcdnpictest.mxplay.com/pic/d445579792b0135598ba1bc9088a84cb/en/4x3/1600x1200/test_pic1624819307993.webp', | |
78 | 'episode': 'Episode 3' | |
1caaf92d | 79 | }, |
1caaf92d | 80 | 'params': { |
1722099d | 81 | 'format': 'bv', |
1caaf92d | 82 | 'skip_download': True, |
1722099d AG |
83 | }, |
84 | }, { | |
85 | 'url': 'https://www.mxplayer.in/show/watch-dangerous/season-1/chapter-1-online-5a351b4f9fb69436f6bd6ae3a1a75292', | |
86 | 'info_dict': { | |
87 | 'id': '5a351b4f9fb69436f6bd6ae3a1a75292', | |
88 | 'ext': 'mp4', | |
89 | 'title': 'Chapter 1', | |
90 | 'description': 'md5:233886b8598bc91648ac098abe1d288f', | |
91 | 'season_number': 1, | |
92 | 'episode_number': 1, | |
93 | 'duration': 1305, | |
94 | 'season': 'Season 1', | |
95 | 'series': 'Dangerous', | |
96 | 'thumbnail': 'https://qqcdnpictest.mxplay.com/pic/5a351b4f9fb69436f6bd6ae3a1a75292/en/4x3/1600x1200/test_pic1624706302350.webp', | |
97 | 'episode': 'Episode 1' | |
98 | }, | |
99 | 'params': { | |
100 | 'format': 'bv', | |
101 | 'skip_download': True, | |
102 | }, | |
103 | }, { | |
104 | 'url': 'https://www.mxplayer.in/movie/watch-the-attacks-of-2611-movie-online-0452f0d80226c398d63ce7e3ea40fa2d', | |
105 | 'info_dict': { | |
106 | 'id': '0452f0d80226c398d63ce7e3ea40fa2d', | |
107 | 'ext': 'mp4', | |
108 | 'title': 'The Attacks of 26/11', | |
109 | 'description': 'md5:689bacd29e97b3f31eaf519eb14127e5', | |
110 | 'season_number': 0, | |
111 | 'episode_number': 0, | |
112 | 'duration': 6085, | |
113 | 'season': 'Season 0', | |
114 | 'series': None, | |
115 | 'thumbnail': 'https://qqcdnpictest.mxplay.com/pic/0452f0d80226c398d63ce7e3ea40fa2d/en/16x9/320x180/00c8955dab5e5d340dbde643f9b1f6fd_1920x1080.webp', | |
116 | 'episode': 'Episode 0' | |
117 | }, | |
118 | 'params': { | |
119 | 'format': 'best', | |
120 | 'skip_download': True, | |
121 | }, | |
1caaf92d | 122 | }] |
097b056c | 123 | |
097b056c | 124 | def _real_extract(self, url): |
1722099d AG |
125 | type, display_id, video_id = self._match_valid_url(url).groups() |
126 | type = 'movie_film' if type == 'movie' else 'tvshow_episode' | |
127 | API_URL = 'https://androidapi.mxplay.com/v1/detail/' | |
128 | headers = { | |
129 | 'X-Av-Code': '23', | |
130 | 'X-Country': 'IN', | |
131 | 'X-Platform': 'android', | |
132 | 'X-App-Version': '1370001318', | |
133 | 'X-Resolution': '3840x2160', | |
134 | } | |
135 | data_json = self._download_json(f'{API_URL}{type}/{video_id}', display_id, headers=headers)['profile'] | |
097b056c | 136 | |
1722099d AG |
137 | season, series = None, None |
138 | for dct in data_json.get('levelInfos', []): | |
139 | if dct.get('type') == 'tvshow_season': | |
140 | season = dct.get('name') | |
141 | elif dct.get('type') == 'tvshow_show': | |
142 | series = dct.get('name') | |
1caaf92d | 143 | thumbnails = [] |
1722099d | 144 | for thumb in data_json.get('poster', []): |
1caaf92d | 145 | thumbnails.append({ |
1722099d AG |
146 | 'url': thumb.get('url'), |
147 | 'width': thumb.get('width'), | |
148 | 'height': thumb.get('height'), | |
1caaf92d | 149 | }) |
097b056c AC |
150 | |
151 | formats = [] | |
1722099d AG |
152 | subtitles = {} |
153 | for dct in data_json.get('playInfo', []): | |
154 | if dct.get('extension') == 'mpd': | |
155 | frmt, subs = self._extract_mpd_formats_and_subtitles(dct.get('playUrl'), display_id, fatal=False) | |
156 | formats.extend(frmt) | |
157 | subtitles = self._merge_subtitles(subtitles, subs) | |
158 | elif dct.get('extension') == 'm3u8': | |
159 | frmt, subs = self._extract_m3u8_formats_and_subtitles(dct.get('playUrl'), display_id, fatal=False) | |
160 | formats.extend(frmt) | |
161 | subtitles = self._merge_subtitles(subtitles, subs) | |
097b056c | 162 | self._sort_formats(formats) |
1caaf92d | 163 | return { |
097b056c | 164 | 'id': video_id, |
87c3d062 | 165 | 'display_id': display_id, |
1722099d AG |
166 | 'title': data_json.get('name') or display_id, |
167 | 'description': data_json.get('description'), | |
168 | 'season_number': data_json.get('seasonNum'), | |
169 | 'episode_number': data_json.get('episodeNum'), | |
170 | 'duration': data_json.get('duration'), | |
171 | 'season': season, | |
172 | 'series': series, | |
1caaf92d | 173 | 'thumbnails': thumbnails, |
1722099d AG |
174 | 'formats': formats, |
175 | 'subtitles': subtitles, | |
097b056c | 176 | } |
87c3d062 A |
177 | |
178 | ||
179 | class MxplayerShowIE(InfoExtractor): | |
73f035e1 | 180 | _VALID_URL = r'https?://(?:www\.)?mxplayer\.in/show/(?P<display_id>[-\w]+)-(?P<id>\w+)/?(?:$|[#?])' |
87c3d062 A |
181 | _TESTS = [{ |
182 | 'url': 'https://www.mxplayer.in/show/watch-chakravartin-ashoka-samrat-series-online-a8f44e3cc0814b5601d17772cedf5417', | |
183 | 'playlist_mincount': 440, | |
184 | 'info_dict': { | |
185 | 'id': 'a8f44e3cc0814b5601d17772cedf5417', | |
186 | 'title': 'Watch Chakravartin Ashoka Samrat Series Online', | |
187 | } | |
188 | }] | |
189 | ||
190 | _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" | |
191 | _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&{}" | |
192 | ||
193 | def _entries(self, show_id): | |
194 | show_json = self._download_json( | |
195 | self._API_SHOW_URL.format(show_id), | |
196 | video_id=show_id, headers={'Referer': 'https://mxplayer.in'}) | |
197 | page_num = 0 | |
198 | for season in show_json.get('items') or []: | |
199 | season_id = try_get(season, lambda x: x['id'], compat_str) | |
200 | next_url = '' | |
201 | while next_url is not None: | |
202 | page_num += 1 | |
203 | season_json = self._download_json( | |
204 | self._API_EPISODES_URL.format(season_id, next_url), | |
205 | video_id=season_id, | |
206 | headers={'Referer': 'https://mxplayer.in'}, | |
207 | note='Downloading JSON metadata page %d' % page_num) | |
208 | for episode in season_json.get('items') or []: | |
209 | video_url = episode['webUrl'] | |
210 | yield self.url_result( | |
211 | 'https://mxplayer.in%s' % video_url, | |
212 | ie=MxplayerIE.ie_key(), video_id=video_url.split('-')[-1]) | |
213 | next_url = season_json.get('next') | |
214 | ||
215 | def _real_extract(self, url): | |
5ad28e7f | 216 | display_id, show_id = self._match_valid_url(url).groups() |
87c3d062 A |
217 | return self.playlist_result( |
218 | self._entries(show_id), playlist_id=show_id, | |
219 | playlist_title=display_id.replace('-', ' ').title()) |