Giter VIP home page Giter VIP logo

python-vast-xml-generator's Introduction

python-vast-xml-generator

if you plan to write an video ad server with vast support you can generate xml response using this lib,

Example

Create instance

vast = VAST({"version":"3.0", "VASTErrorURI": "optional url if something went wrong in client side"}) # create instance of vast object, version is vast version, 

Adding Ad

ad = vast.attachAd({ 
    "id": "1", # ad id 
    "structure": 'inline', # or "wrapper", 
    "sequence": "1", # optional, not required
    "Error": 'http://error.err', # error url if something went wrong in client side, optional
    "AdTitle": 'Common name of the ad' # required for inline structure, 
    "AdSystem": { "name": 'name of adserver or company', "version": "1.0"  }, 
    "Description": "optional description of ad",
    "Advertiser": "Optional name of advertiser",
    "Pricing": "Optional price (if you want to RTB on vast)",
    "Extensions": """<xml>xml extension for client side</xml>""",
  })

Add Impression url

# you can add many servers if you need to
ad.attachImpression({
    "id": "servername"
   "url": "impression url"
})

Add Linear Creative

# you can give any valid VAST XmlTagName and value for Creative
creative = ad.attachCreative('Linear', {
    "AdParameters" : """<xml></xml>""", #Optional
    "Duration" : '00:00:30' # required for linear type
});
# you can give any valid VAST XmlTagName and value for media file
creative.attachMediaFile('file url', {
   "type": "video/mp4",
   "bitrate": "320",
   "minBitrate": "320",
   "maxBitrate": "320",
   "width": "640",
   "height": "360",
   "scalable": "true",
   "maintainAspectRatio": "true",
   "codec": "",
   "apiFramework": "VPAID",
});

# You can add any valid  tracking events: vast/trackingEvent.py#L18
creative.attachTrackingEvent('creativeView', 'server url');
# many times 
creative.attachTrackingEvent('progress', 'server url', '00:00:01');
#
creative.attachVideoClick('ClickThrough', 'click target url');
creative.attachClickThrough("Url of server")
creative.attachClick("Url") # look at the vast 3.0 documentation 

vast.xml() // returns XMLBuilder object, to print str(vast.xml()) 

python-vast-xml-generator's People

Contributors

selam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.