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.6 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urllib_parse,
  6. )
  7. class MalemotionIE(InfoExtractor):
  8. _VALID_URL = r'^(?:https?://)?malemotion\.com/video/(.+?)\.(?P<id>.+?)(#|$)'
  9. _TEST = {
  10. 'url': 'http://malemotion.com/video/bien-dur.10ew',
  11. 'file': '10ew.mp4',
  12. 'md5': 'b3cc49f953b107e4a363cdff07d100ce',
  13. 'info_dict': {
  14. "title": "Bien dur",
  15. "age_limit": 18,
  16. },
  17. 'skip': 'This video has been deleted.'
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group("id")
  22. webpage = self._download_webpage(url, video_id)
  23. self.report_extraction(video_id)
  24. # Extract video URL
  25. video_url = compat_urllib_parse.unquote(
  26. self._search_regex(r'<source type="video/mp4" src="(.+?)"', webpage, 'video URL'))
  27. # Extract title
  28. video_title = self._html_search_regex(
  29. r'<title>(.*?)</title', webpage, 'title')
  30. # Extract video thumbnail
  31. video_thumbnail = self._search_regex(
  32. r'<video .+?poster="(.+?)"', webpage, 'thumbnail', fatal=False)
  33. formats = [{
  34. 'url': video_url,
  35. 'ext': 'mp4',
  36. 'format_id': 'mp4',
  37. 'preference': 1,
  38. }]
  39. return {
  40. 'id': video_id,
  41. 'formats': formats,
  42. 'uploader': None,
  43. 'upload_date': None,
  44. 'title': video_title,
  45. 'thumbnail': video_thumbnail,
  46. 'description': None,
  47. 'age_limit': 18,
  48. }