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.

69 lines
2.1 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. unified_timestamp,
  7. )
  8. class CamTubeIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:(?:www|api)\.)?camtube\.co/recordings?/(?P<id>[^/?#&]+)'
  10. _TESTS = [{
  11. 'url': 'https://camtube.co/recording/minafay-030618-1136-chaturbate-female',
  12. 'info_dict': {
  13. 'id': '42ad3956-dd5b-445a-8313-803ea6079fac',
  14. 'display_id': 'minafay-030618-1136-chaturbate-female',
  15. 'ext': 'mp4',
  16. 'title': 'minafay-030618-1136-chaturbate-female',
  17. 'duration': 1274,
  18. 'timestamp': 1528018608,
  19. 'upload_date': '20180603',
  20. },
  21. 'params': {
  22. 'skip_download': True,
  23. },
  24. }]
  25. _API_BASE = 'https://api.camtube.co'
  26. def _real_extract(self, url):
  27. display_id = self._match_id(url)
  28. token = self._download_json(
  29. '%s/rpc/session/new' % self._API_BASE, display_id,
  30. 'Downloading session token')['token']
  31. self._set_cookie('api.camtube.co', 'session', token)
  32. video = self._download_json(
  33. '%s/recordings/%s' % (self._API_BASE, display_id), display_id,
  34. headers={'Referer': url})
  35. video_id = video['uuid']
  36. timestamp = unified_timestamp(video.get('createdAt'))
  37. duration = int_or_none(video.get('duration'))
  38. view_count = int_or_none(video.get('viewCount'))
  39. like_count = int_or_none(video.get('likeCount'))
  40. creator = video.get('stageName')
  41. formats = [{
  42. 'url': '%s/recordings/%s/manifest.m3u8'
  43. % (self._API_BASE, video_id),
  44. 'format_id': 'hls',
  45. 'ext': 'mp4',
  46. 'protocol': 'm3u8_native',
  47. }]
  48. return {
  49. 'id': video_id,
  50. 'display_id': display_id,
  51. 'title': display_id,
  52. 'timestamp': timestamp,
  53. 'duration': duration,
  54. 'view_count': view_count,
  55. 'like_count': like_count,
  56. 'creator': creator,
  57. 'formats': formats,
  58. }