You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.6 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import ExtractorError
  4. class ChaturbateIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:[^/]+\.)?chaturbate\.com/(?P<id>[^/?#]+)'
  6. _TESTS = [{
  7. 'url': 'https://www.chaturbate.com/siswet19/',
  8. 'info_dict': {
  9. 'id': 'siswet19',
  10. 'ext': 'mp4',
  11. 'title': 're:^siswet19 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
  12. 'age_limit': 18,
  13. 'is_live': True,
  14. },
  15. 'params': {
  16. 'skip_download': True,
  17. }
  18. }, {
  19. 'url': 'https://en.chaturbate.com/siswet19/',
  20. 'only_matching': True,
  21. }]
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. m3u8_url = self._search_regex(
  26. r'src=(["\'])(?P<url>http.+?\.m3u8.*?)\1', webpage,
  27. 'playlist', default=None, group='url')
  28. if not m3u8_url:
  29. error = self._search_regex(
  30. r'<span[^>]+class=(["\'])desc_span\1[^>]*>(?P<error>[^<]+)</span>',
  31. webpage, 'error', group='error')
  32. raise ExtractorError(error, expected=True)
  33. formats = self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4')
  34. return {
  35. 'id': video_id,
  36. 'title': self._live_title(video_id),
  37. 'thumbnail': 'https://cdn-s.highwebmedia.com/uHK3McUtGCG3SMFcd4ZJsRv8/roomimage/%s.jpg' % video_id,
  38. 'age_limit': self._rta_search(webpage),
  39. 'is_live': True,
  40. 'formats': formats,
  41. }