Merge pull request #8194 from vickyg3/bigflix_ie
[youtube-dl] / youtube_dl / extractor / bigflix.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from base64 import b64decode
5
6 from .common import InfoExtractor
7 from ..compat import compat_urllib_parse_unquote
8
9
10 class BigflixIE(InfoExtractor):
11     _VALID_URL = r'https?://(?:www\.)?bigflix\.com/.*/(?P<id>[0-9]+)'
12     _TEST = {
13         'url': 'http://www.bigflix.com/Hindi-movies/Action-movies/Singham-Returns/16537',
14         'md5': 'ec76aa9b1129e2e5b301a474e54fab74',
15         'info_dict': {
16             'id': '16537',
17             'ext': 'mp4',
18             'title': 'Singham Returns',
19             'description': 'md5:3d2ba5815f14911d5cc6a501ae0cf65d',
20         }
21     }
22
23     def _real_extract(self, url):
24         video_id = self._match_id(url)
25
26         webpage = self._download_webpage(url, video_id)
27
28         title = self._html_search_regex(
29             r'<div[^>]+class=["\']pagetitle["\'][^>]*>(.+?)</div>',
30             webpage, 'title')
31
32         video_url = b64decode(compat_urllib_parse_unquote(self._search_regex(
33             r'file=([^&]+)', webpage, 'video url')).encode('ascii')).decode('utf-8')
34
35         description = self._html_search_meta('description', webpage)
36
37         return {
38             'id': video_id,
39             'title': title,
40             'url': video_url,
41             'description': description,
42         }