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

Dailymotion Bid Adaptor: add support for livestream and app #20

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 16 additions & 8 deletions modules/dailymotionBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ function getVideoMetadata(bidRequest, bidderRequest) {
title: videoParams.title || deepAccess(contentObj, 'title', ''),
topics: videoParams.topics || '',
xid: videoParams.xid || '',
livestream: typeof videoParams.livestream === 'number'
? !!videoParams.livestream
: !!deepAccess(contentObj, 'livestream', 0),
};

return videoMetadata;
Expand Down Expand Up @@ -109,15 +112,15 @@ export const spec = {
data: {
bidder_request: {
gdprConsent: {
apiVersion: bidderRequest?.gdprConsent?.apiVersion || 1,
consentString: bidderRequest?.gdprConsent?.consentString || '',
apiVersion: deepAccess(bidderRequest, 'gdprConsent.apiVersion', 1),
consentString: deepAccess(bidderRequest, 'gdprConsent.consentString', ''),
// Cast boolean in any case (eg: if value is int) to ensure type
gdprApplies: !!bidderRequest?.gdprConsent?.gdprApplies,
gdprApplies: !!deepAccess(bidderRequest, 'gdprConsent.gdprApplies'),
},
refererInfo: {
page: bidderRequest?.refererInfo?.page || '',
page: deepAccess(bidderRequest, 'refererInfo.page', ''),
},
uspConsent: bidderRequest?.uspConsent || '',
uspConsent: deepAccess(bidderRequest, 'uspConsent', ''),
gppConsent: {
gppString: deepAccess(bidderRequest, 'gppConsent.gppString') ||
deepAccess(bidderRequest, 'ortb2.regs.gpp', ''),
Expand All @@ -130,10 +133,15 @@ export const spec = {
},
// Cast boolean in any case (value should be 0 or 1) to ensure type
coppa: !!deepAccess(bidderRequest, 'ortb2.regs.coppa'),
// In app context, we need to retrieve additional informations
...(!deepAccess(bidderRequest, 'ortb2.site') && !!deepAccess(bidderRequest, 'ortb2.app') ? {
appBundle: deepAccess(bidderRequest, 'ortb2.app.bundle', ''),
appStoreUrl: deepAccess(bidderRequest, 'ortb2.app.storeurl', ''),
} : {}),
request: {
adUnitCode: bid.adUnitCode || '',
auctionId: bid.auctionId || '',
bidId: bid.bidId || '',
adUnitCode: deepAccess(bid, 'adUnitCode', ''),
auctionId: deepAccess(bid, 'auctionId', ''),
bidId: deepAccess(bid, 'bidId', ''),
mediaTypes: {
video: {
api: bid.mediaTypes?.[VIDEO]?.api || [],
Expand Down
3 changes: 3 additions & 0 deletions modules/dailymotionBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const adUnits = [
iabcat2: ['6', '17'],
id: '54321',
lang: 'FR',
livestream: 0,
private: false,
startdelay: 0,
tags: 'tag_1,tag_2,tag_3',
Expand All @@ -142,6 +143,7 @@ If a field exists in both places, it will be overridden by bids.params.video.
* `iabcat2` - List of IAB category IDs from the [2.0 taxonomy](https://github.com/InteractiveAdvertisingBureau/Taxonomies/blob/main/Content%20Taxonomies/Content%20Taxonomy%202.0.tsv) and above
* `id` - Video unique ID in host video infrastructure
* `lang` - ISO 639-1 code for main language used in the video
* `livestream` - 0 = not live, 1 = content is live
* `private` - True if video is not publicly available
* `tags` - Tags for the video, comma separated
* `title` - Video title
Expand All @@ -156,6 +158,7 @@ If you already specify [First-Party data](https://docs.prebid.org/features/first
| `ortb2.site.content.data` where `ext.segtax` is `5`, `6` or `7` | `iabcat2` |
| `ortb2.site.content.id` | `id` |
| `ortb2.site.content.language` | `lang` |
| `ortb2.site.content.livestream` | `livestream` |
| `ortb2.site.content.keywords` | `tags` |
| `ortb2.site.content.title` | `title` |

Expand Down
23 changes: 21 additions & 2 deletions test/spec/modules/dailymotionBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ describe('dailymotionBidAdapterTests', () => {
title: 'test video',
topics: 'topic_1, topic_2',
xid: 'x123456',
livestream: 1,
},
},
}];
Expand Down Expand Up @@ -173,7 +174,7 @@ describe('dailymotionBidAdapterTests', () => {
expect(reqData.request.bidId).to.eql(bidRequestData[0].bidId);
expect(reqData.request.mediaTypes.video.api).to.eql(bidRequestData[0].mediaTypes.video.api);
expect(reqData.request.mediaTypes.video.playerSize).to.eql(bidRequestData[0].mediaTypes.video.playerSize);
expect(reqData.request.mediaTypes.video.startDelay).to.eql(bidRequestData[0].mediaTypes.video.startdelay);
expect(reqData.request.mediaTypes.video.startdelay).to.eql(bidRequestData[0].mediaTypes.video.startdelay);
expect(reqData.video_metadata).to.eql({
description: bidRequestData[0].mediaTypes.video.description,
iabcat1: ['IAB-1'], // Taxonomy v2 or higher is excluded
Expand All @@ -187,6 +188,7 @@ describe('dailymotionBidAdapterTests', () => {
xid: bidRequestData[0].params.video.xid,
// Overriden through bidder params
duration: bidRequestData[0].params.video.duration,
livestream: !!bidRequestData[0].params.video.livestream,
});
});

Expand All @@ -197,13 +199,21 @@ describe('dailymotionBidAdapterTests', () => {
adUnitCode: 'preroll',
mediaTypes: {
video: {
playerSize: [[1280, 720]],
api: [2, 7],
description: 'this is a test video',
duration: 300,
iabcat2: ['6', '17'],
lang: 'ENG',
mimes: ['video/mp4'],
minduration: 5,
maxduration: 30,
protocols: [1, 2, 3, 4, 5, 6, 7, 8],
skip: 1,
skipafter: 5,
skipmin: 10,
startdelay: 0,
w: 1280,
h: 720,
},
},
sizes: [[1920, 1080]],
Expand All @@ -218,6 +228,7 @@ describe('dailymotionBidAdapterTests', () => {
title: 'test video',
topics: 'topic_1, topic_2',
xid: 'x123456',
livestream: 1,
},
},
}];
Expand All @@ -241,6 +252,8 @@ describe('dailymotionBidAdapterTests', () => {
coppa: 1,
},
app: {
bundle: 'app-bundle',
storeurl: 'https://play.google.com/store/apps/details?id=app-bundle',
content: {
data: [
{
Expand Down Expand Up @@ -276,6 +289,8 @@ describe('dailymotionBidAdapterTests', () => {
});
expect(reqData.config.api_key).to.eql(bidRequestData[0].params.apiKey);
expect(reqData.coppa).to.be.true;
expect(reqData.appBundle).to.eql(bidderRequestData.ortb2.app.bundle);
expect(reqData.appStoreUrl).to.eql(bidderRequestData.ortb2.app.storeurl);
expect(reqData.request.auctionId).to.eql(bidRequestData[0].auctionId);
expect(reqData.request.bidId).to.eql(bidRequestData[0].bidId);
expect(reqData.request.mediaTypes.video.api).to.eql(bidRequestData[0].mediaTypes.video.api);
Expand All @@ -302,6 +317,7 @@ describe('dailymotionBidAdapterTests', () => {
xid: bidRequestData[0].params.video.xid,
// Overriden through bidder params
duration: bidRequestData[0].params.video.duration,
livestream: !!bidRequestData[0].params.video.livestream,
});
});

Expand Down Expand Up @@ -353,6 +369,7 @@ describe('dailymotionBidAdapterTests', () => {
language: 'FR',
keywords: 'tag_1,tag_2,tag_3',
title: 'test video',
livestream: 1,
data: [
undefined, // Undefined to check proper handling of edge cases
{}, // Empty object to check proper handling of edge cases
Expand Down Expand Up @@ -437,6 +454,7 @@ describe('dailymotionBidAdapterTests', () => {
xid: bidRequestData[0].params.video.xid,
// Overriden through bidder params
duration: bidRequestData[0].params.video.duration,
livestream: !!bidderRequestData.ortb2.site.content.livestream,
});
});

Expand Down Expand Up @@ -509,6 +527,7 @@ describe('dailymotionBidAdapterTests', () => {
title: '',
topics: '',
xid: '',
livestream: false,
});
});

Expand Down