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.

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