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

stripchat.py (2503B)


  1. from .common import InfoExtractor
  2. from ..utils import (
  3. ExtractorError,
  4. UserNotLive,
  5. lowercase_escape,
  6. traverse_obj,
  7. )
  8. class StripchatIE(InfoExtractor):
  9. _VALID_URL = r'https?://stripchat\.com/(?P<id>[^/?#]+)'
  10. _TESTS = [{
  11. 'url': 'https://stripchat.com/Joselin_Flower',
  12. 'info_dict': {
  13. 'id': 'Joselin_Flower',
  14. 'ext': 'mp4',
  15. 'title': 're:^Joselin_Flower [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
  16. 'description': str,
  17. 'is_live': True,
  18. 'age_limit': 18,
  19. },
  20. 'skip': 'Room is offline',
  21. }, {
  22. 'url': 'https://stripchat.com/Rakhijaan@xh',
  23. 'only_matching': True,
  24. }]
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. webpage = self._download_webpage(url, video_id, headers=self.geo_verification_headers())
  28. data = self._search_json(
  29. r'<script\b[^>]*>\s*window\.__PRELOADED_STATE__\s*=',
  30. webpage, 'data', video_id, transform_source=lowercase_escape)
  31. if traverse_obj(data, ('viewCam', 'show', {dict})):
  32. raise ExtractorError('Model is in a private show', expected=True)
  33. if not traverse_obj(data, ('viewCam', 'model', 'isLive', {bool})):
  34. raise UserNotLive(video_id=video_id)
  35. model_id = data['viewCam']['model']['id']
  36. formats = []
  37. # HLS hosts are currently found in .configV3.static.features.hlsFallback.fallbackDomains[]
  38. # The rest of the path is for backwards compatibility and to guard against A/B testing
  39. for host in traverse_obj(data, ((('config', 'data'), ('configV3', 'static')), (
  40. (('features', 'featuresV2'), 'hlsFallback', 'fallbackDomains', ...), 'hlsStreamHost'))):
  41. formats = self._extract_m3u8_formats(
  42. f'https://edge-hls.{host}/hls/{model_id}/master/{model_id}_auto.m3u8',
  43. video_id, ext='mp4', m3u8_id='hls', fatal=False, live=True)
  44. if formats:
  45. break
  46. if not formats:
  47. self.raise_no_formats('Unable to extract stream host', video_id=video_id)
  48. return {
  49. 'id': video_id,
  50. 'title': video_id,
  51. 'description': self._og_search_description(webpage),
  52. 'is_live': True,
  53. 'formats': formats,
  54. # Stripchat declares the RTA meta-tag, but in an non-standard format so _rta_search() can't be used
  55. 'age_limit': 18,
  56. }