e77b5f7346ce2df2e55bdf18baa50733702ae3dc
[youtube-dl] / youtube_dl / extractor / megavideozeu.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6     int_or_none,
7     parse_filesize,
8     unified_strdate,
9 )
10
11
12 class MegavideozeuIE(InfoExtractor):
13     _VALID_URL = r'https?://(?:www\.)?megavideoz\.eu/video/(?P<id>.*)(?:.*)'
14
15     def _real_extract(self, url):
16         tmp_video_id = self._match_id(url)
17
18         webpage = self._download_webpage(url, tmp_video_id)
19
20         config_php = self._html_search_regex(
21             r'var cnf = \'([^\']+)\'', webpage, 'config.php url')
22
23         configpage = self._download_webpage(config_php, tmp_video_id)
24
25         video_id = self._html_search_regex(
26             r'<mediaid>([^<]+)', configpage, 'video id')
27         video_url = self._html_search_regex(
28             r'<file>([^<]+)', configpage, 'video URL')
29         title = self._html_search_regex(
30             r'<title><!\[CDATA\[([^\]]+)', configpage, 'title')
31         duration = int_or_none(self._html_search_regex(
32             r'<duration>([0-9]+)', configpage, 'duration', fatal=False))
33
34         return {
35             'id': video_id,
36             'url': video_url,
37             'title': title,
38             'duration': duration
39         }