vporn.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class VpornIE(InfoExtractor):
  6. _VALID_URL = r'http?://(?:www\.)?vporn\.com/[a-z]+/(?P<title_dash>[a-z-]+)/(?P<id>\d+)/?'
  7. _TEST = {
  8. 'url': 'http://www.vporn.com/masturbation/violet-on-her-th-birthday/497944/',
  9. 'md5': 'facf37c1b86546fa0208058546842c55',
  10. 'info_dict': {
  11. 'id': '497944',
  12. 'ext': 'mp4',
  13. 'title': 'Violet On Her 19th Birthday',
  14. 'description': 'Violet dances in front of the camera which is sure to get you horny.',
  15. 'duration': 393,
  16. 'thumbnail': 're:^https?://.*\.jpg$',
  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>(.*?) - Vporn Video</title>', webpage, 'title')
  24. video_url = self._html_search_regex(r'flashvars.videoUrlMedium = "(.*?)"', webpage, 'video_url')
  25. description = self._html_search_regex(r'<div class="description_txt">(.*?)</div>', webpage, 'description')
  26. thumbnail = 'http://www.vporn.com' + self._html_search_regex(r'flashvars.imageUrl = "(.*?)"', webpage, 'description')
  27. mobj = re.search(
  28. r'<span class="f_right">duration (?P<minutes>\d+) min (?P<seconds>\d+) sec </span>', webpage)
  29. duration = int(mobj.group('minutes')) * 60 + int(mobj.group('seconds')) if mobj else None
  30. return {
  31. 'id': video_id,
  32. 'url': video_url,
  33. 'thumbnail': thumbnail,
  34. 'title': title,
  35. 'description': description,
  36. 'duration': duration,
  37. }