]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/odnoklassniki.py
fbc521d1aae02077ae62c5cd0a6c5f9cdcff014a
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
13 class OdnoklassnikiIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:odnoklassniki|ok)\.ru/(?:video|web-api/video/moviePlayer)/(?P<id>\d+)'
16 'url': 'http://ok.ru/video/20079905452',
17 'md5': '8e24ad2da6f387948e7a7d44eb8668fe',
21 'title': 'Культура меняет нас (прекрасный ролик!))',
23 'upload_date': '20141207',
24 'uploader_id': '330537914540',
25 'uploader': 'Виталий Добровольский',
30 'url': 'http://ok.ru/web-api/video/moviePlayer/20079905452',
31 'only_matching': True,
34 def _real_extract(self
, url
):
35 video_id
= self
._match
_id
(url
)
37 webpage
= self
._download
_webpage
(url
, video_id
)
39 player
= self
._parse
_json
(
40 unescapeHTML(self
._search
_regex
(
41 r
'data-attributes="([^"]+)"', webpage
, 'player')),
44 metadata
= self
._parse
_json
(player
['flashvars']['metadata'], video_id
)
46 movie
= metadata
['movie']
47 title
= movie
['title']
48 thumbnail
= movie
.get('poster')
49 duration
= int_or_none(movie
.get('duration'))
51 author
= metadata
.get('author', {})
52 uploader_id
= author
.get('id')
53 uploader
= author
.get('name')
55 upload_date
= unified_strdate(self
._html
_search
_meta
(
56 'ya:ovs:upload_date', webpage
, 'upload date'))
59 adult
= self
._html
_search
_meta
(
60 'ya:ovs:adult', webpage
, 'age limit')
62 age_limit
= 18 if adult
== 'true' else 0
64 like_count
= int_or_none(metadata
.get('likeCount'))
66 quality
= qualities(('mobile', 'lowest', 'low', 'sd', 'hd'))
71 'format_id': f
['name'],
72 'quality': quality(f
['name']),
73 } for f
in metadata
['videos']]
78 'thumbnail': thumbnail
,
80 'upload_date': upload_date
,
82 'uploader_id': uploader_id
,
83 'like_count': like_count
,
84 'age_limit': age_limit
,