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

cineverse.py (5809B)


  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. filter_dict,
  5. float_or_none,
  6. int_or_none,
  7. parse_age_limit,
  8. smuggle_url,
  9. traverse_obj,
  10. unsmuggle_url,
  11. url_or_none,
  12. )
  13. class CineverseBaseIE(InfoExtractor):
  14. _VALID_URL_BASE = r'https?://www\.(?P<host>{})'.format('|'.join(map(re.escape, (
  15. 'cineverse.com',
  16. 'asiancrush.com',
  17. 'dovechannel.com',
  18. 'screambox.com',
  19. 'midnightpulp.com',
  20. 'fandor.com',
  21. 'retrocrush.tv',
  22. ))))
  23. class CineverseIE(CineverseBaseIE):
  24. _VALID_URL = rf'{CineverseBaseIE._VALID_URL_BASE}/watch/(?P<id>[A-Z0-9]+)'
  25. _TESTS = [{
  26. 'url': 'https://www.asiancrush.com/watch/DMR00018919/Women-Who-Flirt',
  27. 'skip': 'geo-blocked',
  28. 'info_dict': {
  29. 'title': 'Women Who Flirt',
  30. 'ext': 'mp4',
  31. 'id': 'DMR00018919',
  32. 'modified_timestamp': 1678744575289,
  33. 'cast': ['Xun Zhou', 'Xiaoming Huang', 'Yi-Lin Sie', 'Sonia Sui', 'Quniciren'],
  34. 'duration': 5811.597,
  35. 'description': 'md5:892fd62a05611d394141e8394ace0bc6',
  36. 'age_limit': 13,
  37. },
  38. }, {
  39. 'url': 'https://www.retrocrush.tv/watch/1000000023016/Archenemy! Crystal Bowie',
  40. 'skip': 'geo-blocked',
  41. 'info_dict': {
  42. 'title': 'Archenemy! Crystal Bowie',
  43. 'ext': 'mp4',
  44. 'id': '1000000023016',
  45. 'episode_number': 3,
  46. 'season_number': 1,
  47. 'cast': ['Nachi Nozawa', 'Yoshiko Sakakibara', 'Toshiko Fujita'],
  48. 'age_limit': 0,
  49. 'episode': 'Episode 3',
  50. 'season': 'Season 1',
  51. 'duration': 1485.067,
  52. 'description': 'Cobra meets a beautiful bounty hunter by the name of Jane Royal.',
  53. 'series': 'Space Adventure COBRA (Original Japanese)',
  54. },
  55. }]
  56. def _real_extract(self, url):
  57. url, smuggled_data = unsmuggle_url(url, default={})
  58. self._initialize_geo_bypass({
  59. 'countries': smuggled_data.get('geo_countries'),
  60. })
  61. video_id = self._match_id(url)
  62. html = self._download_webpage(url, video_id)
  63. idetails = self._search_nextjs_data(html, video_id)['props']['pageProps']['idetails']
  64. err_code = idetails.get('err_code')
  65. if err_code == 1002:
  66. self.raise_login_required()
  67. elif err_code == 1200:
  68. self.raise_geo_restricted(
  69. 'This video is not available from your location due to geo restriction. '
  70. 'You may be able to bypass it by using the /details/ page instead of the /watch/ page',
  71. countries=smuggled_data.get('geo_countries'))
  72. return {
  73. 'subtitles': filter_dict({
  74. 'en': traverse_obj(idetails, (('cc_url_vtt', 'subtitle_url'), {'url': {url_or_none}})) or None,
  75. }),
  76. 'formats': self._extract_m3u8_formats(idetails['url'], video_id),
  77. **traverse_obj(idetails, {
  78. 'title': 'title',
  79. 'id': ('details', 'item_id'),
  80. 'description': ('details', 'description'),
  81. 'duration': ('duration', {float_or_none(scale=1000)}),
  82. 'cast': ('details', 'cast', {lambda x: x.split(', ')}),
  83. 'modified_timestamp': ('details', 'updated_by', 0, 'update_time', 'time', {int_or_none}),
  84. 'season_number': ('details', 'season', {int_or_none}),
  85. 'episode_number': ('details', 'episode', {int_or_none}),
  86. 'age_limit': ('details', 'rating_code', {parse_age_limit}),
  87. 'series': ('details', 'series_details', 'title'),
  88. }),
  89. }
  90. class CineverseDetailsIE(CineverseBaseIE):
  91. _VALID_URL = rf'{CineverseBaseIE._VALID_URL_BASE}/details/(?P<id>[A-Z0-9]+)'
  92. _TESTS = [{
  93. 'url': 'https://www.retrocrush.tv/details/1000000023012/Space-Adventure-COBRA-(Original-Japanese)',
  94. 'playlist_mincount': 30,
  95. 'info_dict': {
  96. 'title': 'Space Adventure COBRA (Original Japanese)',
  97. 'id': '1000000023012',
  98. },
  99. }, {
  100. 'url': 'https://www.asiancrush.com/details/NNVG4938/Hansel-and-Gretel',
  101. 'info_dict': {
  102. 'id': 'NNVG4938',
  103. 'ext': 'mp4',
  104. 'title': 'Hansel and Gretel',
  105. 'description': 'md5:e3e4c35309c2e82aee044f972c2fb05d',
  106. 'cast': ['Jeong-myeong Cheon', 'Eun Won-jae', 'Shim Eun-gyeong', 'Ji-hee Jin', 'Hee-soon Park', 'Lydia Park', 'Kyeong-ik Kim'],
  107. 'duration': 7030.732,
  108. },
  109. }]
  110. def _real_extract(self, url):
  111. host, series_id = self._match_valid_url(url).group('host', 'id')
  112. html = self._download_webpage(url, series_id)
  113. pageprops = self._search_nextjs_data(html, series_id)['props']['pageProps']
  114. geo_countries = traverse_obj(pageprops, ('itemDetailsData', 'geo_country', {lambda x: x.split(', ')}))
  115. geoblocked = traverse_obj(pageprops, (
  116. 'itemDetailsData', 'playback_err_msg')) == 'This title is not available in your location.'
  117. def item_result(item):
  118. item_url = f'https://www.{host}/watch/{item["item_id"]}/{item["title"]}'
  119. if geoblocked:
  120. item_url = smuggle_url(item_url, {'geo_countries': geo_countries})
  121. return self.url_result(item_url, CineverseIE)
  122. season = traverse_obj(pageprops, ('seasonEpisodes', ..., 'episodes', lambda _, v: v['item_id'] and v['title']))
  123. if season:
  124. return self.playlist_result([item_result(ep) for ep in season], playlist_id=series_id,
  125. playlist_title=traverse_obj(pageprops, ('itemDetailsData', 'title')))
  126. return item_result(pageprops['itemDetailsData'])