]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/odnoklassniki.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_urllib_parse
14 class OdnoklassnikiIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:odnoklassniki|ok)\.ru/(?:video|web-api/video/moviePlayer)/(?P<id>[\d-]+)'
18 'url': 'http://ok.ru/video/20079905452',
19 'md5': '8e24ad2da6f387948e7a7d44eb8668fe',
23 'title': 'Культура меняет нас (прекрасный ролик!))',
25 'uploader_id': '330537914540',
26 'uploader': 'Виталий Добровольский',
31 'url': 'http://ok.ru/video/63567059965189-0',
32 'md5': '9676cf86eff5391d35dea675d224e131',
34 'id': '63567059965189-0',
36 'title': 'Девушка без комплексов ...',
38 'uploader_id': '534380003155',
39 'uploader': 'Андрей Мещанинов',
43 'url': 'http://ok.ru/web-api/video/moviePlayer/20079905452',
44 'only_matching': True,
47 def _real_extract(self
, url
):
48 video_id
= self
._match
_id
(url
)
50 webpage
= self
._download
_webpage
(
51 'http://ok.ru/video/%s' % video_id
, video_id
)
53 player
= self
._parse
_json
(
54 unescapeHTML(self
._search
_regex
(
55 r
'data-attributes="([^"]+)"', webpage
, 'player')),
58 flashvars
= player
['flashvars']
60 metadata
= flashvars
.get('metadata')
62 metadata
= self
._parse
_json
(metadata
, video_id
)
64 metadata
= self
._download
_json
(
65 compat_urllib_parse
.unquote(flashvars
['metadataUrl']),
66 video_id
, 'Downloading metadata JSON')
68 movie
= metadata
['movie']
69 title
= movie
['title']
70 thumbnail
= movie
.get('poster')
71 duration
= int_or_none(movie
.get('duration'))
73 author
= metadata
.get('author', {})
74 uploader_id
= author
.get('id')
75 uploader
= author
.get('name')
77 upload_date
= unified_strdate(self
._html
_search
_meta
(
78 'ya:ovs:upload_date', webpage
, 'upload date', default
=None))
81 adult
= self
._html
_search
_meta
(
82 'ya:ovs:adult', webpage
, 'age limit', default
=None)
84 age_limit
= 18 if adult
== 'true' else 0
86 like_count
= int_or_none(metadata
.get('likeCount'))
88 quality
= qualities(('mobile', 'lowest', 'low', 'sd', 'hd'))
93 'format_id': f
['name'],
94 'quality': quality(f
['name']),
95 } for f
in metadata
['videos']]
100 'thumbnail': thumbnail
,
101 'duration': duration
,
102 'upload_date': upload_date
,
103 'uploader': uploader
,
104 'uploader_id': uploader_id
,
105 'like_count': like_count
,
106 'age_limit': age_limit
,