mojvideo.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class MojvideoIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?mojvideo\.com/video-.*/(?P<id>[a-f0-9]+)'
  7. _TEST = {
  8. 'url': 'http://www.mojvideo.com/video-v-avtu-pred-mano-rdecelaska-alfi-nipic/3d1ed4497707730b2906',
  9. 'md5': 'f7fd662cc8ce2be107b0d4f2c0483ae7',
  10. 'info_dict': {
  11. 'id': '3d1ed4497707730b2906',
  12. 'ext': 'mp4',
  13. 'title': 'V avtu pred mano rdečelaska - Alfi Nipič',
  14. 'description':'Video: V avtu pred mano rdečelaska - Alfi Nipič',
  15. 'height':378,
  16. 'width':480
  17. }
  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. title = self._html_search_regex(r'<title>(.*?)</title>', webpage, 'title')
  24. description = self._search_regex(r'<meta name="description" content="(.*)" />', webpage, 'video description')
  25. final_url = self._html_search_regex(r'mp4: \'(.*)\'', webpage, 'video url')
  26. height=int(self._search_regex(r'<meta name="video_height" content="([0-9]*)" />',webpage,"video height"))
  27. width=int(self._search_regex(r'<meta name="video_width" content="([0-9]*)" />',webpage,"video width"))
  28. return {
  29. 'id': video_id,
  30. 'title': title,
  31. 'description': description,
  32. 'ext': 'mp4',
  33. 'url': final_url,
  34. 'height':height,
  35. 'width':width
  36. }