]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/odnoklassniki.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
12 class OdnoklassnikiIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:odnoklassniki|ok)\.ru/(?:video|web-api/video/moviePlayer)/(?P<id>\d+)'
15 'url': 'http://ok.ru/video/20079905452',
16 'md5': '8e24ad2da6f387948e7a7d44eb8668fe',
20 'title': 'Культура меняет нас (прекрасный ролик!))',
22 'upload_date': '20141207',
23 'uploader_id': '330537914540',
24 'uploader': 'Виталий Добровольский',
29 'url': 'http://ok.ru/web-api/video/moviePlayer/20079905452',
30 'only_matching': True,
33 def _real_extract(self
, url
):
34 video_id
= self
._match
_id
(url
)
36 webpage
= self
._download
_webpage
(url
, video_id
)
38 player
= self
._parse
_json
(
40 r
"OKVideo\.start\(({.+?})\s*,\s*'VideoAutoplay_player'", webpage
, 'player'),
43 metadata
= self
._parse
_json
(player
['flashvars']['metadata'], video_id
)
45 movie
= metadata
['movie']
46 title
= movie
['title']
47 thumbnail
= movie
.get('poster')
48 duration
= int_or_none(movie
.get('duration'))
50 author
= metadata
.get('author', {})
51 uploader_id
= author
.get('id')
52 uploader
= author
.get('name')
54 upload_date
= unified_strdate(self
._html
_search
_meta
(
55 'ya:ovs:upload_date', webpage
, 'upload date'))
58 adult
= self
._html
_search
_meta
(
59 'ya:ovs:adult', webpage
, 'age limit')
61 age_limit
= 18 if adult
== 'true' else 0
63 like_count
= int_or_none(metadata
.get('likeCount'))
65 quality
= qualities(('mobile', 'lowest', 'low', 'sd', 'hd'))
70 'format_id': f
['name'],
71 'quality': quality(f
['name']),
72 } for f
in metadata
['videos']]
77 'thumbnail': thumbnail
,
79 'upload_date': upload_date
,
81 'uploader_id': uploader_id
,
82 'like_count': like_count
,
83 'age_limit': age_limit
,