]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/beeg.py
   1 from __future__ 
import unicode_literals
 
   3 from .common 
import InfoExtractor
 
   4 from ..compat 
import compat_str
 
  11 class BeegIE(InfoExtractor
): 
  12     _VALID_URL 
= r
'https?://(?:www\.)?beeg\.com/(?P<id>\d+)' 
  14         'url': 'http://beeg.com/5416503', 
  15         'md5': 'a1a1b1a8bc70a89e49ccfd113aed0820', 
  19             'title': 'Sultry Striptease', 
  20             'description': 'md5:d22219c09da287c14bed3d6c37ce4bc2', 
  21             'timestamp': 1391813355, 
  22             'upload_date': '20140207', 
  29     def _real_extract(self
, url
): 
  30         video_id 
= self
._match
_id
(url
) 
  32         webpage 
= self
._download
_webpage
(url
, video_id
) 
  34         beeg_version 
= self
._search
_regex
( 
  35             r
'beeg_version\s*=\s*([\da-zA-Z_-]+)', webpage
, 'beeg version', 
  36             default
='1546225636701') 
  38         for api_path 
in ('', 'api.'): 
  39             video 
= self
._download
_json
( 
  40                 'https://%sbeeg.com/api/v6/%s/video/%s' 
  41                 % (api_path
, beeg_version
, video_id
), video_id
, 
  42                 fatal
=api_path 
== 'api.') 
  47         for format_id
, video_url 
in video
.items(): 
  50             height 
= self
._search
_regex
( 
  51                 r
'^(\d+)[pP]$', format_id
, 'height', default
=None) 
  55                 'url': self
._proto
_relative
_url
( 
  56                     video_url
.replace('{DATA_MARKERS}', 'data=pc_XX__%s_0' % beeg_version
), 'https:'), 
  57                 'format_id': format_id
, 
  58                 'height': int(height
), 
  60         self
._sort
_formats
(formats
) 
  62         title 
= video
['title'] 
  63         video_id 
= compat_str(video
.get('id') or video_id
) 
  64         display_id 
= video
.get('code') 
  65         description 
= video
.get('desc') 
  66         series 
= video
.get('ps_name') 
  68         timestamp 
= unified_timestamp(video
.get('date')) 
  69         duration 
= int_or_none(video
.get('duration')) 
  71         tags 
= [tag
.strip() for tag 
in video
['tags'].split(',')] if video
.get('tags') else None 
  75             'display_id': display_id
, 
  77             'description': description
, 
  79             'timestamp': timestamp
, 
  83             'age_limit': self
._rta
_search
(webpage
),