shemaroome.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. from .common import InfoExtractor
  2. from ..aes import aes_cbc_decrypt, unpad_pkcs7
  3. from ..compat import (
  4. compat_b64decode,
  5. )
  6. from ..utils import (
  7. bytes_to_intlist,
  8. ExtractorError,
  9. intlist_to_bytes,
  10. unified_strdate,
  11. )
  12. class ShemarooMeIE(InfoExtractor):
  13. _VALID_URL = r'https?://(?:www\.)?shemaroome\.com/(?:movies|shows)/(?P<id>[^?#]+)'
  14. _TESTS = [{
  15. 'url': 'https://www.shemaroome.com/movies/dil-hai-tumhaara',
  16. 'info_dict': {
  17. 'id': 'dil-hai-tumhaara',
  18. 'ext': 'mp4',
  19. 'title': 'Dil Hai Tumhaara',
  20. 'release_date': '20020906',
  21. 'thumbnail': r're:^https?://.*\.jpg$',
  22. 'description': 'md5:2782c4127807103cf5a6ae2ca33645ce',
  23. },
  24. 'params': {
  25. 'skip_download': True
  26. }
  27. }, {
  28. 'url': 'https://www.shemaroome.com/shows/jurm-aur-jazbaat/laalach',
  29. 'info_dict': {
  30. 'id': 'jurm-aur-jazbaat_laalach',
  31. 'ext': 'mp4',
  32. 'title': 'Laalach',
  33. 'description': 'md5:92b79c2dcb539b0ab53f9fa5a048f53c',
  34. 'thumbnail': r're:^https?://.*\.jpg$',
  35. 'release_date': '20210507',
  36. },
  37. 'params': {
  38. 'skip_download': True
  39. },
  40. 'skip': 'Premium videos cannot be downloaded yet.'
  41. }, {
  42. 'url': 'https://www.shemaroome.com/shows/jai-jai-jai-bajrang-bali/jai-jai-jai-bajrang-bali-episode-99',
  43. 'info_dict': {
  44. 'id': 'jai-jai-jai-bajrang-bali_jai-jai-jai-bajrang-bali-episode-99',
  45. 'ext': 'mp4',
  46. 'title': 'Jai Jai Jai Bajrang Bali Episode 99',
  47. 'description': 'md5:850d127a18ee3f9529d7fbde2f49910d',
  48. 'thumbnail': r're:^https?://.*\.jpg$',
  49. 'release_date': '20110101',
  50. },
  51. 'params': {
  52. 'skip_download': True
  53. }
  54. }]
  55. def _real_extract(self, url):
  56. video_id = self._match_id(url).replace('/', '_')
  57. webpage = self._download_webpage(url, video_id)
  58. title = self._search_regex(r'id=\"ma_title\" value=\"([^\"]+)', webpage, 'title')
  59. thumbnail = self._og_search_thumbnail(webpage)
  60. content_def = self._search_regex(r'id=\"content_definition\" value=\"([^\"]+)', webpage, 'content_def')
  61. catalog_id = self._search_regex(r'id=\"catalog_id\" value=\"([^\"]+)', webpage, 'catalog_id')
  62. item_category = self._search_regex(r'id=\"item_category\" value=\"([^\"]+)', webpage, 'item_category')
  63. content_id = self._search_regex(r'id=\"content_id\" value=\"([^\"]+)', webpage, 'content_id')
  64. data = f'catalog_id={catalog_id}&content_id={content_id}&category={item_category}&content_def={content_def}'
  65. data_json = self._download_json('https://www.shemaroome.com/users/user_all_lists', video_id, data=data.encode())
  66. if not data_json.get('status'):
  67. raise ExtractorError('Premium videos cannot be downloaded yet.', expected=True)
  68. url_data = bytes_to_intlist(compat_b64decode(data_json['new_play_url']))
  69. key = bytes_to_intlist(compat_b64decode(data_json['key']))
  70. iv = [0] * 16
  71. m3u8_url = unpad_pkcs7(intlist_to_bytes(aes_cbc_decrypt(url_data, key, iv))).decode('ascii')
  72. formats, m3u8_subs = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id, fatal=False, headers={'stream_key': data_json['stream_key']})
  73. release_date = self._html_search_regex(
  74. (r'itemprop="uploadDate">\s*([\d-]+)', r'id="release_date" value="([\d-]+)'),
  75. webpage, 'release date', fatal=False)
  76. subtitles = {}
  77. sub_url = data_json.get('subtitle')
  78. if sub_url:
  79. subtitles.setdefault('EN', []).append({
  80. 'url': self._proto_relative_url(sub_url),
  81. })
  82. subtitles = self._merge_subtitles(subtitles, m3u8_subs)
  83. description = self._html_search_regex(r'(?s)>Synopsis(</.+?)</', webpage, 'description', fatal=False)
  84. return {
  85. 'id': video_id,
  86. 'formats': formats,
  87. 'title': title,
  88. 'thumbnail': thumbnail,
  89. 'release_date': unified_strdate(release_date),
  90. 'description': description,
  91. 'subtitles': subtitles,
  92. }