xnxx.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. compat_urllib_parse,
  7. )
  8. class XNXXIE(InfoExtractor):
  9. _VALID_URL = r'^https?://(?:video|www)\.xnxx\.com/video(?P<id>[0-9]+)/(.*)'
  10. _TEST = {
  11. 'url': 'http://video.xnxx.com/video1135332/lida_naked_funny_actress_5_',
  12. 'md5': '0831677e2b4761795f68d417e0b7b445',
  13. 'info_dict': {
  14. 'id': '1135332',
  15. 'ext': 'flv',
  16. 'title': 'lida » Naked Funny Actress (5)',
  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('id')
  23. # Get webpage content
  24. webpage = self._download_webpage(url, video_id)
  25. video_url = self._search_regex(r'flv_url=(.*?)&amp;',
  26. webpage, 'video URL')
  27. video_url = compat_urllib_parse.unquote(video_url)
  28. video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XNXX.COM',
  29. webpage, 'title')
  30. video_thumbnail = self._search_regex(r'url_bigthumb=(.*?)&amp;',
  31. webpage, 'thumbnail', fatal=False)
  32. return {
  33. 'id': video_id,
  34. 'url': video_url,
  35. 'title': video_title,
  36. 'ext': 'flv',
  37. 'thumbnail': video_thumbnail,
  38. 'age_limit': 18,
  39. }