]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/mojvideo.py
[Mojvideo] Add new extractor
[yt-dlp.git] / youtube_dl / extractor / mojvideo.py
CommitLineData
5537dce8
DF
1import re
2
3from .common import InfoExtractor
4
5class 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 # TODO more properties, either as:
18 # * A value
19 # * MD5 checksum; start the string with md5:
20 # * A regular expression; start the string with re:
21 # * Any Python type (for example int or float)
22 }
23 }
24
25 def _real_extract(self, url):
26 mobj = re.match(self._VALID_URL, url)
27 video_id = mobj.group('id')
28
29 # TODO more code goes here, for example ...
30 webpage = self._download_webpage(url, video_id)
31 title = self._html_search_regex(r'<title>(.*?)</title>', webpage, 'title')
32 description = self._search_regex(r'<meta name="description" content="(.*)" />', webpage, 'video description')
33 final_url = self._html_search_regex(r'mp4: \'(.*)\'', webpage, 'video url')
34 height=int(self._search_regex(r'<meta name="video_height" content="([0-9]*)" />',webpage,"video height"))
35 width=int(self._search_regex(r'<meta name="video_width" content="([0-9]*)" />',webpage,"video width"))
36
37 return {
38 'id': video_id,
39 'title': title,
40 'description': description,
41 'ext': 'mp4',
42 'url': final_url,
43 'height':height,
44 'width':width
45 # TODO more properties (see youtube_dl/extractor/common.py)
46 }