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.

43 lines
1.2 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. def _real_extract(self, url):
  9. mobj = re.match(self._VALID_URL, url)
  10. video_id = mobj.group(1)
  11. webpage = self._download_webpage(url, video_id)
  12. self.report_extraction(video_id)
  13. # Extract video URL
  14. video_url = compat_urllib_parse.unquote(self._search_regex(r'flv_url=(.+?)&',
  15. webpage, u'video URL'))
  16. # Extract title
  17. video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XVID',
  18. webpage, u'title')
  19. # Extract video thumbnail
  20. 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)',
  21. webpage, u'thumbnail', fatal=False)
  22. info = {
  23. 'id': video_id,
  24. 'url': video_url,
  25. 'uploader': None,
  26. 'upload_date': None,
  27. 'title': video_title,
  28. 'ext': 'flv',
  29. 'thumbnail': video_thumbnail,
  30. 'description': None,
  31. }
  32. return [info]