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.

72 lines
2.3 KiB

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