1 from .common
import InfoExtractor
10 class MxplayerIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?mxplayer\.in/(?P<type>movie|show/[-\w]+/[-\w]+)/(?P<display_id>[-\w]+)-(?P<id>\w+)'
13 'url': 'https://www.mxplayer.in/show/watch-my-girlfriend-is-an-alien-hindi-dubbed/season-1/episode-1-online-9d2013d31d5835bb8400e3b3c5e7bb72',
15 'id': '9d2013d31d5835bb8400e3b3c5e7bb72',
16 'display_id': 'episode-1-online',
19 'description': 'md5:62ed43eb9fec5efde5cf3bd1040b7670',
24 'series': 'My Girlfriend Is An Alien (Hindi Dubbed)',
25 'episode': 'Episode 1',
29 'skip_download': True,
32 'url': 'https://www.mxplayer.in/movie/watch-knock-knock-hindi-dubbed-movie-online-b9fa28df3bfb8758874735bbd7d2655a?watch=true',
34 'id': 'b9fa28df3bfb8758874735bbd7d2655a',
35 'display_id': 'episode-1-online',
37 'title': 'Knock Knock (Hindi Dubbed)',
38 'description': 'md5:4160f2dfc3b87c524261366f6b736329',
43 'skip_download': True,
45 'skip': 'No longer available',
47 'url': 'https://www.mxplayer.in/show/watch-shaitaan/season-1/the-infamous-taxi-gang-of-meerut-online-45055d5bcff169ad48f2ad7552a83d6c',
49 'id': '45055d5bcff169ad48f2ad7552a83d6c',
51 'title': 'The infamous taxi gang of Meerut',
52 'description': 'md5:033a0a7e3fd147be4fb7e07a01a3dc28',
58 'episode': 'Episode 1',
62 'skip_download': True,
64 'skip': 'No longer available.',
66 'url': 'https://www.mxplayer.in/show/watch-aashram/chapter-1/duh-swapna-online-d445579792b0135598ba1bc9088a84cb',
68 'id': 'd445579792b0135598ba1bc9088a84cb',
69 'display_id': 'duh-swapna-online',
71 'title': 'Duh Swapna',
72 'description': 'md5:35ff39c4bdac403c53be1e16a04192d8',
78 'episode': 'Episode 3',
82 'skip_download': True,
85 'url': 'https://www.mxplayer.in/show/watch-dangerous/season-1/chapter-1-online-5a351b4f9fb69436f6bd6ae3a1a75292',
87 'id': '5a351b4f9fb69436f6bd6ae3a1a75292',
88 'display_id': 'chapter-1-online',
91 'description': 'md5:233886b8598bc91648ac098abe1d288f',
96 'series': 'Dangerous',
97 'episode': 'Episode 1',
101 'skip_download': True,
104 'url': 'https://www.mxplayer.in/movie/watch-the-attacks-of-2611-movie-online-0452f0d80226c398d63ce7e3ea40fa2d',
106 'id': '0452f0d80226c398d63ce7e3ea40fa2d',
108 'title': 'The Attacks of 26/11',
109 'description': 'md5:689bacd29e97b3f31eaf519eb14127e5',
114 'skip_download': True,
116 'skip': 'No longer available. Cannot be played on browser',
118 'url': 'https://www.mxplayer.in/movie/watch-kitne-door-kitne-paas-movie-online-a9e9c76c566205955f70d8b2cb88a6a2',
120 'id': 'a9e9c76c566205955f70d8b2cb88a6a2',
121 'display_id': 'watch-kitne-door-kitne-paas-movie-online',
122 'title': 'Kitne Door Kitne Paas',
125 'description': 'md5:fb825f3c542513088024dcafef0921b4',
129 'skip_download': True,
132 'url': 'https://www.mxplayer.in/show/watch-ek-thi-begum-hindi/season-2/game-of-power-online-5e5305c28f1409847cdc4520b6ad77cf',
134 'id': '5e5305c28f1409847cdc4520b6ad77cf',
135 'display_id': 'game-of-power-online',
136 'title': 'Game Of Power',
139 'description': 'md5:1d0948d2a5312d7013792d53542407f9',
140 'series': 'Ek Thi Begum (Hindi)',
141 'season': 'Season 2',
143 'episode': 'Episode 2',
148 'skip_download': True,
151 'url': 'https://www.mxplayer.in/movie/watch-deewane-huye-paagal-movie-online-4f9175c40a11c3994182a65afdd37ec6?watch=true',
153 'id': '4f9175c40a11c3994182a65afdd37ec6',
154 'display_id': 'watch-deewane-huye-paagal-movie-online',
155 'title': 'Deewane Huye Paagal',
158 'description': 'md5:d17bd5c651016c4ed2e6f8a4ace15534',
160 'params': {'skip_download': 'm3u8'},
163 def _real_extract(self
, url
):
164 video_type
, display_id
, video_id
= self
._match
_valid
_url
(url
).group('type', 'display_id', 'id')
165 if 'show' in video_type
:
166 video_type
= 'episode'
168 data_json
= self
._download
_json
(
169 f
'https://api.mxplay.com/v1/web/detail/video?type={video_type}&id={video_id}', display_id
)
171 formats
, subtitles
= [], {}
172 m3u8_url
= urljoin('https://llvod.mxplay.com/', traverse_obj(
173 data_json
, ('stream', (('thirdParty', 'hlsUrl'), ('hls', 'high'))), get_all
=False))
175 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(m3u8_url
, display_id
, 'mp4', fatal
=False)
176 mpd_url
= urljoin('https://llvod.mxplay.com/', traverse_obj(
177 data_json
, ('stream', (('thirdParty', 'dashUrl'), ('dash', 'high'))), get_all
=False))
179 fmts
, subs
= self
._extract
_mpd
_formats
_and
_subtitles
(mpd_url
, display_id
, fatal
=False)
181 self
._merge
_subtitles
(subs
, target
=subtitles
)
183 season
= traverse_obj(data_json
, ('container', 'title'))
186 'title': data_json
.get('title'),
188 'subtitles': subtitles
,
189 'display_id': display_id
,
190 'duration': data_json
.get('duration'),
191 'series': traverse_obj(data_json
, ('container', 'container', 'title')),
192 'description': data_json
.get('description'),
194 'season_number': int_or_none(
195 self
._search
_regex
(r
'Season (\d+)', season
, 'Season Number', default
=None)),
196 'episode_number': data_json
.get('sequence') or None,
200 class MxplayerShowIE(InfoExtractor
):
201 _VALID_URL
= r
'https?://(?:www\.)?mxplayer\.in/show/(?P<display_id>[-\w]+)-(?P<id>\w+)/?(?:$|[#?])'
203 'url': 'https://www.mxplayer.in/show/watch-chakravartin-ashoka-samrat-series-online-a8f44e3cc0814b5601d17772cedf5417',
204 'playlist_mincount': 440,
206 'id': 'a8f44e3cc0814b5601d17772cedf5417',
207 'title': 'Watch Chakravartin Ashoka Samrat Series Online',
211 _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'
212 _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 def _entries(self
, show_id
):
215 show_json
= self
._download
_json
(
216 self
._API
_SHOW
_URL
.format(show_id
),
217 video_id
=show_id
, headers
={'Referer': 'https://mxplayer.in'})
219 for season
in show_json
.get('items') or []:
220 season_id
= try_get(season
, lambda x
: x
['id'], str)
222 while next_url
is not None:
224 season_json
= self
._download
_json
(
225 self
._API
_EPISODES
_URL
.format(season_id
, next_url
),
227 headers
={'Referer': 'https://mxplayer.in'},
228 note
=f
'Downloading JSON metadata page {page_num}')
229 for episode
in season_json
.get('items') or []:
230 video_url
= episode
['webUrl']
231 yield self
.url_result(
232 f
'https://mxplayer.in{video_url}',
233 ie
=MxplayerIE
.ie_key(), video_id
=video_url
.split('-')[-1])
234 next_url
= season_json
.get('next')
236 def _real_extract(self
, url
):
237 display_id
, show_id
= self
._match
_valid
_url
(url
).groups()
238 return self
.playlist_result(
239 self
._entries
(show_id
), playlist_id
=show_id
,
240 playlist_title
=display_id
.replace('-', ' ').title())