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.

71 lines
2.2 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. js_to_json,
  6. remove_end,
  7. )
  8. class HellPornoIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?hellporno\.com/videos/(?P<id>[^/]+)'
  10. _TEST = {
  11. 'url': 'http://hellporno.com/videos/dixie-is-posing-with-naked-ass-very-erotic/',
  12. 'md5': '1fee339c610d2049699ef2aa699439f1',
  13. 'info_dict': {
  14. 'id': '149116',
  15. 'display_id': 'dixie-is-posing-with-naked-ass-very-erotic',
  16. 'ext': 'mp4',
  17. 'title': 'Dixie is posing with naked ass very erotic',
  18. 'thumbnail': 're:https?://.*\.jpg$',
  19. 'age_limit': 18,
  20. }
  21. }
  22. def _real_extract(self, url):
  23. display_id = self._match_id(url)
  24. webpage = self._download_webpage(url, display_id)
  25. title = remove_end(self._html_search_regex(
  26. r'<title>([^<]+)</title>', webpage, 'title'), ' - Hell Porno')
  27. flashvars = self._parse_json(self._search_regex(
  28. r'var\s+flashvars\s*=\s*({.+?});', webpage, 'flashvars'),
  29. display_id, transform_source=js_to_json)
  30. video_id = flashvars.get('video_id')
  31. thumbnail = flashvars.get('preview_url')
  32. ext = flashvars.get('postfix', '.mp4')[1:]
  33. formats = []
  34. for video_url_key in ['video_url', 'video_alt_url']:
  35. video_url = flashvars.get(video_url_key)
  36. if not video_url:
  37. continue
  38. video_text = flashvars.get('%s_text' % video_url_key)
  39. fmt = {
  40. 'url': video_url,
  41. 'ext': ext,
  42. 'format_id': video_text,
  43. }
  44. m = re.search(r'^(?P<height>\d+)[pP]', video_text)
  45. if m:
  46. fmt['height'] = int(m.group('height'))
  47. formats.append(fmt)
  48. self._sort_formats(formats)
  49. categories = self._html_search_meta(
  50. 'keywords', webpage, 'categories', default='').split(',')
  51. return {
  52. 'id': video_id,
  53. 'display_id': display_id,
  54. 'title': title,
  55. 'thumbnail': thumbnail,
  56. 'categories': categories,
  57. 'age_limit': 18,
  58. 'formats': formats,
  59. }