anysex.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class AnySexIE(InfoExtractor):
  6. _VALID_URL = r'http?://(?:www\.)?anysex\.com/(?P<id>\d+)/?'
  7. _TEST = {
  8. 'url': 'http://anysex.com/156592/',
  9. 'md5': '023e9fbb7f7987f5529a394c34ad3d3d',
  10. 'info_dict': {
  11. 'id': '156592',
  12. 'ext': 'mp4',
  13. 'title': 'Busty and sexy blondie in her bikini strips for you',
  14. 'duration': 270
  15. }
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('id')
  20. webpage = self._download_webpage(url, video_id)
  21. title = self._html_search_regex(r'<title>(.*?)</title>', webpage, 'title')
  22. video_url = self._html_search_regex(r'video_url: \'(.*?)\',', webpage, 'video_url')
  23. thumbnail = self._html_search_regex(r'preview_url: \'(.*?)\',', webpage, 'thumbnail')
  24. mobj = re.search(r'<b>Duration:</b> (?P<minutes>\d+):(?P<seconds>\d+)<', webpage)
  25. duration = int(mobj.group('minutes')) * 60 + int(mobj.group('seconds')) if mobj else None
  26. view_count = self._html_search_regex(r'<b>Views:</b> (\d+)', webpage, 'view count', fatal=False)
  27. return {
  28. 'id': video_id,
  29. 'ext': 'mp4',
  30. 'url': video_url,
  31. 'title': title,
  32. 'duration': duration,
  33. 'view_count': view_count
  34. }