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.

69 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. }
  36. def _real_extract(self, url):
  37. mobj = re.match(self._VALID_URL, url)
  38. pl_id = mobj.group('id')
  39. vast_doc = self._download_xml(url, pl_id)
  40. title = vast_doc.find('.//AdTitle').text
  41. media = vast_doc.find('.//MediaFile').text
  42. info_url = self._search_regex(r'&adData=([^&]+)&', media, 'info URL')
  43. doc = self._download_xml(info_url, pl_id, 'Downloading video info')
  44. entries = [{
  45. '_type': 'video',
  46. 'id': a.attrib['id'],
  47. 'title': '%s (%s)' % (title, a.attrib['assetID']),
  48. 'url': a.attrib['URL'],
  49. 'duration': int_or_none(a.attrib.get('length')),
  50. 'tbr': int_or_none(a.attrib.get('bitrate')),
  51. 'height': int_or_none(a.attrib.get('height')),
  52. 'width': int_or_none(a.attrib.get('width')),
  53. } for a in doc.findall('.//AdditionalAssets/asset')]
  54. return {
  55. '_type': 'playlist',
  56. 'id': pl_id,
  57. 'title': title,
  58. 'entries': entries,
  59. }