mojvideo.py 1.5 KB

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