]>
Commit | Line | Data |
---|---|---|
2aebbcce | 1 | from __future__ import unicode_literals |
2 | ||
2aebbcce | 3 | from .common import InfoExtractor |
5946cda7 S |
4 | from ..utils import ( |
5 | int_or_none, | |
6 | parse_iso8601, | |
7 | ) | |
2aebbcce | 8 | |
9 | ||
10 | class BeegIE(InfoExtractor): | |
11 | _VALID_URL = r'https?://(?:www\.)?beeg\.com/(?P<id>\d+)' | |
12 | _TEST = { | |
13 | 'url': 'http://beeg.com/5416503', | |
5946cda7 | 14 | 'md5': '46c384def73b33dbc581262e5ee67cef', |
2aebbcce | 15 | 'info_dict': { |
16 | 'id': '5416503', | |
17 | 'ext': 'mp4', | |
18 | 'title': 'Sultry Striptease', | |
5946cda7 S |
19 | 'description': 'md5:d22219c09da287c14bed3d6c37ce4bc2', |
20 | 'timestamp': 1391813355, | |
21 | 'upload_date': '20140207', | |
22 | 'duration': 383, | |
23 | 'tags': list, | |
7ca2e11f | 24 | 'age_limit': 18, |
2aebbcce | 25 | } |
26 | } | |
27 | ||
28 | def _real_extract(self, url): | |
5946cda7 | 29 | video_id = self._match_id(url) |
3baa62e8 | 30 | |
5946cda7 S |
31 | video = self._download_json( |
32 | 'http://beeg.com/api/v1/video/%s' % video_id, video_id) | |
3baa62e8 | 33 | |
5946cda7 S |
34 | formats = [] |
35 | for format_id, video_url in video.items(): | |
36 | height = self._search_regex( | |
37 | r'^(\d+)[pP]$', format_id, 'height', default=None) | |
38 | if not height: | |
39 | continue | |
40 | formats.append({ | |
41 | 'url': self._proto_relative_url(video_url.replace('{DATA_MARKERS}', ''), 'http:'), | |
42 | 'format_id': format_id, | |
43 | 'height': int(height), | |
44 | }) | |
3baa62e8 | 45 | self._sort_formats(formats) |
2aebbcce | 46 | |
5946cda7 S |
47 | title = video['title'] |
48 | video_id = video.get('id') or video_id | |
49 | display_id = video.get('code') | |
50 | description = video.get('desc') | |
5f6a1245 | 51 | |
5946cda7 S |
52 | timestamp = parse_iso8601(video.get('date'), ' ') |
53 | duration = int_or_none(video.get('duration')) | |
2aebbcce | 54 | |
5946cda7 | 55 | tags = [tag.strip() for tag in video['tags'].split(',')] if video.get('tags') else None |
2aebbcce | 56 | |
57 | return { | |
58 | 'id': video_id, | |
5946cda7 | 59 | 'display_id': display_id, |
2aebbcce | 60 | 'title': title, |
61 | 'description': description, | |
5946cda7 S |
62 | 'timestamp': timestamp, |
63 | 'duration': duration, | |
64 | 'tags': tags, | |
3baa62e8 | 65 | 'formats': formats, |
7ca2e11f | 66 | 'age_limit': 18, |
2aebbcce | 67 | } |