Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bright Mountain Media Bid Adapter: add video support and refactor #6607

Merged
merged 19 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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