Skip to content

Commit

Permalink
Bright Mountain Media Bid Adapter: add video support and refactor (#6607
Browse files Browse the repository at this point in the history
)

* Update BrightMountainMedia cookie sync URL

* Bright Mountain Media: Update bidder code

* Bright Mountain Media: Add brightmountainmedia as alias

* Bright Mountain Media: Update Bid Endpoint

* Bright Mountain Media: Add support for Video and refactor

* Bright Mountain Media Bid Adapter: add video support and refactor

* Bright Mountain Media Bid Adapter: add video support and refactor

* Bright Mountain Media Bid Adapter: update test coverage

* Bright Mountain Media Bid Adapter: fix typo

* Bright Mountain Media Bid Adapter: fix example

* Bright Mountain Media Bid Adapter: add support for reading video params from ad unit

* Bright Mountain Media Bid Adapter: update read video config from bid.mediaTypes.video object

* Bright Mountain Media Bid Adapter: update playbackmethod and skip for video params

* Bright Mountain Media Bid Adapter: update skip for video params in test
  • Loading branch information
BrightMountainMedia authored May 10, 2021
1 parent 6f732e0 commit e04ed88
Show file tree
Hide file tree
Showing 3 changed files with 243 additions and 76 deletions.
73 changes: 56 additions & 17 deletions modules/brightMountainMediaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import * as utils from '../src/utils.js';

const BIDDER_CODE = 'bmtm';
const AD_URL = 'https://one.elitebidder.com/api/hb';
const SYNC_URL = 'https://console.brightmountainmedia.com:8443/cookieSync';

const videoExt = [
'video/x-ms-wmv',
'video/x-flv',
'video/mp4',
'video/3gpp',
'application/x-mpegURL',
'video/quicktime',
'video/x-msvideo',
'application/x-shockwave-flash',
'application/javascript'
];

export const spec = {
code: BIDDER_CODE,
aliases: ['brightmountainmedia'],
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
supportedMediaTypes: [BANNER, VIDEO],

isBidRequestValid: (bid) => {
return Boolean(bid.bidId && bid.params && bid.params.placement_id);
Expand Down Expand Up @@ -42,13 +55,38 @@ export const spec = {
}
for (let i = 0; i < validBidRequests.length; i++) {
let bid = validBidRequests[i];
let traff = bid.params.traffic || BANNER
let placement = {
placementId: bid.params.placement_id,
bidId: bid.bidId,
sizes: bid.mediaTypes[traff].sizes,
traffic: traff
};

if (bid.mediaTypes.hasOwnProperty(BANNER)) {
placement['traffic'] = BANNER;
if (bid.mediaTypes.banner.sizes) {
placement['sizes'] = bid.mediaTypes.banner.sizes;
}
}

if (bid.mediaTypes.hasOwnProperty(VIDEO)) {
placement['traffic'] = VIDEO;
if (bid.mediaTypes.video.context) {
placement['context'] = bid.mediaTypes.video.context;
}
if (bid.mediaTypes.video.playerSize) {
placement['sizes'] = bid.mediaTypes.video.playerSize;
}
if (bid.mediaTypes.video.mimes && Array.isArray(bid.mediaTypes.video.mimes)) {
placement['mimes'] = bid.mediaTypes.video.mimes;
} else {
placement['mimes'] = videoExt;
}
if (bid.mediaTypes.video.skip != undefined) {
placement['skip'] = bid.mediaTypes.video.skip;
}
if (bid.mediaTypes.video.playbackmethod && Array.isArray(bid.mediaTypes.video.playbackmethod)) {
placement['playbackmethod'] = bid.mediaTypes.video.playbackmethod;
}
}
if (bid.schain) {
placement.schain = bid.schain;
}
Expand All @@ -62,25 +100,26 @@ export const spec = {
},

interpretResponse: (serverResponse) => {
let response = [];
try {
serverResponse = serverResponse.body;
for (let i = 0; i < serverResponse.length; i++) {
let resItem = serverResponse[i];

response.push(resItem);
let bidResponse = [];
const response = serverResponse.body;
if (response && Array.isArray(response) && response.length > 0) {
for (let i = 0; i < response.length; i++) {
if (response[i].cpm > 0) {
if (response[i].mediaType && response[i].mediaType === 'video') {
response[i].vastXml = response[i].ad;
}
bidResponse.push(response[i]);
}
}
} catch (e) {
utils.logMessage(e);
};
return response;
}
return bidResponse;
},

getUserSyncs: (syncOptions) => {
if (syncOptions.iframeEnabled) {
return [{
type: 'iframe',
url: 'https://console.brightmountainmedia.com:8443/cookieSync'
url: SYNC_URL
}];
}
},
Expand Down
107 changes: 92 additions & 15 deletions modules/brightMountainMediaBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,102 @@ Maintainer: dev@brightmountainmedia.com

Connects to Bright Mountain Media exchange for bids.

Bright Mountain Media bid adapter currently supports Banner.
Bright Mountain Media bid adapter currently supports Banner and Video.

# Sample Ad Unit: For Publishers

## Sample Banner only Ad Unit

# Test Parameters
```
var adUnits = [
code: 'placementid_0',
mediaTypes: {
var adUnits = [
{
code: 'postbid_iframe',
mediaTypes: {
banner: {
sizes: [[300, 250]]
sizes: [[300, 250]]
}
},
bids: [
},
bids: [
{
bidder: 'bmtm',
params: {
placement_id: '5f21784949be82079d08c',
traffic: 'banner'
}
"bidder": "bmtm",
"params": {
"placement_id": 1
}
}
]
]
}
];
```
```

## Sample Video only Ad Unit: Outstream

```
var adUnits = [
{
code: 'postbid_iframe_video',
mediaTypes: {
video: {
playerSize: [[640, 480]],
context: 'outstream'
... // Additional ORTB video params
}
},
bids: [
{
bidder: "bmtm",
params: {
placement_id: 1
}
}
],
renderer: {
url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js',
render: function (bid) {
adResponse = {
ad: {
video: {
content: bid.vastXml,
player_height: bid.height,
player_width: bid.width
}
}
}
// push to render queue because ANOutstreamVideo may not be loaded yet.
bid.renderer.push(() => {
ANOutstreamVideo.renderAd({
targetId: bid.adUnitCode,
adResponse: adResponse
});
});
}
}
}
];
```

## Sample Video only Ad Unit: Instream

```
var adUnits = [
{
code: 'postbid_iframe_video',
mediaTypes: {
video: {
playerSize: [[640, 480]],
context: 'instream'
... // Additional ORTB video params
},
},
bids: [
{
bidder: "bmtm",
params: {
placement_id: 1
}
}
]
}
];
```
Loading

0 comments on commit e04ed88

Please sign in to comment.