cam4.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. from .common import InfoExtractor
  2. class CAM4IE(InfoExtractor):
  3. _VALID_URL = r'https?://(?:[^/]+\.)?cam4\.com/(?P<id>[a-z0-9_]+)'
  4. _TEST = {
  5. 'url': 'https://www.cam4.com/foxynesss',
  6. 'info_dict': {
  7. 'id': 'foxynesss',
  8. 'ext': 'mp4',
  9. 'title': 're:^foxynesss [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
  10. 'age_limit': 18,
  11. 'live_status': 'is_live',
  12. 'thumbnail': 'https://snapshots.xcdnpro.com/thumbnails/foxynesss',
  13. },
  14. }
  15. def _real_extract(self, url):
  16. channel_id = self._match_id(url)
  17. m3u8_playlist = self._download_json(f'https://www.cam4.com/rest/v1.0/profile/{channel_id}/streamInfo', channel_id).get('cdnURL')
  18. formats = self._extract_m3u8_formats(m3u8_playlist, channel_id, 'mp4', m3u8_id='hls', live=True)
  19. return {
  20. 'id': channel_id,
  21. 'title': channel_id,
  22. 'is_live': True,
  23. 'age_limit': 18,
  24. 'formats': formats,
  25. 'thumbnail': f'https://snapshots.xcdnpro.com/thumbnails/{channel_id}',
  26. }