You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.2 KiB

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