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.

59 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/video939581/funny_porns_by_s_-1',
  13. 'file': '939581.flv',
  14. 'md5': '1d0c835822f0a71a7bf011855db929d0',
  15. 'info_dict': {
  16. "title": "Funny Porns By >>>>S<<<<<< -1",
  17. "age_limit": 18,
  18. }
  19. }
  20. def _real_extract(self, url):
  21. mobj = re.match(self._VALID_URL, url)
  22. video_id = mobj.group(1)
  23. webpage = self._download_webpage(url, video_id)
  24. self.report_extraction(video_id)
  25. mobj = re.search(r'<h1 class="inlineError">(.+?)</h1>', webpage)
  26. if mobj:
  27. raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True)
  28. # Extract video URL
  29. video_url = compat_urllib_parse.unquote(
  30. self._search_regex(r'flv_url=(.+?)&', webpage, 'video URL'))
  31. # Extract title
  32. video_title = self._html_search_regex(
  33. r'<title>(.*?)\s+-\s+XVID', webpage, 'title')
  34. # Extract video thumbnail
  35. video_thumbnail = self._search_regex(
  36. r'url_bigthumb=(.+?)&amp', webpage, 'thumbnail', fatal=False)
  37. return {
  38. 'id': video_id,
  39. 'url': video_url,
  40. 'uploader': None,
  41. 'upload_date': None,
  42. 'title': video_title,
  43. 'ext': 'flv',
  44. 'thumbnail': video_thumbnail,
  45. 'description': None,
  46. 'age_limit': 18,
  47. }