mzaalo.py 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. parse_age_limit,
  4. parse_duration,
  5. traverse_obj,
  6. url_or_none,
  7. )
  8. class MzaaloIE(InfoExtractor):
  9. _VALID_URL = r'(?i)https?://(?:www\.)?mzaalo\.com/(?:play|watch)/(?P<type>movie|original|clip)/(?P<id>[a-f0-9-]+)/[\w-]+'
  10. _TESTS = [{
  11. # Movies
  12. 'url': 'https://www.mzaalo.com/play/movie/c0958d9f-f90e-4503-a755-44358758921d/Jamun',
  13. 'info_dict': {
  14. 'id': 'c0958d9f-f90e-4503-a755-44358758921d',
  15. 'title': 'Jamun',
  16. 'ext': 'mp4',
  17. 'description': 'md5:24fe9ebb9bbe5b36f7b54b90ab1e2f31',
  18. 'thumbnails': 'count:15',
  19. 'thumbnail': r're:^https?://.*\.jpg$',
  20. 'duration': 5527.0,
  21. 'language': 'hin',
  22. 'categories': ['Drama'],
  23. 'age_limit': 13,
  24. },
  25. 'params': {'skip_download': 'm3u8'},
  26. }, {
  27. # Shows
  28. 'url': 'https://www.mzaalo.com/play/original/93d42b2b-f373-4c2d-bca4-997412cb069d/Modi-Season-2-CM-TO-PM/Episode-1:Decision,-Not-Promises',
  29. 'info_dict': {
  30. 'id': '93d42b2b-f373-4c2d-bca4-997412cb069d',
  31. 'title': 'Episode 1:Decision, Not Promises',
  32. 'ext': 'mp4',
  33. 'description': 'md5:16f76058432a54774fbb2561a1955652',
  34. 'thumbnails': 'count:22',
  35. 'thumbnail': r're:^https?://.*\.jpg$',
  36. 'duration': 2040.0,
  37. 'language': 'hin',
  38. 'categories': ['Drama'],
  39. 'age_limit': 13,
  40. },
  41. 'params': {'skip_download': 'm3u8'},
  42. }, {
  43. # Streams/Clips
  44. 'url': 'https://www.mzaalo.com/play/clip/83cdbcb5-400a-42f1-a1d2-459053cfbda5/Manto-Ki-Kahaaniya',
  45. 'info_dict': {
  46. 'id': '83cdbcb5-400a-42f1-a1d2-459053cfbda5',
  47. 'title': 'Manto Ki Kahaaniya',
  48. 'ext': 'mp4',
  49. 'description': 'md5:c3c5f1d05f0fd1bfcb05b673d1cc9f2f',
  50. 'thumbnails': 'count:3',
  51. 'thumbnail': r're:^https?://.*\.jpg$',
  52. 'duration': 1937.0,
  53. 'language': 'hin',
  54. },
  55. 'params': {'skip_download': 'm3u8'},
  56. }, {
  57. 'url': 'https://mzaalo.com/watch/MOVIE/389c892d-0b65-4019-bf73-d4edcb1c014f/Chalo-Dilli',
  58. 'only_matching': True,
  59. }]
  60. def _real_extract(self, url):
  61. video_id, type_ = self._match_valid_url(url).group('id', 'type')
  62. path = (f'partner/streamurl?&assetId={video_id}&getClipDetails=YES' if type_ == 'clip'
  63. else f'api/v2/player/details?assetType={type_.upper()}&assetId={video_id}')
  64. data = self._download_json(
  65. f'https://production.mzaalo.com/platform/{path}', video_id, headers={
  66. 'Ocp-Apim-Subscription-Key': '1d0caac2702049b89a305929fdf4cbae',
  67. })['data']
  68. formats = self._extract_m3u8_formats(data['streamURL'], video_id)
  69. subtitles = {}
  70. for subs_lang, subs_url in traverse_obj(data, ('subtitles', {dict.items}, ...)):
  71. if url_or_none(subs_url):
  72. subtitles[subs_lang] = [{'url': subs_url, 'ext': 'vtt'}]
  73. lang = traverse_obj(data, ('language', {str.lower}))
  74. for f in formats:
  75. f['language'] = lang
  76. return {
  77. 'id': video_id,
  78. 'formats': formats,
  79. 'subtitles': subtitles,
  80. **traverse_obj(data, {
  81. 'title': ('title', {str}),
  82. 'description': ('description', {str}),
  83. 'duration': ('duration', {parse_duration}),
  84. 'age_limit': ('maturity_rating', {parse_age_limit}),
  85. 'thumbnails': ('images', ..., {'url': {url_or_none}}),
  86. 'categories': ('genre', ..., {str}),
  87. }),
  88. }