]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/beeg.py
[dailymotion] Error spelling
[youtube-dl] / youtube_dl / extractor / beeg.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import (
5     int_or_none,
6     parse_iso8601,
7 )
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',
14         'md5': '46c384def73b33dbc581262e5ee67cef',
15         'info_dict': {
16             'id': '5416503',
17             'ext': 'mp4',
18             'title': 'Sultry Striptease',
19             'description': 'md5:d22219c09da287c14bed3d6c37ce4bc2',
20             'timestamp': 1391813355,
21             'upload_date': '20140207',
22             'duration': 383,
23             'tags': list,
24             'age_limit': 18,
25         }
26     }
27
28     def _real_extract(self, url):
29         video_id = self._match_id(url)
30
31         video = self._download_json(
32             'http://beeg.com/api/v1/video/%s' % video_id, video_id)
33
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             })
45         self._sort_formats(formats)
46
47         title = video['title']
48         video_id = video.get('id') or video_id
49         display_id = video.get('code')
50         description = video.get('desc')
51
52         timestamp = parse_iso8601(video.get('date'), ' ')
53         duration = int_or_none(video.get('duration'))
54
55         tags = [tag.strip() for tag in video['tags'].split(',')] if video.get('tags') else None
56
57         return {
58             'id': video_id,
59             'display_id': display_id,
60             'title': title,
61             'description': description,
62             'timestamp': timestamp,
63             'duration': duration,
64             'tags': tags,
65             'formats': formats,
66             'age_limit': 18,
67         }