From ce6df8545a97ecfc895d3cac35bbb642f36af460 Mon Sep 17 00:00:00 2001 From: Doug Shore Date: Tue, 24 May 2022 21:48:35 -0400 Subject: [PATCH 1/5] AD-1883: mock jwplayer adapter sourcing s3 --- adapters/jwplayer/jwplayer.go | 78 ++++++++++++++++++++++++++++++++ config/config.go | 1 + static/bidder-info/jwplayer.yaml | 9 ++++ 3 files changed, 88 insertions(+) create mode 100644 adapters/jwplayer/jwplayer.go create mode 100644 static/bidder-info/jwplayer.yaml diff --git a/adapters/jwplayer/jwplayer.go b/adapters/jwplayer/jwplayer.go new file mode 100644 index 00000000000..d833478ff67 --- /dev/null +++ b/adapters/jwplayer/jwplayer.go @@ -0,0 +1,78 @@ +package jwplayer + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" +) + +type adapter struct { + endpoint string +} + +// Builder builds a new instance of the JWPlayer adapter for the given bidder with the given config. +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { + bidder := &adapter{ + endpoint: config.Endpoint, + } + return bidder, nil +} + +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + requestJSON, err := json.Marshal(request) + if err != nil { + return nil, []error{err} + } + + requestData := &adapters.RequestData{ + Method: "GET", + Uri: a.endpoint, + Body: requestJSON, + } + + return []*adapters.RequestData{requestData}, nil +} + +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if responseData.StatusCode == http.StatusNoContent { + return nil, nil + } + + if responseData.StatusCode == http.StatusBadRequest { + err := &errortypes.BadInput{ + Message: "Unexpected status code: 400. Bad request from publisher. Run with request.debug = 1 for more info.", + } + return nil, []error{err} + } + + if responseData.StatusCode != http.StatusOK { + err := &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), + } + return nil, []error{err} + } + + var response openrtb2.BidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { + return nil, []error{err} + } + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + bidResponse.Currency = response.Cur + for _, seatBid := range response.SeatBid { + for i, _ := range seatBid.Bid { + b := &adapters.TypedBid{ + Bid: &seatBid.Bid[i], + BidType: openrtb_ext.BidTypeVideo, + } + bidResponse.Bids = append(bidResponse.Bids, b) + } + } + return bidResponse, nil +} diff --git a/config/config.go b/config/config.go index 6af0e6c2ab3..7dfcc870a70 100644 --- a/config/config.go +++ b/config/config.go @@ -812,6 +812,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.krushmedia.endpoint", "http://ads4.krushmedia.com/?c=rtb&m=req&key={{.AccountID}}") v.SetDefault("adapters.invibes.endpoint", "https://{{.Host}}/bid/ServerBidAdContent") v.SetDefault("adapters.iqzone.endpoint", "http://smartssp-us-east.iqzone.com/pserver") + v.SetDefault("adapters.jwplayer.endpoint", "http://demo.jwplayer.com.s3.us-east-1.amazonaws.com/vpb-server.json") v.SetDefault("adapters.kidoz.endpoint", "http://prebid-adapter.kidoz.net/openrtb2/auction?src=prebid-server") v.SetDefault("adapters.kubient.endpoint", "https://kssp.kbntx.ch/prebid") v.SetDefault("adapters.lockerdome.endpoint", "https://lockerdome.com/ladbid/prebidserver/openrtb2") diff --git a/static/bidder-info/jwplayer.yaml b/static/bidder-info/jwplayer.yaml new file mode 100644 index 00000000000..b97bbb80383 --- /dev/null +++ b/static/bidder-info/jwplayer.yaml @@ -0,0 +1,9 @@ +maintainer: + email: boost-engineering@jwplayer.com +capabilities: + app: + mediaTypes: + - video + site: + mediaTypes: + - video From c7da7f1ee46fad4e45dbae1a43bf9f740db36fbf Mon Sep 17 00:00:00 2001 From: Doug Shore Date: Fri, 27 May 2022 08:13:20 -0400 Subject: [PATCH 2/5] AD-1883: additional config --- adapters/jwplayer/jwplayer.go | 5 +++++ config/config.go | 1 - exchange/adapter_builders.go | 2 ++ openrtb_ext/bidders.go | 2 ++ static/bidder-info/jwplayer.yaml | 1 + static/bidder-params/jwplayer.json | 18 ++++++++++++++++++ 6 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 static/bidder-params/jwplayer.json diff --git a/adapters/jwplayer/jwplayer.go b/adapters/jwplayer/jwplayer.go index d833478ff67..fb8c215656b 100644 --- a/adapters/jwplayer/jwplayer.go +++ b/adapters/jwplayer/jwplayer.go @@ -30,10 +30,15 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte return nil, []error{err} } + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + requestData := &adapters.RequestData{ Method: "GET", Uri: a.endpoint, Body: requestJSON, + Headers: headers, } return []*adapters.RequestData{requestData}, nil diff --git a/config/config.go b/config/config.go index 7dfcc870a70..6af0e6c2ab3 100644 --- a/config/config.go +++ b/config/config.go @@ -812,7 +812,6 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.krushmedia.endpoint", "http://ads4.krushmedia.com/?c=rtb&m=req&key={{.AccountID}}") v.SetDefault("adapters.invibes.endpoint", "https://{{.Host}}/bid/ServerBidAdContent") v.SetDefault("adapters.iqzone.endpoint", "http://smartssp-us-east.iqzone.com/pserver") - v.SetDefault("adapters.jwplayer.endpoint", "http://demo.jwplayer.com.s3.us-east-1.amazonaws.com/vpb-server.json") v.SetDefault("adapters.kidoz.endpoint", "http://prebid-adapter.kidoz.net/openrtb2/auction?src=prebid-server") v.SetDefault("adapters.kubient.endpoint", "https://kssp.kbntx.ch/prebid") v.SetDefault("adapters.lockerdome.endpoint", "https://lockerdome.com/ladbid/prebidserver/openrtb2") diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index af5507bb4d6..2c064898556 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -68,6 +68,7 @@ import ( "github.com/prebid/prebid-server/adapters/iqzone" "github.com/prebid/prebid-server/adapters/ix" "github.com/prebid/prebid-server/adapters/jixie" + "github.com/prebid/prebid-server/adapters/jwplayer" "github.com/prebid/prebid-server/adapters/kayzen" "github.com/prebid/prebid-server/adapters/kidoz" "github.com/prebid/prebid-server/adapters/krushmedia" @@ -201,6 +202,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderIQZone: iqzone.Builder, openrtb_ext.BidderIx: ix.Builder, openrtb_ext.BidderJixie: jixie.Builder, + openrtb_ext.BidderJWPlayer: jwplayer.Builder, openrtb_ext.BidderKayzen: kayzen.Builder, openrtb_ext.BidderKidoz: kidoz.Builder, openrtb_ext.BidderKrushmedia: krushmedia.Builder, diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 1d189c66a5d..f1c29063b83 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -139,6 +139,7 @@ const ( BidderIQZone BidderName = "iqzone" BidderIx BidderName = "ix" BidderJixie BidderName = "jixie" + BidderJWPlayer BidderName = "jwplayer" BidderKayzen BidderName = "kayzen" BidderKidoz BidderName = "kidoz" BidderKrushmedia BidderName = "krushmedia" @@ -274,6 +275,7 @@ func CoreBidderNames() []BidderName { BidderIQZone, BidderIx, BidderJixie, + BidderJWPlayer, BidderKayzen, BidderKidoz, BidderKrushmedia, diff --git a/static/bidder-info/jwplayer.yaml b/static/bidder-info/jwplayer.yaml index b97bbb80383..e9157cd8381 100644 --- a/static/bidder-info/jwplayer.yaml +++ b/static/bidder-info/jwplayer.yaml @@ -1,5 +1,6 @@ maintainer: email: boost-engineering@jwplayer.com +gvlVendorID: 1046 capabilities: app: mediaTypes: diff --git a/static/bidder-params/jwplayer.json b/static/bidder-params/jwplayer.json new file mode 100644 index 00000000000..76fc4b8c0cf --- /dev/null +++ b/static/bidder-params/jwplayer.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "JWPlayer Adapter Params", + "description": "A schema which validates params accepted by the JWPlayer adapter", + + "type": "object", + "properties": { + "placementid": { + "type": "string" + }, + "pubid": { + "type": "string" + } + }, + "required": [ + "placementid" + ] +} From 83683bef31ab13a984f41cd59c5fa234452d693a Mon Sep 17 00:00:00 2001 From: Doug Shore Date: Fri, 27 May 2022 12:14:27 -0400 Subject: [PATCH 3/5] AD-1883: camel case bidding parameters --- static/bidder-params/jwplayer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/static/bidder-params/jwplayer.json b/static/bidder-params/jwplayer.json index 76fc4b8c0cf..07ea718919d 100644 --- a/static/bidder-params/jwplayer.json +++ b/static/bidder-params/jwplayer.json @@ -5,14 +5,14 @@ "type": "object", "properties": { - "placementid": { + "placementId": { "type": "string" }, - "pubid": { + "publisherId": { "type": "string" } }, "required": [ - "placementid" + "placementId" ] } From f486d042c55269dbbabddfaff2d7dc180fe1ceb6 Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Tue, 12 Jul 2022 18:22:12 -0400 Subject: [PATCH 4/5] sets the impression id to bid id --- adapters/jwplayer/jwplayer.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/adapters/jwplayer/jwplayer.go b/adapters/jwplayer/jwplayer.go index fb8c215656b..001088c4d32 100644 --- a/adapters/jwplayer/jwplayer.go +++ b/adapters/jwplayer/jwplayer.go @@ -68,12 +68,19 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R return nil, []error{err} } + response.ID = request.ID + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) bidResponse.Currency = response.Cur for _, seatBid := range response.SeatBid { for i, _ := range seatBid.Bid { + bid := &seatBid.Bid[i] + if matchingImpId := getImpId(i, *request); matchingImpId != "" { + bid.ID = matchingImpId + } + b := &adapters.TypedBid{ - Bid: &seatBid.Bid[i], + Bid: bid, BidType: openrtb_ext.BidTypeVideo, } bidResponse.Bids = append(bidResponse.Bids, b) @@ -81,3 +88,12 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } return bidResponse, nil } + +func getImpId(impIdx int, request openrtb2.BidRequest) string { + impressions := request.Imp + if impIdx >= len(impressions) { + return "" + } + + return impressions[impIdx].ID +} From 1f9508aa88b146df1c5358dc14ea81361d1e853d Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Tue, 12 Jul 2022 18:23:27 -0400 Subject: [PATCH 5/5] sets to impid --- adapters/jwplayer/jwplayer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/jwplayer/jwplayer.go b/adapters/jwplayer/jwplayer.go index 001088c4d32..38439f00ad0 100644 --- a/adapters/jwplayer/jwplayer.go +++ b/adapters/jwplayer/jwplayer.go @@ -76,7 +76,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R for i, _ := range seatBid.Bid { bid := &seatBid.Bid[i] if matchingImpId := getImpId(i, *request); matchingImpId != "" { - bid.ID = matchingImpId + bid.ImpID = matchingImpId } b := &adapters.TypedBid{