Giter Club home page Giter Club logo

vast's Introduction

Vast

VAST 4.2 : https://github.com/haxqer/vast/tree/4.2

XML/Json

โญ VAST Ad generator and parser library on GoLang.

todo

  • Support for all TrackEvents

Specs

Installation

go get -u github.com/haxqer/vast

Quick Start

package main

import (
	"encoding/xml"
	"fmt"
	. "github.com/haxqer/vast"
	"time"
)

func main()  {
	v := VAST{
		Version: "3.0",
		Ads: []Ad{
			{
				ID:   "123",
				Type: "front",
				InLine: &InLine{
					AdSystem: &AdSystem{Name: "DSP"},
					AdTitle:  CDATAString{CDATA: "adTitle"},
					Impressions: []Impression{
						{ID: "11111", URI: "http://impressionv1.track.com"},
						{ID: "11112", URI: "http://impressionv2.track.com"},
					},
					Creatives: []Creative{
						{
							ID:       "987",
							Sequence: 0,
							Linear: &Linear{
								Duration: Duration(15 * time.Second),
								TrackingEvents: []Tracking{
									{Event: Event_type_start, URI: "http://track.xxx.com/q/start?xx"},
									{Event: Event_type_firstQuartile, URI: "http://track.xxx.com/q/firstQuartile?xx"},
									{Event: Event_type_midpoint, URI: "http://track.xxx.com/q/midpoint?xx"},
									{Event: Event_type_thirdQuartile, URI: "http://track.xxx.com/q/thirdQuartile?xx"},
									{Event: Event_type_complete, URI: "http://track.xxx.com/q/complete?xx"},
								},
								MediaFiles: []MediaFile{
									{
										Delivery: "progressive",
										Type:     "video/mp4",
										Width:    1024,
										Height:   576,
										URI:      "http://mp4.res.xxx.com/new_video/2020/01/14/1485/335928CBA9D02E95E63ED9F4D45DF6DF_20200114_1_1_1051.mp4",
									},
								},
							},
						},
					},
				},
			},
		},
	}
	vastXMLText, _ := xml.Marshal(v)
	fmt.Printf("%s", vastXMLText)
}

Result Demo

<VAST version="3.0">
    <Ad id="123" type="front">
        <InLine>
            <AdSystem><![CDATA[DSP]]></AdSystem>
            <AdTitle><![CDATA[adTitle]]></AdTitle>
            <Impression id="11111"><![CDATA[http://impressionv1.track.com]]></Impression>
            <Impression id="11112"><![CDATA[http://impressionv2.track.com]]></Impression>
            <Creatives>
                <Creative id="987">
                    <Linear>
                        <Duration>00:00:15</Duration>
                        <TrackingEvents>
                            <Tracking event="start"><![CDATA[http://track.xxx.com/q/start?xx]]></Tracking>
                            <Tracking event="firstQuartile"><![CDATA[http://track.xxx.com/q/firstQuartile?xx]]></Tracking>
                            <Tracking event="midpoint"><![CDATA[http://track.xxx.com/q/midpoint?xx]]></Tracking>
                            <Tracking event="thirdQuartile"><![CDATA[http://track.xxx.com/q/thirdQuartile?xx]]></Tracking>
                            <Tracking event="complete"><![CDATA[http://track.xxx.com/q/complete?xx]]></Tracking>
                        </TrackingEvents>
                        <MediaFiles>
                            <MediaFile delivery="progressive" type="video/mp4" width="1024" height="576"><![CDATA[http://mp4.res.xxx.com/new_video/2020/01/14/1485/335928CBA9D02E95E63ED9F4D45DF6DF_20200114_1_1_1051.mp4]]></MediaFile>
                        </MediaFiles>
                    </Linear>
                </Creative>
            </Creatives>
            <Description></Description>
            <Survey></Survey>
        </InLine>
    </Ad>
</VAST>

Thanks

vast's People

Contributors

0tarof avatar haxqer avatar pabramowicz avatar xsharp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar

vast's Issues

Adding root xml tag name (VAST)

It would be great to include root xml tag name (VAST) to be able to catch problems with parsing other xml based formats (e.g vmap) earlier. Sometimes ad servers might respond with e.g vmap (xml format as well) in which case unmarshalling succeeds - and would be nicer to get an early error in that case.
It's one liner inside VAST struct:

XMLName xml.Name `xml:"VAST"`

The lib produces invalid Vast 4.1 documents

Hi,
First of all, I want to thank you for sharing your work and making this lib OSS!

I'm working on a project that needs to produce VAST files and one of my team-mates noticed that the results produced by this lib aren't compliant with VAST 4.1.

Vastvalidator tool returns the following error when checking the package output:
"Attribute 'idValue' is not allowed to appear in element 'UniversalAdId'".

The VAST 4.1 spec mentions:

was removed as of 4.1. Media players should not fail if this attribute is present, but should
always use the Content as the source of truth for the creative ID value.```

There's a chance that someone from my team will create a patch to fix this issue.

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.