logo

youtube-dl

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

pornotube.py (3154B)


  1. from __future__ import unicode_literals
  2. import json
  3. from .common import InfoExtractor
  4. from ..utils import int_or_none
  5. class PornotubeIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:\w+\.)?pornotube\.com/(?:[^?#]*?)/video/(?P<id>[0-9]+)'
  7. _TEST = {
  8. 'url': 'http://www.pornotube.com/orientation/straight/video/4964/title/weird-hot-and-wet-science',
  9. 'md5': '60fc5a4f0d93a97968fc7999d98260c9',
  10. 'info_dict': {
  11. 'id': '4964',
  12. 'ext': 'mp4',
  13. 'upload_date': '20141203',
  14. 'title': 'Weird Hot and Wet Science',
  15. 'description': 'md5:a8304bef7ef06cb4ab476ca6029b01b0',
  16. 'categories': ['Adult Humor', 'Blondes'],
  17. 'uploader': 'Alpha Blue Archives',
  18. 'thumbnail': r're:^https?://.*\.jpg$',
  19. 'timestamp': 1417582800,
  20. 'age_limit': 18,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. token = self._download_json(
  26. 'https://api.aebn.net/auth/v2/origins/authenticate',
  27. video_id, note='Downloading token',
  28. data=json.dumps({'credentials': 'Clip Application'}).encode('utf-8'),
  29. headers={
  30. 'Content-Type': 'application/json',
  31. 'Origin': 'http://www.pornotube.com',
  32. })['tokenKey']
  33. video_url = self._download_json(
  34. 'https://api.aebn.net/delivery/v1/clips/%s/MP4' % video_id,
  35. video_id, note='Downloading delivery information',
  36. headers={'Authorization': token})['mediaUrl']
  37. FIELDS = (
  38. 'title', 'description', 'startSecond', 'endSecond', 'publishDate',
  39. 'studios{name}', 'categories{name}', 'movieId', 'primaryImageNumber'
  40. )
  41. info = self._download_json(
  42. 'https://api.aebn.net/content/v2/clips/%s?fields=%s'
  43. % (video_id, ','.join(FIELDS)), video_id,
  44. note='Downloading metadata',
  45. headers={'Authorization': token})
  46. if isinstance(info, list):
  47. info = info[0]
  48. title = info['title']
  49. timestamp = int_or_none(info.get('publishDate'), scale=1000)
  50. uploader = info.get('studios', [{}])[0].get('name')
  51. movie_id = info.get('movieId')
  52. primary_image_number = info.get('primaryImageNumber')
  53. thumbnail = None
  54. if movie_id and primary_image_number:
  55. thumbnail = 'http://pic.aebn.net/dis/t/%s/%s_%08d.jpg' % (
  56. movie_id, movie_id, primary_image_number)
  57. start = int_or_none(info.get('startSecond'))
  58. end = int_or_none(info.get('endSecond'))
  59. duration = end - start if start and end else None
  60. categories = [c['name'] for c in info.get('categories', []) if c.get('name')]
  61. return {
  62. 'id': video_id,
  63. 'url': video_url,
  64. 'title': title,
  65. 'description': info.get('description'),
  66. 'duration': duration,
  67. 'timestamp': timestamp,
  68. 'uploader': uploader,
  69. 'thumbnail': thumbnail,
  70. 'categories': categories,
  71. 'age_limit': 18,
  72. }