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.

53 lines
1.5 KiB

  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. compat_urllib_parse,
  5. )
  6. class XVideosIE(InfoExtractor):
  7. _VALID_URL = r'^(?:https?://)?(?:www\.)?xvideos\.com/video([0-9]+)(?:.*)'
  8. _TEST = {
  9. u'url': u'http://www.xvideos.com/video939581/funny_porns_by_s_-1',
  10. u'file': u'939581.flv',
  11. u'md5': u'1d0c835822f0a71a7bf011855db929d0',
  12. u'info_dict': {
  13. u"title": u"Funny Porns By >>>>S<<<<<< -1",
  14. u"age_limit": 18,
  15. }
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group(1)
  20. webpage = self._download_webpage(url, video_id)
  21. self.report_extraction(video_id)
  22. # Extract video URL
  23. video_url = compat_urllib_parse.unquote(self._search_regex(r'flv_url=(.+?)&',
  24. webpage, u'video URL'))
  25. # Extract title
  26. video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XVID',
  27. webpage, u'title')
  28. # Extract video thumbnail
  29. video_thumbnail = self._search_regex(r'http://(?:img.*?\.)xvideos.com/videos/thumbs/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/([a-fA-F0-9.]+jpg)',
  30. webpage, u'thumbnail', fatal=False)
  31. info = {
  32. 'id': video_id,
  33. 'url': video_url,
  34. 'uploader': None,
  35. 'upload_date': None,
  36. 'title': video_title,
  37. 'ext': 'flv',
  38. 'thumbnail': video_thumbnail,
  39. 'description': None,
  40. 'age_limit': 18,
  41. }
  42. return [info]