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

pornbox.py (4447B)


  1. from .common import InfoExtractor
  2. from ..utils import (
  3. int_or_none,
  4. parse_duration,
  5. parse_iso8601,
  6. qualities,
  7. str_or_none,
  8. traverse_obj,
  9. url_or_none,
  10. )
  11. class PornboxIE(InfoExtractor):
  12. _VALID_URL = r'https?://(?:www\.)?pornbox\.com/application/watch-page/(?P<id>[0-9]+)'
  13. _TESTS = [{
  14. 'url': 'https://pornbox.com/application/watch-page/212108',
  15. 'md5': '3ff6b6e206f263be4c5e987a3162ac6e',
  16. 'info_dict': {
  17. 'id': '212108',
  18. 'ext': 'mp4',
  19. 'title': 'md5:ececc5c6e6c9dd35d290c45fed05fd49',
  20. 'uploader': 'Lily Strong',
  21. 'timestamp': 1665871200,
  22. 'upload_date': '20221015',
  23. 'age_limit': 18,
  24. 'availability': 'needs_auth',
  25. 'duration': 1505,
  26. 'cast': ['Lily Strong', 'John Strong'],
  27. 'tags': 'count:11',
  28. 'description': 'md5:589c7f33e183aa8aa939537300efb859',
  29. 'thumbnail': r're:^https?://cdn-image\.gtflixtv\.com.*\.jpg.*$',
  30. },
  31. }, {
  32. 'url': 'https://pornbox.com/application/watch-page/216045',
  33. 'info_dict': {
  34. 'id': '216045',
  35. 'title': 'md5:3e48528e73a9a2b12f7a2772ed0b26a2',
  36. 'description': 'md5:3e631dcaac029f15ed434e402d1b06c7',
  37. 'uploader': 'VK Studio',
  38. 'timestamp': 1618264800,
  39. 'upload_date': '20210412',
  40. 'age_limit': 18,
  41. 'availability': 'premium_only',
  42. 'duration': 2710,
  43. 'cast': 'count:3',
  44. 'tags': 'count:29',
  45. 'thumbnail': r're:^https?://cdn-image\.gtflixtv\.com.*\.jpg.*$',
  46. 'subtitles': 'count:6',
  47. },
  48. 'params': {
  49. 'skip_download': True,
  50. 'ignore_no_formats_error': True,
  51. },
  52. 'expected_warnings': [
  53. 'You are either not logged in or do not have access to this scene',
  54. 'No video formats found', 'Requested format is not available'],
  55. }]
  56. def _real_extract(self, url):
  57. video_id = self._match_id(url)
  58. public_data = self._download_json(f'https://pornbox.com/contents/{video_id}', video_id)
  59. subtitles = {country_code: [{
  60. 'url': f'https://pornbox.com/contents/{video_id}/subtitles/{country_code}',
  61. 'ext': 'srt',
  62. }] for country_code in traverse_obj(public_data, ('subtitles', ..., {str}))}
  63. is_free_scene = traverse_obj(
  64. public_data, ('price', 'is_available_for_free', {bool}), default=False)
  65. metadata = {
  66. 'id': video_id,
  67. **traverse_obj(public_data, {
  68. 'title': ('scene_name', {str.strip}),
  69. 'description': ('small_description', {str.strip}),
  70. 'uploader': 'studio',
  71. 'duration': ('runtime', {parse_duration}),
  72. 'cast': (('models', 'male_models'), ..., 'model_name'),
  73. 'thumbnail': ('player_poster', {url_or_none}),
  74. 'tags': ('niches', ..., 'niche'),
  75. }),
  76. 'age_limit': 18,
  77. 'timestamp': parse_iso8601(traverse_obj(
  78. public_data, ('studios', 'release_date'), 'publish_date')),
  79. 'availability': self._availability(needs_auth=True, needs_premium=not is_free_scene),
  80. 'subtitles': subtitles,
  81. }
  82. if not public_data.get('is_purchased') or not is_free_scene:
  83. self.raise_login_required(
  84. 'You are either not logged in or do not have access to this scene', metadata_available=True)
  85. return metadata
  86. media_id = traverse_obj(public_data, (
  87. 'medias', lambda _, v: v['title'] == 'Full video', 'media_id', {int}), get_all=False)
  88. if not media_id:
  89. self.raise_no_formats('Could not find stream id', video_id=video_id)
  90. stream_data = self._download_json(
  91. f'https://pornbox.com/media/{media_id}/stream', video_id=video_id, note='Getting manifest urls')
  92. get_quality = qualities(['web', 'vga', 'hd', '1080p', '4k', '8k'])
  93. metadata['formats'] = traverse_obj(stream_data, ('qualities', lambda _, v: v['src'], {
  94. 'url': 'src',
  95. 'vbr': ('bitrate', {int_or_none(scale=1000)}),
  96. 'format_id': ('quality', {str_or_none}),
  97. 'quality': ('quality', {get_quality}),
  98. 'width': ('size', {lambda x: int(x[:-1])}),
  99. }))
  100. return metadata