]>
Commit | Line | Data |
---|---|---|
0a899a14 VV |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
6e99d576 S |
4 | import base64 |
5 | import re | |
0a899a14 VV |
6 | |
7 | from .common import InfoExtractor | |
8 | from ..compat import compat_urllib_parse_unquote | |
9 | ||
10 | ||
11 | class BigflixIE(InfoExtractor): | |
6e99d576 S |
12 | _VALID_URL = r'https?://(?:www\.)?bigflix\.com/.+/(?P<id>[0-9]+)' |
13 | _TESTS = [{ | |
0a899a14 VV |
14 | 'url': 'http://www.bigflix.com/Hindi-movies/Action-movies/Singham-Returns/16537', |
15 | 'md5': 'ec76aa9b1129e2e5b301a474e54fab74', | |
16 | 'info_dict': { | |
17 | 'id': '16537', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Singham Returns', | |
20 | 'description': 'md5:3d2ba5815f14911d5cc6a501ae0cf65d', | |
21 | } | |
6e99d576 | 22 | }, { |
a9bbd26f | 23 | # 2 formats |
6e99d576 S |
24 | 'url': 'http://www.bigflix.com/Tamil-movies/Drama-movies/Madarasapatinam/16070', |
25 | 'info_dict': { | |
26 | 'id': '16070', | |
27 | 'ext': 'mp4', | |
28 | 'title': 'Madarasapatinam', | |
29 | 'description': 'md5:63b9b8ed79189c6f0418c26d9a3452ca', | |
30 | 'formats': 'mincount:2', | |
31 | }, | |
32 | 'params': { | |
33 | 'skip_download': True, | |
34 | } | |
a9bbd26f S |
35 | }, { |
36 | # multiple formats | |
37 | 'url': 'http://www.bigflix.com/Malayalam-movies/Drama-movies/Indian-Rupee/15967', | |
38 | 'only_matching': True, | |
6e99d576 | 39 | }] |
0a899a14 VV |
40 | |
41 | def _real_extract(self, url): | |
42 | video_id = self._match_id(url) | |
43 | ||
44 | webpage = self._download_webpage(url, video_id) | |
45 | ||
46 | title = self._html_search_regex( | |
47 | r'<div[^>]+class=["\']pagetitle["\'][^>]*>(.+?)</div>', | |
48 | webpage, 'title') | |
49 | ||
6e99d576 S |
50 | def decode_url(quoted_b64_url): |
51 | return base64.b64decode(compat_urllib_parse_unquote( | |
a9bbd26f S |
52 | quoted_b64_url).encode('ascii')).decode('utf-8') |
53 | ||
54 | formats = [] | |
55 | for height, encoded_url in re.findall( | |
7e8a800f | 56 | r'ContentURL_(\d{3,4})[pP][^=]+=([^&]+)', webpage): |
a9bbd26f S |
57 | video_url = decode_url(encoded_url) |
58 | f = { | |
59 | 'url': video_url, | |
60 | 'format_id': '%sp' % height, | |
61 | 'height': int(height), | |
62 | } | |
63 | if video_url.startswith('rtmp'): | |
64 | f['ext'] = 'flv' | |
65 | formats.append(f) | |
6e99d576 | 66 | |
a9bbd26f S |
67 | file_url = self._search_regex( |
68 | r'file=([^&]+)', webpage, 'video url', default=None) | |
69 | if file_url: | |
70 | video_url = decode_url(file_url) | |
71 | if all(f['url'] != video_url for f in formats): | |
72 | formats.append({ | |
73 | 'url': decode_url(file_url), | |
74 | }) | |
6e99d576 | 75 | |
a9bbd26f | 76 | self._sort_formats(formats) |
0a899a14 VV |
77 | |
78 | description = self._html_search_meta('description', webpage) | |
79 | ||
80 | return { | |
81 | 'id': video_id, | |
82 | 'title': title, | |
0a899a14 | 83 | 'description': description, |
6e99d576 | 84 | 'formats': formats |
0a899a14 | 85 | } |