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.

61 lines
2.0 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. )
  8. class AnySexIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?anysex\.com/(?P<id>\d+)'
  10. _TEST = {
  11. 'url': 'http://anysex.com/156592/',
  12. 'md5': '023e9fbb7f7987f5529a394c34ad3d3d',
  13. 'info_dict': {
  14. 'id': '156592',
  15. 'ext': 'mp4',
  16. 'title': 'Busty and sexy blondie in her bikini strips for you',
  17. 'description': 'md5:de9e418178e2931c10b62966474e1383',
  18. 'categories': ['Erotic'],
  19. 'duration': 270,
  20. 'age_limit': 18,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. webpage = self._download_webpage(url, video_id)
  27. video_url = self._html_search_regex(r"video_url\s*:\s*'([^']+)'", webpage, 'video URL')
  28. title = self._html_search_regex(r'<title>(.*?)</title>', webpage, 'title')
  29. description = self._html_search_regex(
  30. r'<div class="description"[^>]*>([^<]+)</div>', webpage, 'description', fatal=False)
  31. thumbnail = self._html_search_regex(
  32. r'preview_url\s*:\s*\'(.*?)\'', webpage, 'thumbnail', fatal=False)
  33. categories = re.findall(
  34. r'<a href="http://anysex\.com/categories/[^"]+" title="[^"]*">([^<]+)</a>', webpage)
  35. duration = parse_duration(self._search_regex(
  36. r'<b>Duration:</b> (?:<q itemprop="duration">)?(\d+:\d+)', webpage, 'duration', fatal=False))
  37. view_count = int_or_none(self._html_search_regex(
  38. r'<b>Views:</b> (\d+)', webpage, 'view count', fatal=False))
  39. return {
  40. 'id': video_id,
  41. 'url': video_url,
  42. 'ext': 'mp4',
  43. 'title': title,
  44. 'description': description,
  45. 'thumbnail': thumbnail,
  46. 'categories': categories,
  47. 'duration': duration,
  48. 'view_count': view_count,
  49. 'age_limit': 18,
  50. }