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.

74 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. video_id = self._match_id(url)
  27. webpage = self._download_webpage(url, video_id)
  28. title = self._html_search_regex(
  29. r'<title>([^<]+)</title>', webpage, 'title')
  30. description = self._html_search_meta(
  31. 'description', webpage, 'description')
  32. thumbnail = self._html_search_regex(
  33. r'poster="([^"]+)"', webpage, 'thumbnail', fatal=False)
  34. duration = parse_duration(self._search_regex(
  35. r'itemprop="duration">\s*(\d+:\d+)\s*<',
  36. webpage, 'duration', fatal=False))
  37. view_count = int_or_none(self._html_search_regex(
  38. r'class="views">\s*(\d+)\s*<',
  39. webpage, 'view count', fatal=False))
  40. comment_count = int_or_none(self._html_search_regex(
  41. r'(\d+)</b> Comments?',
  42. webpage, 'comment count', fatal=False))
  43. formats = []
  44. quality = qualities(['mp4', 'flv'])
  45. for video_url in re.findall(r'<(?:source|video) src="([^"]+)"', webpage):
  46. video_ext = determine_ext(video_url)
  47. formats.append({
  48. 'url': video_url,
  49. 'format_id': video_ext,
  50. 'quality': quality(video_ext),
  51. })
  52. self._sort_formats(formats)
  53. return {
  54. 'id': video_id,
  55. 'title': title,
  56. 'description': description,
  57. 'thumbnail': thumbnail,
  58. 'duration': duration,
  59. 'view_count': view_count,
  60. 'comment_count': comment_count,
  61. 'formats': formats,
  62. 'age_limit': 18,
  63. }