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.

58 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. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group("id")
  21. webpage = self._download_webpage(url, video_id)
  22. self.report_extraction(video_id)
  23. # Extract video URL
  24. video_url = compat_urllib_parse.unquote(
  25. self._search_regex(r'<source type="video/mp4" src="(.+?)"', webpage, 'video URL'))
  26. # Extract title
  27. video_title = self._html_search_regex(
  28. r'<title>(.*?)</title', webpage, 'title')
  29. # Extract video thumbnail
  30. video_thumbnail = self._search_regex(
  31. r'<video .+?poster="(.+?)"', webpage, 'thumbnail', fatal=False)
  32. formats = [{
  33. 'url': video_url,
  34. 'ext': 'mp4',
  35. 'format_id': 'mp4',
  36. 'preference': 1,
  37. }]
  38. return {
  39. 'id': video_id,
  40. 'formats': formats,
  41. 'uploader': None,
  42. 'upload_date': None,
  43. 'title': video_title,
  44. 'thumbnail': video_thumbnail,
  45. 'description': None,
  46. 'age_limit': 18,
  47. }