]>
Commit | Line | Data |
---|---|---|
7b0817e8 PH |
1 | from __future__ import unicode_literals |
2 | ||
7b0817e8 PH |
3 | from .common import InfoExtractor |
4 | from ..utils import ( | |
5 | int_or_none, | |
6 | ) | |
7 | ||
8 | ||
9 | class ServingSysIE(InfoExtractor): | |
10 | _VALID_URL = r'https?://(?:[^.]+\.)?serving-sys\.com/BurstingPipe/adServer\.bs\?.*?&pli=(?P<id>[0-9]+)' | |
11 | ||
12 | _TEST = { | |
13 | '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?', | |
e3327725 PH |
14 | 'info_dict': { |
15 | 'id': '5349193', | |
16 | 'title': 'AdAPPter_Hyundai_demo', | |
17 | }, | |
7b0817e8 | 18 | 'playlist': [{ |
7b0817e8 PH |
19 | 'md5': 'baed851342df6846eb8677a60a011a0f', |
20 | 'info_dict': { | |
e3327725 PH |
21 | 'id': '29955898', |
22 | 'ext': 'flv', | |
7b0817e8 PH |
23 | 'title': 'AdAPPter_Hyundai_demo (1)', |
24 | 'duration': 74, | |
25 | 'tbr': 1378, | |
26 | 'width': 640, | |
27 | 'height': 400, | |
28 | }, | |
29 | }, { | |
7b0817e8 PH |
30 | 'md5': '979b4da2655c4bc2d81aeb915a8c5014', |
31 | 'info_dict': { | |
e3327725 PH |
32 | 'id': '29907998', |
33 | 'ext': 'flv', | |
7b0817e8 PH |
34 | 'title': 'AdAPPter_Hyundai_demo (2)', |
35 | 'duration': 34, | |
36 | 'width': 854, | |
37 | 'height': 480, | |
38 | 'tbr': 516, | |
39 | }, | |
40 | }], | |
41 | 'params': { | |
42 | 'playlistend': 2, | |
a70515c0 | 43 | }, |
e3327725 | 44 | '_skip': 'Blocked in the US [sic]', |
7b0817e8 PH |
45 | } |
46 | ||
47 | def _real_extract(self, url): | |
e3327725 | 48 | pl_id = self._match_id(url) |
7b0817e8 | 49 | vast_doc = self._download_xml(url, pl_id) |
e3327725 | 50 | |
7b0817e8 PH |
51 | title = vast_doc.find('.//AdTitle').text |
52 | media = vast_doc.find('.//MediaFile').text | |
53 | info_url = self._search_regex(r'&adData=([^&]+)&', media, 'info URL') | |
54 | ||
55 | doc = self._download_xml(info_url, pl_id, 'Downloading video info') | |
56 | entries = [{ | |
57 | '_type': 'video', | |
58 | 'id': a.attrib['id'], | |
59 | 'title': '%s (%s)' % (title, a.attrib['assetID']), | |
60 | 'url': a.attrib['URL'], | |
61 | 'duration': int_or_none(a.attrib.get('length')), | |
62 | 'tbr': int_or_none(a.attrib.get('bitrate')), | |
63 | 'height': int_or_none(a.attrib.get('height')), | |
64 | 'width': int_or_none(a.attrib.get('width')), | |
65 | } for a in doc.findall('.//AdditionalAssets/asset')] | |
66 | ||
67 | return { | |
68 | '_type': 'playlist', | |
69 | 'id': pl_id, | |
70 | 'title': title, | |
71 | 'entries': entries, | |
72 | } |