]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vube.py
   1 from __future__ 
import unicode_literals
 
   5 from .common 
import InfoExtractor
 
   6 from ..utils 
import int_or_none
 
   9 class VubeIE(InfoExtractor
): 
  12     _VALID_URL 
= r
'http://vube\.com/(?:[^/]+/)+(?P<id>[\da-zA-Z]{10})\b' 
  16             'url': 'http://vube.com/Chiara+Grispo+Video+Channel/YL2qNPkqon', 
  17             'md5': 'db7aba89d4603dadd627e9d1973946fe', 
  21                 'title': 'Chiara Grispo - Price Tag by Jessie J', 
  22                 'description': 'md5:8ea652a1f36818352428cb5134933313', 
  23                 'thumbnail': 'http://frame.thestaticvube.com/snap/228x128/102e7e63057-5ebc-4f5c-4065-6ce4ebde131f.jpg', 
  24                 'uploader': 'Chiara.Grispo', 
  25                 'uploader_id': '1u3hX0znhP', 
  26                 'timestamp': 1388743358, 
  27                 'upload_date': '20140103', 
  32             'url': 'http://vube.com/SerainaMusic/my-7-year-old-sister-and-i-singing-alive-by-krewella/UeBhTudbfS?t=s&n=1', 
  33             'md5': '5d4a52492d76f72712117ce6b0d98d08', 
  37                 'title': 'My 7 year old Sister and I singing "Alive" by Krewella', 
  38                 'description': 'md5:40bcacb97796339f1690642c21d56f4a', 
  39                 'thumbnail': 'http://frame.thestaticvube.com/snap/228x128/102265d5a9f-0f17-4f6b-5753-adf08484ee1e.jpg', 
  40                 'uploader': 'Seraina', 
  41                 'uploader_id': 'XU9VE2BQ2q', 
  42                 'timestamp': 1396492438, 
  43                 'upload_date': '20140403', 
  49     def _real_extract(self
, url
): 
  50         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  51         video_id 
= mobj
.group('id') 
  53         video 
= self
._download
_json
( 
  54             'http://vube.com/api/v2/video/%s' % video_id
, video_id
, 'Downloading video JSON') 
  56         public_id 
= video
['public_id'] 
  60                 'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (fmt
['media_resolution_id'], public_id
), 
  61                 'height': int(fmt
['height']), 
  62                 'abr': int(fmt
['audio_bitrate']), 
  63                 'vbr': int(fmt
['video_bitrate']), 
  64                 'format_id': fmt
['media_resolution_id'] 
  65             } for fmt 
in video
['mtm'] if fmt
['transcoding_status'] == 'processed' 
  68         self
._sort
_formats
(formats
) 
  70         title 
= video
['title'] 
  71         description 
= video
.get('description') 
  72         thumbnail 
= video
['thumbnail_src'] 
  73         if thumbnail
.startswith('//'): 
  74             thumbnail 
= 'http:' + thumbnail
 
  75         uploader 
= video
['user_alias'] 
  76         uploader_id 
= video
['user_url_id'] 
  77         timestamp 
= int(video
['upload_time']) 
  78         duration 
= video
['duration'] 
  79         view_count 
= video
.get('raw_view_count') 
  80         like_count 
= video
.get('total_likes') 
  81         dislike_count
= video
.get('total_hates') 
  83         comment 
= self
._download
_json
( 
  84             'http://vube.com/api/video/%s/comment' % video_id
, video_id
, 'Downloading video comment JSON') 
  86         comment_count 
= int_or_none(comment
.get('total')) 
  92             'description': description
, 
  93             'thumbnail': thumbnail
, 
  95             'uploader_id': uploader_id
, 
  96             'timestamp': timestamp
, 
  98             'view_count': view_count
, 
  99             'like_count': like_count
, 
 100             'dislike_count': dislike_count
, 
 101             'comment_count': comment_count
,