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.

60 lines
1.7 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urllib_parse,
  6. ExtractorError,
  7. clean_html,
  8. )
  9. class XVideosIE(InfoExtractor):
  10. _VALID_URL = r'^(?:https?://)?(?:www\.)?xvideos\.com/video([0-9]+)(?:.*)'
  11. _TEST = {
  12. 'url': 'http://www.xvideos.com/video4588838/biker_takes_his_girl',
  13. 'md5': '4b46ae6ea5e6e9086e714d883313c0c9',
  14. 'info_dict': {
  15. 'id': '4588838',
  16. 'ext': 'flv',
  17. 'title': 'Biker Takes his Girl',
  18. 'age_limit': 18,
  19. }
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group(1)
  24. webpage = self._download_webpage(url, video_id)
  25. self.report_extraction(video_id)
  26. mobj = re.search(r'<h1 class="inlineError">(.+?)</h1>', webpage)
  27. if mobj:
  28. raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True)
  29. # Extract video URL
  30. video_url = compat_urllib_parse.unquote(
  31. self._search_regex(r'flv_url=(.+?)&', webpage, 'video URL'))
  32. # Extract title
  33. video_title = self._html_search_regex(
  34. r'<title>(.*?)\s+-\s+XVID', webpage, 'title')
  35. # Extract video thumbnail
  36. video_thumbnail = self._search_regex(
  37. r'url_bigthumb=(.+?)&amp', webpage, 'thumbnail', fatal=False)
  38. return {
  39. 'id': video_id,
  40. 'url': video_url,
  41. 'uploader': None,
  42. 'upload_date': None,
  43. 'title': video_title,
  44. 'ext': 'flv',
  45. 'thumbnail': video_thumbnail,
  46. 'description': None,
  47. 'age_limit': 18,
  48. }