alphaporno.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. int_or_none,
  4. parse_duration,
  5. parse_filesize,
  6. parse_iso8601,
  7. )
  8. class AlphaPornoIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?alphaporno\.com/videos/(?P<id>[^/]+)'
  10. _TEST = {
  11. 'url': 'http://www.alphaporno.com/videos/sensual-striptease-porn-with-samantha-alexandra/',
  12. 'md5': 'feb6d3bba8848cd54467a87ad34bd38e',
  13. 'info_dict': {
  14. 'id': '258807',
  15. 'display_id': 'sensual-striptease-porn-with-samantha-alexandra',
  16. 'ext': 'mp4',
  17. 'title': 'Sensual striptease porn with Samantha Alexandra',
  18. 'thumbnail': r're:https?://.*\.jpg$',
  19. 'timestamp': 1418694611,
  20. 'upload_date': '20141216',
  21. 'duration': 387,
  22. 'filesize_approx': 54120000,
  23. 'tbr': 1145,
  24. 'categories': list,
  25. 'age_limit': 18,
  26. },
  27. }
  28. def _real_extract(self, url):
  29. display_id = self._match_id(url)
  30. webpage = self._download_webpage(url, display_id)
  31. video_id = self._search_regex(
  32. r"video_id\s*:\s*'([^']+)'", webpage, 'video id', default=None)
  33. video_url = self._search_regex(
  34. r"video_url\s*:\s*'([^']+)'", webpage, 'video url')
  35. ext = self._html_search_meta(
  36. 'encodingFormat', webpage, 'ext', default='.mp4')[1:]
  37. title = self._search_regex(
  38. [r'<meta content="([^"]+)" itemprop="description">',
  39. r'class="title" itemprop="name">([^<]+)<'],
  40. webpage, 'title')
  41. thumbnail = self._html_search_meta('thumbnail', webpage, 'thumbnail')
  42. timestamp = parse_iso8601(self._html_search_meta(
  43. 'uploadDate', webpage, 'upload date'))
  44. duration = parse_duration(self._html_search_meta(
  45. 'duration', webpage, 'duration'))
  46. filesize_approx = parse_filesize(self._html_search_meta(
  47. 'contentSize', webpage, 'file size'))
  48. bitrate = int_or_none(self._html_search_meta(
  49. 'bitrate', webpage, 'bitrate'))
  50. categories = self._html_search_meta(
  51. 'keywords', webpage, 'categories', default='').split(',')
  52. age_limit = self._rta_search(webpage)
  53. return {
  54. 'id': video_id,
  55. 'display_id': display_id,
  56. 'url': video_url,
  57. 'ext': ext,
  58. 'title': title,
  59. 'thumbnail': thumbnail,
  60. 'timestamp': timestamp,
  61. 'duration': duration,
  62. 'filesize_approx': filesize_approx,
  63. 'tbr': bitrate,
  64. 'categories': categories,
  65. 'age_limit': age_limit,
  66. }