Fixed the encoding
[youtube-dl] / youtube_dl / extractor / mojvideo.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3 import re
4
5 from .common import InfoExtractor
6
7 class MojvideoIE(InfoExtractor):
8     _VALID_URL = r'https?://(?:www\.)?mojvideo\.com/video-.*/(?P<id>[a-f0-9]+)'
9     _TEST = {
10         'url': 'http://www.mojvideo.com/video-v-avtu-pred-mano-rdecelaska-alfi-nipic/3d1ed4497707730b2906',
11         'md5': 'f7fd662cc8ce2be107b0d4f2c0483ae7',
12         'info_dict': {
13             'id': '3d1ed4497707730b2906',
14             'ext': 'mp4',
15             'title': 'V avtu pred mano rdečelaska - Alfi Nipič',
16             'description':'Video: V avtu pred mano rdečelaska - Alfi Nipič',
17             'height':378,
18             'width':480
19         }
20     }
21
22     def _real_extract(self, url):
23         mobj = re.match(self._VALID_URL, url)
24         video_id = mobj.group('id')
25
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
33         return {
34             'id': video_id,
35             'title': title,
36             'description': description,
37             'ext': 'mp4',
38             'url': final_url,
39             'height':height,
40             'width':width
41         }