]>
 
 
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/(?:refid/[^/]+/prefid/)?(?P<id>[a-z0-9_]+)'  
  21              'url' :  'http://player.piksel.com/v/ums2867l' ,  
  22              'md5' :  '34e34c8d89dc2559976a6079db531e85' ,  
  26                  'title' :  'GX-005 with Caption' ,  
  27                  'timestamp' :  1481335659 ,  
  28                  'upload_date' :  '20161210'  
  32              # Original source: http://www.uscourts.gov/cameras-courts/state-washington-vs-donald-j-trump-et-al  
  33              'url' :  'https://player.piksel.com/v/v80kqp41' ,  
  34              'md5' :  '753ddcd8cc8e4fa2dda4b7be0e77744d' ,  
  38                  'title' :  'WAW- State of Washington vs. Donald J. Trump, et al' ,  
  39                  '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.' ,  
  40                  'timestamp' :  1486171129 ,  
  41                  'upload_date' :  '20170204'  
  45              # https://www3.nhk.or.jp/nhkworld/en/ondemand/video/2019240/  
  46              'url' :  'http://player.piksel.com/v/refid/nhkworld/prefid/nw_vod_v_en_2019_240_20190823233000_02_1566873477' ,  
  47              'only_matching' :  True ,  
  52      def  _extract_url ( webpage
):  
  54              r
'<iframe[^>]+src=["\' ]( ?P
< url
>( ?
: https?
:) ?
// player\
. piksel\
. com
/ v
/[ a
- z0
- 9 ]+) ',  
  57              return mobj.group(' url
')  
  59      def _real_extract(self, url):  
  60          display_id = self._match_id(url)  
  61          webpage = self._download_webpage(url, display_id)  
  62          video_id = self._search_regex(  
  63              r' data
- de
- program
- uuid
=[ \' "]([a-z0-9]+)',  
  64              webpage, 'program uuid', default=display_id)  
  65          app_token = self._search_regex([  
  66              r'clientAPI\s*:\s*" ([ ^
"]+)" ',  
  67              r' data
- de
- api
- key\s
*= \s
* "([^" ]+) "'  
  68          ], webpage, 'app token')  
  69          response = self._download_json(  
  70              'http://player.piksel.com/ws/ws_program/api/ %s /mode/json/apiv/5' % app_token,  
  74          failure = response.get('failure')  
  76              raise ExtractorError(response['failure']['reason'], expected=True)  
  77          video_data = response['WsProgramResponse']['program']['asset']  
  78          title = video_data['title']  
  82          m3u8_url = dict_get(video_data, [  
  89              formats.extend(self._extract_m3u8_formats(  
  90                  m3u8_url, video_id, 'mp4', 'm3u8_native',  
  91                  m3u8_id='hls', fatal=False))  
  93          asset_type = dict_get(video_data, ['assetType', 'asset_type'])  
  94          for asset_file in video_data.get('assetFiles', []):  
  95              # TODO: extract rtmp formats  
  96              http_url = asset_file.get('http_url')  
 100              vbr = int_or_none(asset_file.get('videoBitrate'), 1024)  
 101              abr = int_or_none(asset_file.get('audioBitrate'), 1024)  
 102              if asset_type == 'video':  
 104              elif asset_type == 'audio':  
 109                  format_id.append(compat_str(tbr))  
 112                  'format_id': '-'.join(format_id),  
 113                  'url': unescapeHTML(http_url),  
 116                  'width': int_or_none(asset_file.get('videoWidth')),  
 117                  'height': int_or_none(asset_file.get('videoHeight')),  
 118                  'filesize': int_or_none(asset_file.get('filesize')),  
 121          self._sort_formats(formats)  
 124          for caption in video_data.get('captions', []):  
 125              caption_url = caption.get('url')  
 127                  subtitles.setdefault(caption.get('locale', 'en'), []).append({  
 133              'description': video_data.get('description'),  
 134              'thumbnail': video_data.get('thumbnailUrl'),  
 135              'timestamp': parse_iso8601(video_data.get('dateadd')),  
 137              'subtitles': subtitles,