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.

63 lines
2.1 KiB

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