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.

70 lines
2.3 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_duration,
  6. int_or_none,
  7. qualities,
  8. determine_ext,
  9. )
  10. class SunPornoIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:www\.)?sunporno\.com/videos/(?P<id>\d+)'
  12. _TEST = {
  13. 'url': 'http://www.sunporno.com/videos/807778/',
  14. 'md5': '6457d3c165fd6de062b99ef6c2ff4c86',
  15. 'info_dict': {
  16. 'id': '807778',
  17. 'ext': 'flv',
  18. 'title': 'md5:0a400058e8105d39e35c35e7c5184164',
  19. 'description': 'md5:a31241990e1bd3a64e72ae99afb325fb',
  20. 'thumbnail': 're:^https?://.*\.jpg$',
  21. 'duration': 302,
  22. 'age_limit': 18,
  23. }
  24. }
  25. def _real_extract(self, url):
  26. mobj = re.match(self._VALID_URL, url)
  27. video_id = mobj.group('id')
  28. webpage = self._download_webpage(url, video_id)
  29. title = self._html_search_regex(r'<title>([^<]+)</title>', webpage, 'title')
  30. description = self._html_search_meta('description', webpage, 'description')
  31. thumbnail = self._html_search_regex(
  32. r'poster="([^"]+)"', webpage, 'thumbnail', fatal=False)
  33. duration = parse_duration(self._search_regex(
  34. r'Duration:\s*(\d+:\d+)\s*<', webpage, 'duration', fatal=False))
  35. view_count = int_or_none(self._html_search_regex(
  36. r'class="views">\s*(\d+)\s*<', webpage, 'view count', fatal=False))
  37. comment_count = int_or_none(self._html_search_regex(
  38. r'(\d+)</b> Comments?', webpage, 'comment count', fatal=False))
  39. formats = []
  40. quality = qualities(['mp4', 'flv'])
  41. for video_url in re.findall(r'<source src="([^"]+)"', webpage):
  42. video_ext = determine_ext(video_url)
  43. formats.append({
  44. 'url': video_url,
  45. 'format_id': video_ext,
  46. 'quality': quality(video_ext),
  47. })
  48. self._sort_formats(formats)
  49. return {
  50. 'id': video_id,
  51. 'title': title,
  52. 'description': description,
  53. 'thumbnail': thumbnail,
  54. 'duration': duration,
  55. 'view_count': view_count,
  56. 'comment_count': comment_count,
  57. 'formats': formats,
  58. 'age_limit': 18,
  59. }