]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/twentyfourvideo.py
a983ebf05ac512242415a3052fbd172668ff060e
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  13 class TwentyFourVideoIE(InfoExtractor
): 
  15     _VALID_URL 
= r
'https?://(?:www\.)?24video\.(?:net|me|xxx|sex)/(?:video/(?:view|xml)/|player/new24_play\.swf\?id=)(?P<id>\d+)' 
  18         'url': 'http://www.24video.net/video/view/1044982', 
  19         'md5': 'e09fc0901d9eaeedac872f154931deeb', 
  23             'title': 'Эротика каменного века', 
  24             'description': 'Как смотрели порно в каменном веке.', 
  25             'thumbnail': r
're:^https?://.*\.jpg$', 
  26             'uploader': 'SUPERTELO', 
  28             'timestamp': 1275937857, 
  29             'upload_date': '20100607', 
  35         'url': 'http://www.24video.net/player/new24_play.swf?id=1044982', 
  36         'only_matching': True, 
  38         'url': 'http://www.24video.me/video/view/1044982', 
  39         'only_matching': True, 
  42     def _real_extract(self
, url
): 
  43         video_id 
= self
._match
_id
(url
) 
  45         webpage 
= self
._download
_webpage
( 
  46             'http://www.24video.sex/video/view/%s' % video_id
, video_id
) 
  48         title 
= self
._og
_search
_title
(webpage
) 
  49         description 
= self
._html
_search
_regex
( 
  50             r
'<(p|span)[^>]+itemprop="description"[^>]*>(?P<description>[^<]+)</\1>', 
  51             webpage
, 'description', fatal
=False, group
='description') 
  52         thumbnail 
= self
._og
_search
_thumbnail
(webpage
) 
  53         duration 
= int_or_none(self
._og
_search
_property
( 
  54             'duration', webpage
, 'duration', fatal
=False)) 
  55         timestamp 
= parse_iso8601(self
._search
_regex
( 
  56             r
'<time id="video-timeago" datetime="([^"]+)" itemprop="uploadDate">', 
  57             webpage
, 'upload date')) 
  59         uploader 
= self
._html
_search
_regex
( 
  60             r
'class="video-uploaded"[^>]*>\s*<a href="/jsecUser/movies/[^"]+"[^>]*>([^<]+)</a>', 
  61             webpage
, 'uploader', fatal
=False) 
  63         view_count 
= int_or_none(self
._html
_search
_regex
( 
  64             r
'<span class="video-views">(\d+) просмотр', 
  65             webpage
, 'view count', fatal
=False)) 
  66         comment_count 
= int_or_none(self
._html
_search
_regex
( 
  67             r
'<a[^>]+href="#tab-comments"[^>]*>(\d+) комментари', 
  68             webpage
, 'comment count', fatal
=False)) 
  72             r
'http://www.24video.sex/video/xml/%s?mode=init' % video_id
, 
  73             video_id
, 'Downloading init XML') 
  75         video_xml 
= self
._download
_xml
( 
  76             'http://www.24video.sex/video/xml/%s?mode=play' % video_id
, 
  77             video_id
, 'Downloading video XML') 
  79         video 
= xpath_element(video_xml
, './/video', 'video', fatal
=True) 
  82             'url': xpath_attr(video
, '', 'url', 'video URL', fatal
=True), 
  85         like_count 
= int_or_none(video
.get('ratingPlus')) 
  86         dislike_count 
= int_or_none(video
.get('ratingMinus')) 
  87         age_limit 
= 18 if video
.get('adult') == 'true' else 0 
  92             'description': description
, 
  93             'thumbnail': thumbnail
, 
  96             'timestamp': timestamp
, 
  97             'view_count': view_count
, 
  98             'comment_count': comment_count
, 
  99             'like_count': like_count
, 
 100             'dislike_count': dislike_count
, 
 101             'age_limit': age_limit
,