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.

79 lines
2.6 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|embeds\.sunporno\.com/embed)/(?P<id>\d+)'
  12. _TESTS = [{
  13. 'url': 'http://www.sunporno.com/videos/807778/',
  14. 'md5': '507887e29033502f29dba69affeebfc9',
  15. 'info_dict': {
  16. 'id': '807778',
  17. 'ext': 'mp4',
  18. 'title': 'md5:0a400058e8105d39e35c35e7c5184164',
  19. 'description': 'md5:a31241990e1bd3a64e72ae99afb325fb',
  20. 'thumbnail': r're:^https?://.*\.jpg$',
  21. 'duration': 302,
  22. 'age_limit': 18,
  23. }
  24. }, {
  25. 'url': 'http://embeds.sunporno.com/embed/807778',
  26. 'only_matching': True,
  27. }]
  28. def _real_extract(self, url):
  29. video_id = self._match_id(url)
  30. webpage = self._download_webpage(
  31. 'http://www.sunporno.com/videos/%s' % video_id, video_id)
  32. title = self._html_search_regex(
  33. r'<title>([^<]+)</title>', webpage, 'title')
  34. description = self._html_search_meta(
  35. 'description', webpage, 'description')
  36. thumbnail = self._html_search_regex(
  37. r'poster="([^"]+)"', webpage, 'thumbnail', fatal=False)
  38. duration = parse_duration(self._search_regex(
  39. (r'itemprop="duration"[^>]*>\s*(\d+:\d+)\s*<',
  40. r'>Duration:\s*<span[^>]+>\s*(\d+:\d+)\s*<'),
  41. webpage, 'duration', fatal=False))
  42. view_count = int_or_none(self._html_search_regex(
  43. r'class="views">(?:<noscript>)?\s*(\d+)\s*<',
  44. webpage, 'view count', fatal=False))
  45. comment_count = int_or_none(self._html_search_regex(
  46. r'(\d+)</b> Comments?',
  47. webpage, 'comment count', fatal=False, default=None))
  48. formats = []
  49. quality = qualities(['mp4', 'flv'])
  50. for video_url in re.findall(r'<(?:source|video) src="([^"]+)"', webpage):
  51. video_ext = determine_ext(video_url)
  52. formats.append({
  53. 'url': video_url,
  54. 'format_id': video_ext,
  55. 'quality': quality(video_ext),
  56. })
  57. self._sort_formats(formats)
  58. return {
  59. 'id': video_id,
  60. 'title': title,
  61. 'description': description,
  62. 'thumbnail': thumbnail,
  63. 'duration': duration,
  64. 'view_count': view_count,
  65. 'comment_count': comment_count,
  66. 'formats': formats,
  67. 'age_limit': 18,
  68. }