mojvideo.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. # TODO more properties, either as:
  16. # * A value
  17. # * MD5 checksum; start the string with md5:
  18. # * A regular expression; start the string with re:
  19. # * Any Python type (for example int or float)
  20. }
  21. }
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. # TODO more code goes here, for example ...
  26. webpage = self._download_webpage(url, video_id)
  27. title = self._html_search_regex(r'<title>(.*?)</title>', webpage, 'title')
  28. description = self._search_regex(r'<meta name="description" content="(.*)" />', webpage, 'video description')
  29. final_url = self._html_search_regex(r'mp4: \'(.*)\'', webpage, 'video url')
  30. height=int(self._search_regex(r'<meta name="video_height" content="([0-9]*)" />',webpage,"video height"))
  31. width=int(self._search_regex(r'<meta name="video_width" content="([0-9]*)" />',webpage,"video width"))
  32. return {
  33. 'id': video_id,
  34. 'title': title,
  35. 'description': description,
  36. 'ext': 'mp4',
  37. 'url': final_url,
  38. 'height':height,
  39. 'width':width
  40. # TODO more properties (see youtube_dl/extractor/common.py)
  41. }