keezmovies.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from __future__ import unicode_literals
  2. import os
  3. import re
  4. from .common import InfoExtractor
  5. from ..compat import compat_urllib_parse_urlparse
  6. from ..utils import sanitized_Request
  7. class KeezMoviesIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?keezmovies\.com/video/.+?(?P<id>[0-9]+)(?:[/?&]|$)'
  9. _TEST = {
  10. 'url': 'http://www.keezmovies.com/video/petite-asian-lady-mai-playing-in-bathtub-1214711',
  11. 'md5': '6e297b7e789329923fcf83abb67c9289',
  12. 'info_dict': {
  13. 'id': '1214711',
  14. 'ext': 'mp4',
  15. 'title': 'Petite Asian Lady Mai Playing In Bathtub',
  16. 'age_limit': 18,
  17. }
  18. }
  19. def _real_extract(self, url):
  20. video_id = self._match_id(url)
  21. req = sanitized_Request(url)
  22. req.add_header('Cookie', 'age_verified=1')
  23. webpage = self._download_webpage(req, video_id)
  24. # embedded video
  25. mobj = re.search(r'href="([^"]+)"></iframe>', webpage)
  26. if mobj:
  27. embedded_url = mobj.group(1)
  28. return self.url_result(embedded_url)
  29. video_title = self._html_search_regex(
  30. r'<h1 [^>]*>([^<]+)', webpage, 'title')
  31. video_url = self._html_search_regex(
  32. r'(?s)html5VideoPlayer = .*?src="([^"]+)"', webpage, 'video URL')
  33. path = compat_urllib_parse_urlparse(video_url).path
  34. extension = os.path.splitext(path)[1][1:]
  35. format = path.split('/')[4].split('_')[:2]
  36. format = "-".join(format)
  37. age_limit = self._rta_search(webpage)
  38. return {
  39. 'id': video_id,
  40. 'title': video_title,
  41. 'url': video_url,
  42. 'ext': extension,
  43. 'format': format,
  44. 'format_id': format,
  45. 'age_limit': age_limit,
  46. }