logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

shemaroome.py (4226B)


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