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

DMX Fix video bug #5910

Merged
merged 44 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5711b57
adding DMX
Nov 17, 2016
ad33b56
Update districtm_spec.js
stevealliance Nov 30, 2016
fbd31ff
Update districtmDMX.js
stevealliance Nov 30, 2016
fe94313
updating repo fork in github
Oct 26, 2017
6054a04
Merge pull request #1 from prebid/master
stevealliance Jun 22, 2018
0384c75
adding all districtm needed file
Jun 22, 2018
d2f5de2
remove legacy file
Jun 22, 2018
d83db11
remove typo || 0 in the test method
Jun 22, 2018
a7d0a85
force default to return a valid width and height
Jun 27, 2018
d73cac7
update unit test code for failing test
Jun 27, 2018
d5b2617
changed class for an object
Jul 9, 2018
c80b0df
remove package-lock.json
Jul 9, 2018
afa5d3e
change file name for dmx adapter
Jul 11, 2018
4e93b06
remove package-lock.json
Jul 11, 2018
afdbd9e
update fork
Jul 31, 2018
5cc3181
renamed files
Jul 31, 2018
e3e864d
restaure package-lock.json
Jul 31, 2018
6af65f9
update to last package-lock state
Jul 31, 2018
4da8f60
Merge branch 'master' of https://github.com/prebid/Prebid.js
Aug 14, 2018
15954f2
Merge branch 'master' of https://github.com/prebid/Prebid.js
Aug 27, 2018
af73067
update gdpr user consent
Aug 27, 2018
c2e2f5f
fix sizes issue
Aug 27, 2018
0f83dab
Documentation updates
lsv1 Aug 29, 2018
787e1e0
Merge pull request #3 from lsv1/patch-1
stevealliance Aug 29, 2018
a63b92b
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 4, 2018
3dfb282
update file name and update unit testing import file location
Sep 4, 2018
5786375
Merge branch 'master' of https://github.com/stevealliance/Prebid.js
Sep 4, 2018
60f693e
update remote to reflect forked repo
Jun 17, 2019
1f03347
Mdding all file to localserge branch 'master' of github.com:prebid/Pr…
Oct 23, 2019
a3d85d7
current machine state
Oct 23, 2019
a327932
lint correction
Oct 23, 2019
1706bd1
remove variable assigment duplicate
Oct 23, 2019
9492b32
adding change to dmx
steve-a-districtm Nov 6, 2019
5660324
Merge pull request #4 from prebid/master
stevealliance Dec 9, 2019
f006e29
adding CCPA support for DMX
steve-a-districtm Dec 9, 2019
c6b689b
adding test for ccpa and gdpr
steve-a-districtm Dec 13, 2019
c57fc3b
districtm dmx adding deal id field
stevealliance Jan 21, 2020
f31582b
idsync support ccpa & gdpr
steve-a-districtm Feb 17, 2020
774dd31
Merge pull request #5 from prebid/master
stevealliance Mar 18, 2020
1487845
merge remote-tracking branch 'upstream/master'
steve-a-districtm Apr 23, 2020
3836393
Merge remote-tracking branch 'upstream/master'
stevealliance Aug 4, 2020
69a4310
Merge branch 'master' of https://github.com/prebid/Prebid.js
stevealliance Oct 6, 2020
c930a32
Merge branch 'master' of https://github.com/prebid/Prebid.js
stevealliance Oct 29, 2020
8e1b6b5
fix error on vast response that failed
stevealliance Oct 29, 2020
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
72 changes: 28 additions & 44 deletions modules/districtmDMXBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export const spec = {
nBid.requestId = nBid.impid;
nBid.width = nBid.w || width;
nBid.height = nBid.h || height;
nBid.mediaType = bid.mediaTypes && bid.mediaTypes.video ? 'video' : null;
nBid.mediaType = bid.mediaTypes && bid.mediaTypes.video ? 'video' : 'banner';
if (nBid.mediaType) {
nBid.vastXml = cleanVast(nBid.adm);
nBid.vastXml = cleanVast(nBid.adm, nBid.nurl);
}
if (nBid.dealid) {
nBid.dealId = nBid.dealid;
Expand Down Expand Up @@ -154,19 +154,16 @@ export const spec = {
if (dmx.mediaTypes && dmx.mediaTypes.video) {
obj.video = {
topframe: 1,
skip: dmx.mediaTypes.video.skippable || 0,
skip: dmx.mediaTypes.video.skip || 0,
linearity: dmx.mediaTypes.video.linearity || 1,
minduration: dmx.mediaTypes.video.minduration || 5,
maxduration: dmx.mediaTypes.video.maxduration || 60,
playbackmethod: getPlaybackmethod(dmx.mediaTypes.video.playback_method),
playbackmethod: dmx.mediaTypes.video.playbackmethod || [2],
api: getApi(dmx.mediaTypes.video),
mimes: dmx.mediaTypes.video.mimes || ['video/mp4'],
protocols: getProtocols(dmx.mediaTypes.video),
w: dmx.mediaTypes.video.playerSize[0][0],
h: dmx.mediaTypes.video.playerSize[0][1],
format: dmx.mediaTypes.video.playerSize.map(s => {
return {w: s[0], h: s[1]};
}).filter(obj => typeof obj.w === 'number' && typeof obj.h === 'number')
w: dmx.mediaTypes.video.playerSize[0][0]
};
} else {
obj.banner = {
Expand Down Expand Up @@ -380,20 +377,10 @@ export function bindUserId(eids, value, source, atype) {
}
}

export function getApi({protocols}) {
export function getApi({api}) {
let defaultValue = [2];
let listProtocols = [
{key: 'VPAID_1_0', value: 1},
{key: 'VPAID_2_0', value: 2},
{key: 'MRAID_1', value: 3},
{key: 'ORMMA', value: 4},
{key: 'MRAID_2', value: 5},
{key: 'MRAID_3', value: 6},
];
if (protocols) {
return listProtocols.filter(p => {
return protocols.indexOf(p.key) !== -1;
}).map(p => p.value)
if (api && Array.isArray(api) && api.length > 0) {
return api
} else {
return defaultValue;
}
Expand All @@ -409,35 +396,32 @@ export function getPlaybackmethod(playback) {

export function getProtocols({protocols}) {
let defaultValue = [2, 3, 5, 6, 7, 8];
let listProtocols = [
{key: 'VAST_1_0', value: 1},
{key: 'VAST_2_0', value: 2},
{key: 'VAST_3_0', value: 3},
{key: 'VAST_1_0_WRAPPER', value: 4},
{key: 'VAST_2_0_WRAPPER', value: 5},
{key: 'VAST_3_0_WRAPPER', value: 6},
{key: 'VAST_4_0', value: 7},
{key: 'VAST_4_0_WRAPPER', value: 8}
];
if (protocols) {
return listProtocols.filter(p => {
return protocols.indexOf(p.key) !== -1
}).map(p => p.value);
if (protocols && Array.isArray(protocols) && protocols.length > 0) {
return protocols;
} else {
return defaultValue;
}
}

export function cleanVast(str) {
const toberemove = /<img\s[^>]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/
const [img, url] = str.match(toberemove)
str = str.replace(toberemove, '')
if (img) {
if (url) {
const insrt = `<Impression><![CDATA[${url}]]></Impression>`
str = str.replace('</Impression>', `</Impression>${insrt}`)
export function cleanVast(str, nurl) {
try {
const toberemove = /<img\s[^>]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/
const [img, url] = str.match(toberemove)
str = str.replace(toberemove, '')
if (img) {
if (url) {
const insrt = `<Impression><![CDATA[${url}]]></Impression>`
str = str.replace('</Impression>', `</Impression>${insrt}`)
}
}
return str;
} catch (e) {
if(!nurl) {
return str
}
const insrt = `<Impression><![CDATA[${nurl}]]></Impression>`
str = str.replace('</Impression>', `</Impression>${insrt}`)
return str
}
return str;
}
registerBidder(spec);
7 changes: 4 additions & 3 deletions test/spec/modules/districtmDmxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const bidRequestVideo = [{
}
},
'mediaTypes': { video: {context: 'instream', // or 'outstream'
playerSize: [[640, 480]]} },
playerSize: [[640, 480]]} },
'adUnitCode': 'div-gpt-ad-12345678-1',
'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2',
'sizes': [
Expand Down Expand Up @@ -616,7 +616,7 @@ describe('DistrictM Adaptor', function () {
})
describe('Test getApi function', function() {
const data = {
protocols: ['VPAID_1_0']
api: [1]
}
it('Will return 1 for vpaid version 1', function() {
expect(getApi(data)[0]).to.be.equal(1)
Expand Down Expand Up @@ -646,7 +646,7 @@ describe('DistrictM Adaptor', function () {

describe('Test getProtocols function', function() {
it('getProtocols will return 3', function() {
expect(getProtocols({protocols: ['VAST_3_0']})[0]).to.be.equal(3)
expect(getProtocols({protocols: [3]})[0]).to.be.equal(3)
})
it('getProtocols will return 6', function() {
expect(_.isEqual(getProtocols({}), [2, 3, 5, 6, 7, 8])).to.be.equal(true)
Expand Down Expand Up @@ -811,3 +811,4 @@ describe('DistrictM Adaptor', function () {
});
});
});