]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/servingsys.py
New upstream version 2019.09.28
[youtubedl] / youtube_dl / extractor / servingsys.py
1 from __future__ import unicode_literals
2
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?',
14 'info_dict': {
15 'id': '5349193',
16 'title': 'AdAPPter_Hyundai_demo',
17 },
18 'playlist': [{
19 'md5': 'baed851342df6846eb8677a60a011a0f',
20 'info_dict': {
21 'id': '29955898',
22 'ext': 'flv',
23 'title': 'AdAPPter_Hyundai_demo (1)',
24 'duration': 74,
25 'tbr': 1378,
26 'width': 640,
27 'height': 400,
28 },
29 }, {
30 'md5': '979b4da2655c4bc2d81aeb915a8c5014',
31 'info_dict': {
32 'id': '29907998',
33 'ext': 'flv',
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,
43 },
44 '_skip': 'Blocked in the US [sic]',
45 }
46
47 def _real_extract(self, url):
48 pl_id = self._match_id(url)
49 vast_doc = self._download_xml(url, pl_id)
50
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 }