1 from .common
import InfoExtractor
2 from ..compat
import compat_str
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+)'
14 'url': 'https://www.mxplayer.in/show/watch-my-girlfriend-is-an-alien-hindi-dubbed/season-1/episode-1-online-9d2013d31d5835bb8400e3b3c5e7bb72',
16 'id': '9d2013d31d5835bb8400e3b3c5e7bb72',
17 'display_id': 'episode-1-online',
20 'description': 'md5:62ed43eb9fec5efde5cf3bd1040b7670',
25 'series': 'My Girlfriend Is An Alien (Hindi Dubbed)',
26 'episode': 'Episode 1'
30 'skip_download': True,
33 'url': 'https://www.mxplayer.in/movie/watch-knock-knock-hindi-dubbed-movie-online-b9fa28df3bfb8758874735bbd7d2655a?watch=true',
35 'id': 'b9fa28df3bfb8758874735bbd7d2655a',
36 'display_id': 'episode-1-online',
38 'title': 'Knock Knock (Hindi Dubbed)',
39 'description': 'md5:4160f2dfc3b87c524261366f6b736329',
44 'skip_download': True,
46 'skip': 'No longer available',
48 'url': 'https://www.mxplayer.in/show/watch-shaitaan/season-1/the-infamous-taxi-gang-of-meerut-online-45055d5bcff169ad48f2ad7552a83d6c',
50 'id': '45055d5bcff169ad48f2ad7552a83d6c',
52 'title': 'The infamous taxi gang of Meerut',
53 'description': 'md5:033a0a7e3fd147be4fb7e07a01a3dc28',
59 'episode': 'Episode 1'
63 'skip_download': True,
65 'skip': 'No longer available.'
67 'url': 'https://www.mxplayer.in/show/watch-aashram/chapter-1/duh-swapna-online-d445579792b0135598ba1bc9088a84cb',
69 'id': 'd445579792b0135598ba1bc9088a84cb',
70 'display_id': 'duh-swapna-online',
72 'title': 'Duh Swapna',
73 'description': 'md5:35ff39c4bdac403c53be1e16a04192d8',
79 'episode': 'Episode 3'
83 'skip_download': True,
86 'url': 'https://www.mxplayer.in/show/watch-dangerous/season-1/chapter-1-online-5a351b4f9fb69436f6bd6ae3a1a75292',
88 'id': '5a351b4f9fb69436f6bd6ae3a1a75292',
89 'display_id': 'chapter-1-online',
92 'description': 'md5:233886b8598bc91648ac098abe1d288f',
97 'series': 'Dangerous',
98 'episode': 'Episode 1'
102 'skip_download': True,
105 'url': 'https://www.mxplayer.in/movie/watch-the-attacks-of-2611-movie-online-0452f0d80226c398d63ce7e3ea40fa2d',
107 'id': '0452f0d80226c398d63ce7e3ea40fa2d',
109 'title': 'The Attacks of 26/11',
110 'description': 'md5:689bacd29e97b3f31eaf519eb14127e5',
115 'skip_download': True,
117 'skip': 'No longer available. Cannot be played on browser'
119 'url': 'https://www.mxplayer.in/movie/watch-kitne-door-kitne-paas-movie-online-a9e9c76c566205955f70d8b2cb88a6a2',
121 'id': 'a9e9c76c566205955f70d8b2cb88a6a2',
122 'display_id': 'watch-kitne-door-kitne-paas-movie-online',
123 'title': 'Kitne Door Kitne Paas',
126 'description': 'md5:fb825f3c542513088024dcafef0921b4',
130 'skip_download': True,
133 'url': 'https://www.mxplayer.in/show/watch-ek-thi-begum-hindi/season-2/game-of-power-online-5e5305c28f1409847cdc4520b6ad77cf',
135 'id': '5e5305c28f1409847cdc4520b6ad77cf',
136 'display_id': 'game-of-power-online',
137 'title': 'Game Of Power',
140 'description': 'md5:1d0948d2a5312d7013792d53542407f9',
141 'series': 'Ek Thi Begum (Hindi)',
142 'season': 'Season 2',
144 'episode': 'Episode 2',
149 'skip_download': True,
152 'url': 'https://www.mxplayer.in/movie/watch-deewane-huye-paagal-movie-online-4f9175c40a11c3994182a65afdd37ec6?watch=true',
154 'id': '4f9175c40a11c3994182a65afdd37ec6',
155 'display_id': 'watch-deewane-huye-paagal-movie-online',
156 'title': 'Deewane Huye Paagal',
159 'description': 'md5:d17bd5c651016c4ed2e6f8a4ace15534',
161 'params': {'skip_download': 'm3u8'}
,
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'
169 data_json
= self
._download
_json
(
170 f
'https://api.mxplay.com/v1/web/detail/video?type={video_type}&id={video_id}', display_id
)
172 formats
, subtitles
= [], {}
173 m3u8_url
= urljoin('https://llvod.mxplay.com/', traverse_obj(
174 data_json
, ('stream', (('thirdParty', 'hlsUrl'), ('hls', 'high'))), get_all
=False))
176 formats
, subtitles
= self
._extract
_m
3u8_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))
180 fmts
, subs
= self
._extract
_mpd
_formats
_and
_subtitles
(mpd_url
, display_id
, fatal
=False)
182 self
._merge
_subtitles
(subs
, target
=subtitles
)
184 season
= traverse_obj(data_json
, ('container', 'title'))
187 'title': data_json
.get('title'),
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'),
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,
201 class MxplayerShowIE(InfoExtractor
):
202 _VALID_URL
= r
'https?://(?:www\.)?mxplayer\.in/show/(?P<display_id>[-\w]+)-(?P<id>\w+)/?(?:$|[#?])'
204 'url': 'https://www.mxplayer.in/show/watch-chakravartin-ashoka-samrat-series-online-a8f44e3cc0814b5601d17772cedf5417',
205 'playlist_mincount': 440,
207 'id': 'a8f44e3cc0814b5601d17772cedf5417',
208 'title': 'Watch Chakravartin Ashoka Samrat Series Online',
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&{}"
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'}
)
220 for season
in show_json
.get('items') or []:
221 season_id
= try_get(season
, lambda x
: x
['id'], compat_str
)
223 while next_url
is not None:
225 season_json
= self
._download
_json
(
226 self
._API
_EPISODES
_URL
.format(season_id
, next_url
),
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')
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())