]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/servingsys.py
   1 from __future__ 
import unicode_literals
 
   5 from .common 
import InfoExtractor
 
  11 class ServingSysIE(InfoExtractor
): 
  12     _VALID_URL 
= r
'https?://(?:[^.]+\.)?serving-sys\.com/BurstingPipe/adServer\.bs\?.*?&pli=(?P<id>[0-9]+)' 
  15         'url': 'http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=is&c=23&pl=VAST&pli=5349193&PluID=0&pos=7135&ord=[timestamp]&cim=1?', 
  17             'file': '29955898.flv', 
  18             'md5': 'baed851342df6846eb8677a60a011a0f', 
  20                 'title': 'AdAPPter_Hyundai_demo (1)', 
  27             'file': '29907998.flv', 
  28             'md5': '979b4da2655c4bc2d81aeb915a8c5014', 
  30                 'title': 'AdAPPter_Hyundai_demo (2)', 
  40         'skip': 'Blocked in the US [sic]', 
  43     def _real_extract(self
, url
): 
  44         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  45         pl_id 
= mobj
.group('id') 
  47         vast_doc 
= self
._download
_xml
(url
, pl_id
) 
  48         title 
= vast_doc
.find('.//AdTitle').text
 
  49         media 
= vast_doc
.find('.//MediaFile').text
 
  50         info_url 
= self
._search
_regex
(r
'&adData=([^&]+)&', media
, 'info URL') 
  52         doc 
= self
._download
_xml
(info_url
, pl_id
, 'Downloading video info') 
  56             'title': '%s (%s)' % (title
, a
.attrib
['assetID']), 
  57             'url': a
.attrib
['URL'], 
  58             'duration': int_or_none(a
.attrib
.get('length')), 
  59             'tbr': int_or_none(a
.attrib
.get('bitrate')), 
  60             'height': int_or_none(a
.attrib
.get('height')), 
  61             'width': int_or_none(a
.attrib
.get('width')), 
  62         } for a 
in doc
.findall('.//AdditionalAssets/asset')]