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.

60 lines
1.9 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. }
  21. }
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. webpage = self._download_webpage(url, video_id)
  26. video_url = self._html_search_regex(r"video_url\s*:\s*'([^']+)'", webpage, 'video URL')
  27. title = self._html_search_regex(r'<title>(.*?)</title>', webpage, 'title')
  28. description = self._html_search_regex(
  29. r'<div class="description">([^<]+)</div>', webpage, 'description', fatal=False)
  30. thumbnail = self._html_search_regex(
  31. r'preview_url\s*:\s*\'(.*?)\'', webpage, 'thumbnail', fatal=False)
  32. categories = re.findall(
  33. r'<a href="http://anysex\.com/categories/[^"]+" title="[^"]*">([^<]+)</a>', webpage)
  34. duration = parse_duration(self._search_regex(
  35. r'<b>Duration:</b> (\d+:\d+)', webpage, 'duration', fatal=False))
  36. view_count = int_or_none(self._html_search_regex(
  37. r'<b>Views:</b> (\d+)', webpage, 'view count', fatal=False))
  38. return {
  39. 'id': video_id,
  40. 'url': video_url,
  41. 'ext': 'mp4',
  42. 'title': title,
  43. 'description': description,
  44. 'thumbnail': thumbnail,
  45. 'categories': categories,
  46. 'duration': duration,
  47. 'view_count': view_count,
  48. }