anysex.py 1.5 KB

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