]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/openfilm.py
debian/changelog: Annotate bugs to close.
[youtubedl] / youtube_dl / extractor / openfilm.py
1 from __future__ import unicode_literals
2
3 import json
4
5 from .common import InfoExtractor
6 from ..utils import (
7 parse_iso8601,
8 compat_urllib_parse,
9 parse_age_limit,
10 int_or_none,
11 )
12
13
14 class OpenFilmIE(InfoExtractor):
15 _VALID_URL = r'http://(?:www\.)openfilm\.com/videos/(?P<id>.+)'
16 _TEST = {
17 'url': 'http://www.openfilm.com/videos/human-resources-remastered',
18 'md5': '42bcd88c2f3ec13b65edf0f8ad1cac37',
19 'info_dict': {
20 'id': '32736',
21 'display_id': 'human-resources-remastered',
22 'ext': 'mp4',
23 'title': 'Human Resources (Remastered)',
24 'description': 'Social Engineering in the 20th Century.',
25 'thumbnail': 're:^https?://.*\.jpg$',
26 'duration': 7164,
27 'timestamp': 1334756988,
28 'upload_date': '20120418',
29 'uploader_id': '41117',
30 'view_count': int,
31 'age_limit': 0,
32 },
33 }
34
35 def _real_extract(self, url):
36 display_id = self._match_id(url)
37
38 webpage = self._download_webpage(url, display_id)
39
40 player = compat_urllib_parse.unquote_plus(
41 self._og_search_video_url(webpage))
42
43 video = json.loads(self._search_regex(
44 r'\bp=({.+?})(?:&|$)', player, 'video JSON'))
45
46 video_url = '%s1.mp4' % video['location']
47 video_id = video.get('video_id')
48 display_id = video.get('alias') or display_id
49 title = video.get('title')
50 description = video.get('description')
51 thumbnail = video.get('main_thumb')
52 duration = int_or_none(video.get('duration'))
53 timestamp = parse_iso8601(video.get('dt_published'), ' ')
54 uploader_id = video.get('user_id')
55 view_count = int_or_none(video.get('views_count'))
56 age_limit = parse_age_limit(video.get('age_limit'))
57
58 return {
59 'id': video_id,
60 'display_id': display_id,
61 'url': video_url,
62 'title': title,
63 'description': description,
64 'thumbnail': thumbnail,
65 'duration': duration,
66 'timestamp': timestamp,
67 'uploader_id': uploader_id,
68 'view_count': view_count,
69 'age_limit': age_limit,
70 }