]>
 
 
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/piksel.py 
 
 
 
 
 
 
 
 
   2  from  __future__ 
import  unicode_literals
 
   6  from  . common 
import  InfoExtractor
 
   7  from  .. compat 
import  compat_str
 
  17  class  PikselIE ( InfoExtractor
):  
  18      _VALID_URL 
=  r
'https?://player\.piksel\.com/v/(?P<id>[a-z0-9]+)'  
  21              'url' :  'http://player.piksel.com/v/nv60p12f' ,  
  22              'md5' :  'd9c17bbe9c3386344f9cfd32fad8d235' ,  
  26                  'title' :  'فن الحياة  - الحلقة 1' ,  
  27                  'description' :  'احدث برامج الداعية الاسلامي " مصطفي حسني " فى رمضان 2016علي النهار نور' ,  
  28                  'timestamp' :  1465231790 ,  
  29                  'upload_date' :  '20160606' ,  
  33              # Original source: http://www.uscourts.gov/cameras-courts/state-washington-vs-donald-j-trump-et-al  
  34              'url' :  'https://player.piksel.com/v/v80kqp41' ,  
  35              'md5' :  '753ddcd8cc8e4fa2dda4b7be0e77744d' ,  
  39                  'title' :  'WAW- State of Washington vs. Donald J. Trump, et al' ,  
  40                  'description' :  'State of Washington vs. Donald J. Trump, et al, Case Number 17-CV-00141-JLR, TRO Hearing, Civil Rights Case, 02/3/2017, 1:00 PM (PST), Seattle Federal Courthouse, Seattle, WA, Judge James L. Robart presiding.' ,  
  41                  'timestamp' :  1486171129 ,  
  42                  'upload_date' :  '20170204' ,  
  48      def  _extract_url ( webpage
):  
  50              r
'<iframe[^>]+src=["\' ]( ?P
< url
>( ?
: https?
:) ?
// player\
. piksel\
. com
/ v
/[ a
- z0
- 9 ]+) ',  
  53              return mobj.group(' url
')  
  55      def _real_extract(self, url):  
  56          video_id = self._match_id(url)  
  57          webpage = self._download_webpage(url, video_id)  
  58          app_token = self._search_regex([  
  59              r' clientAPI\s
*: \s
* "([^" ]+) "',  
  60              r'data-de-api-key\s*=\s*" ([ ^
"]+)" '  
  61          ], webpage, ' app token
')  
  62          response = self._download_json(  
  63              ' http
:// player
. piksel
. com
/ ws
/ ws_program
/ api
/ %s/ mode
/ json
/ apiv
/ 5 ' % app_token,  
  67          failure = response.get(' failure
')  
  69              raise ExtractorError(response[' failure
'][' reason
'], expected=True)  
  70          video_data = response[' WsProgramResponse
'][' program
'][' asset
']  
  71          title = video_data[' title
']  
  75          m3u8_url = dict_get(video_data, [  
  82              formats.extend(self._extract_m3u8_formats(  
  83                  m3u8_url, video_id, ' mp4
', ' m3u8_native
',  
  84                  m3u8_id=' hls
', fatal=False))  
  86          asset_type = dict_get(video_data, [' assetType
', ' asset_type
'])  
  87          for asset_file in video_data.get(' assetFiles
', []):  
  88              # TODO: extract rtmp formats  
  89              http_url = asset_file.get(' http_url
')  
  93              vbr = int_or_none(asset_file.get(' videoBitrate
'), 1024)  
  94              abr = int_or_none(asset_file.get(' audioBitrate
'), 1024)  
  95              if asset_type == ' video
':  
  97              elif asset_type == ' audio
':  
 102                  format_id.append(compat_str(tbr))  
 105                  ' format_id
': ' - '.join(format_id),  
 106                  ' url
': unescapeHTML(http_url),  
 109                  ' width
': int_or_none(asset_file.get(' videoWidth
')),  
 110                  ' height
': int_or_none(asset_file.get(' videoHeight
')),  
 111                  ' filesize
': int_or_none(asset_file.get(' filesize
')),  
 114          self._sort_formats(formats)  
 119              ' description
': video_data.get(' description
'),  
 120              ' thumbnail
': video_data.get(' thumbnailUrl
'),  
 121              ' timestamp
': parse_iso8601(video_data.get(' dateadd
')),