logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

camtube.py (2215B)


  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. 'age_limit': 18
  21. },
  22. 'params': {
  23. 'skip_download': True,
  24. },
  25. }]
  26. _API_BASE = 'https://api.camtube.co'
  27. def _real_extract(self, url):
  28. display_id = self._match_id(url)
  29. token = self._download_json(
  30. '%s/rpc/session/new' % self._API_BASE, display_id,
  31. 'Downloading session token')['token']
  32. self._set_cookie('api.camtube.co', 'session', token)
  33. video = self._download_json(
  34. '%s/recordings/%s' % (self._API_BASE, display_id), display_id,
  35. headers={'Referer': url})
  36. video_id = video['uuid']
  37. timestamp = unified_timestamp(video.get('createdAt'))
  38. duration = int_or_none(video.get('duration'))
  39. view_count = int_or_none(video.get('viewCount'))
  40. like_count = int_or_none(video.get('likeCount'))
  41. creator = video.get('stageName')
  42. formats = [{
  43. 'url': '%s/recordings/%s/manifest.m3u8'
  44. % (self._API_BASE, video_id),
  45. 'format_id': 'hls',
  46. 'ext': 'mp4',
  47. 'protocol': 'm3u8_native',
  48. }]
  49. return {
  50. 'id': video_id,
  51. 'display_id': display_id,
  52. 'title': display_id,
  53. 'timestamp': timestamp,
  54. 'duration': duration,
  55. 'view_count': view_count,
  56. 'like_count': like_count,
  57. 'creator': creator,
  58. 'formats': formats,
  59. 'age_limit': 18
  60. }