From 1a0ef36489ee7eb7d9093a27280f7565990eaaa8 Mon Sep 17 00:00:00 2001 From: Laurentiu Badea Date: Tue, 30 Jul 2024 02:07:48 +0000 Subject: [PATCH] OpenX: return cat/dur for video bids --- adapters/openx/openx.go | 16 ++++++++++++++-- .../openx/openxtest/exemplary/simple-video.json | 14 ++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/adapters/openx/openx.go b/adapters/openx/openx.go index d56339df178..83d50b2b56b 100644 --- a/adapters/openx/openx.go +++ b/adapters/openx/openx.go @@ -231,14 +231,26 @@ func (a *OpenxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRe for _, sb := range bidResp.SeatBid { for i := range sb.Bid { bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ - Bid: &sb.Bid[i], - BidType: getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp), + Bid: &sb.Bid[i], + BidType: getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp), + BidVideo: getBidVideo(&sb.Bid[i]), }) } } return bidResponse, nil } +func getBidVideo(bid *openrtb2.Bid) *openrtb_ext.ExtBidPrebidVideo { + var primaryCategory string + if len(bid.Cat) > 0 { + primaryCategory = bid.Cat[0] + } + return &openrtb_ext.ExtBidPrebidVideo{ + PrimaryCategory: primaryCategory, + Duration: int(bid.Dur), + } +} + // getMediaTypeForImp figures out which media type this bid is for. // // OpenX doesn't support multi-type impressions. diff --git a/adapters/openx/openxtest/exemplary/simple-video.json b/adapters/openx/openxtest/exemplary/simple-video.json index 4b7d7798b96..e6b67775999 100644 --- a/adapters/openx/openxtest/exemplary/simple-video.json +++ b/adapters/openx/openxtest/exemplary/simple-video.json @@ -60,7 +60,10 @@ "adm": "some-test-ad", "crid": "crid_10", "w": 1024, - "h": 576 + "h": 576, + "cattax": 1, + "cat": ["IAB20"], + "dur": 30 }] } ] @@ -82,7 +85,14 @@ "adm": "some-test-ad", "crid": "crid_10", "w": 1024, - "h": 576 + "h": 576, + "cattax": 1, + "cat": ["IAB20"], + "dur": 30 + }, + "video": { + "duration": 30, + "primary_category": "IAB20" }, "type": "video" }