]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/kontrtube.py
720bc939bfd4c3a30c9a3709968c6008e6472067
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..utils
import int_or_none
10 class KontrTubeIE(InfoExtractor
):
12 IE_DESC
= 'KontrTube.ru - Труба зовёт'
13 _VALID_URL
= r
'http://(?:www\.)?kontrtube\.ru/videos/(?P<id>\d+)/(?P<display_id>[^/]+)/'
16 'url': 'http://www.kontrtube.ru/videos/2678/nad-olimpiyskoy-derevney-v-sochi-podnyat-rossiyskiy-flag/',
17 'md5': '975a991a4926c9a85f383a736a2e6b80',
20 'display_id': 'nad-olimpiyskoy-derevney-v-sochi-podnyat-rossiyskiy-flag',
22 'title': 'Над олимпийской деревней в Сочи поднят российский флаг',
23 'description': 'md5:80edc4c613d5887ae8ccf1d59432be41',
24 'thumbnail': 'http://www.kontrtube.ru/contents/videos_screenshots/2000/2678/preview.mp4.jpg',
29 def _real_extract(self
, url
):
30 mobj
= re
.match(self
._VALID
_URL
, url
)
31 video_id
= mobj
.group('id')
32 display_id
= mobj
.group('display_id')
34 webpage
= self
._download
_webpage
(
35 url
, display_id
, 'Downloading page')
37 video_url
= self
._html
_search
_regex
(
38 r
"video_url\s*:\s*'(.+?)/?',", webpage
, 'video URL')
39 thumbnail
= self
._html
_search
_regex
(
40 r
"preview_url\s*:\s*'(.+?)/?',", webpage
, 'video thumbnail', fatal
=False)
41 title
= self
._html
_search
_regex
(
42 r
'<title>(.+?)</title>', webpage
, 'video title')
43 description
= self
._html
_search
_meta
(
44 'description', webpage
, 'video description')
47 r
'<div class="col_2">Длительность: <span>(?P<minutes>\d+)м:(?P<seconds>\d+)с</span></div>',
49 duration
= int(mobj
.group('minutes')) * 60 + int(mobj
.group('seconds')) if mobj
else None
51 view_count
= self
._html
_search
_regex
(
52 r
'<div class="col_2">Просмотров: <span>(\d+)</span></div>',
53 webpage
, 'view count', fatal
=False)
56 comment_str
= self
._html
_search
_regex
(
57 r
'Комментарии: <span>([^<]+)</span>', webpage
, 'comment count', fatal
=False)
58 if comment_str
.startswith('комментариев нет'):
61 mobj
= re
.search(r
'\d+ из (?P<total>\d+) комментариев', comment_str
)
63 comment_count
= mobj
.group('total')
67 'display_id': display_id
,
69 'thumbnail': thumbnail
,
71 'description': description
,
73 'view_count': int_or_none(view_count
),
74 'comment_count': int_or_none(comment_count
),