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.

50 lines
1.5 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_urllib_parse,
  6. )
  7. from ..utils import (
  8. clean_html,
  9. ExtractorError,
  10. )
  11. class XVideosIE(InfoExtractor):
  12. _VALID_URL = r'https?://(?:www\.)?xvideos\.com/video(?P<id>[0-9]+)(?:.*)'
  13. _TEST = {
  14. 'url': 'http://www.xvideos.com/video4588838/biker_takes_his_girl',
  15. 'md5': '4b46ae6ea5e6e9086e714d883313c0c9',
  16. 'info_dict': {
  17. 'id': '4588838',
  18. 'ext': 'flv',
  19. 'title': 'Biker Takes his Girl',
  20. 'age_limit': 18,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, 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. video_url = compat_urllib_parse.unquote(
  30. self._search_regex(r'flv_url=(.+?)&', webpage, 'video URL'))
  31. video_title = self._html_search_regex(
  32. r'<title>(.*?)\s+-\s+XVID', webpage, 'title')
  33. video_thumbnail = self._search_regex(
  34. r'url_bigthumb=(.+?)&amp', webpage, 'thumbnail', fatal=False)
  35. return {
  36. 'id': video_id,
  37. 'url': video_url,
  38. 'title': video_title,
  39. 'ext': 'flv',
  40. 'thumbnail': video_thumbnail,
  41. 'age_limit': 18,
  42. }