Skip to content

Commit

Permalink
Merge pull request #81 from prebid/dshore/video_max_duration
Browse files Browse the repository at this point in the history
Add support for video max duration w/ default of 30 seconds (#80)
  • Loading branch information
dshore authored Dec 1, 2021
2 parents 95dd6e9 + 65edbc2 commit b593cfb
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 7 deletions.
2 changes: 1 addition & 1 deletion line_item_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__version__ = '0.2.3'

# For an official release, use dev_version = ''
dev_version = '1'
dev_version = '2'

version = __version__
if dev_version:
Expand Down
1 change: 1 addition & 0 deletions line_item_manager/conf.d/line_item_manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ creative: # at least one of the following types is required {video, banner}
- height: 240
width: 320
vast_xml_url: "https://prebid.adnxs.com/pbc/v1/cache?uuid=%%PATTERN:{{ hb_uuid }}%%"
# max_duration: 60000 # optional: defaults to 30000, see settings.yml
###############################################################################
# Orders (required)
# Allowed Templating Key Words: Bidder, Media, Order, Misc
Expand Down
1 change: 1 addition & 0 deletions line_item_manager/conf.d/line_item_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ creativePlaceholders:
{% if li.media_type == 'video' %}
environmentType: "VIDEO_PLAYER"
companionDeliveryOption: "OPTIONAL"
videoMaxDuration: {{ user_cfg.creative[li.media_type].max_duration }}
{% endif %}

{% if user_cfg.line_item.goal %}
Expand Down
5 changes: 5 additions & 0 deletions line_item_manager/conf.d/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ properties:
$ref: "#/definitions/sizeArray"
vast_xml_url:
type: "string"
max_duration:
type: "#/definitions/positiveIntegerType"
required:
- "sizes"
- "vast_xml_url"
Expand Down Expand Up @@ -213,6 +215,9 @@ definitions:
- 'auto'
- 'dense'
- 'custom'
positiveIntegerType:
type: "integer"
minimum: 1
priorityType:
type: "integer"
minimum: 1
Expand Down
1 change: 1 addition & 0 deletions line_item_manager/conf.d/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ prebid:
height: 1
width: 1
video:
max_duration: 30000 # milliseconds
duration: 1000 # milliseconds
price_granularity:
low:
Expand Down
6 changes: 6 additions & 0 deletions line_item_manager/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ def pre_create(self) -> None:
fmt = self.app['mgr']['date_fmt']
vcpm = self.user['rate'].get('vcpm')

if self.user['creative'].get('video'):
_ = self.user['creative']['video'].setdefault(
'max_duration',
self.app['prebid']['creative']['video']['max_duration']
)

if vcpm and not is_standard:
raise ValueError("Specifying 'vcpm' requires using line item type 'standard'")

Expand Down
131 changes: 131 additions & 0 deletions tests/resources/cfg_video_max_duration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# line_item_manager configuration
###############################################################################
# Templating uses jinja2 rendering (see https://palletsprojects.com/p/jinja/)
# The following key word types are supported:
# Bidder:
# bidder_code = bidder-code
# bidder_name = bidder-name
# hb_<keystr> = hb_<keystr>_<bidder-code> (20 char limit)
# CPM:
# cpm = line item rate as cost-per-thousand impressions
# Media:
# media_type = video or banner based on creative configuration below
# Misc:
# time = current UTC time represented as "%m/%d/%Y %H:%M:%S"
# Order:
# cpm_max = order maximum cpm
# cpm_min = order minimum cpm
#
# See https://docs.prebid.org/dev-docs/bidder-data.csv for referencing bidder
# names and codes.
###############################################################################
# Publisher (optional)
# This can be specified at run-time like this:
# --network-code <code>
# --network-name <name>
#
publisher:
network_code: 1234
network_name: "Video Publisher"
###############################################################################
# Advertiser (required)
# Allowed Templating Key Words: Bidder
###############################################################################
advertiser:
name: "Prebid"
###############################################################################
# Creatives (required)
# Allowed Templating Key Words: Bidder, Media, Misc
###############################################################################
creative: # at least one of the following types is required {video, banner}
name: "Prebid {{ bidder_name }}-{{ media_type }}"
video:
sizes: # list
- height: 480
width: 640
- height: 240
width: 320
vast_xml_url: "https://prebid.adnxs.com/pbc/v1/cache?uuid=%%PATTERN:{{ hb_cache_id }}%%"
max_duration: 60000
banner:
sizes: # list
- height: 480
width: 640
snippet: |
<script src = "https://..."></script>
<script>
...
</script>
# safe_frame: False (optional: defaults to True)
###############################################################################
# Orders (required)
# Allowed Templating Key Words: Bidder, Media, Order, Misc
###############################################################################
order:
name: "Prebid-{{ bidder_name }}-{{ media_type }}-{{ time }} {{ cpm_min }}-{{ cpm_max }}"
appliedTeamIds: # list (optional)
- 12345678
- 23456789
###############################################################################
# Line Items (required)
# Allowed Templating Key Words: Bidder, Media, CPM, Misc
#
# Supported Types: price_priority, standard
# datetimes use: "%m/%d/%y %H:%M" (ex. 11/17/20 21:28)
# - default timezone is UTC
# timezones: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
###############################################################################
line_item:
name: "Prebid-{{ bidder_name }}-{{ media_type }}-{{ time }} @ {{ cpm }}"
item_type: "price_priority"
# Optional
# start_datetime: "11/17/20 21:28"
# end_datetime: "12/17/20 21:28"
# timezone: "UTC"
###############################################################################
# Bidder Targeting Key Override Map (optional):
# If provided override the default bidder_targeting_key and use these
# targeting keys specified by bidder_code.
#
# bidder_key_map:
# <bidder_code_1>: <bidder_targeting_key_1>
# <bidder_code_2>: <bidder_targeting_key_2>
###############################################################################
# Targeting (required)
# Allowed Templating Key Words: None
#
# Note: A Key-Value of 'bidder_targeting_key' with all CPM values is created
# by default.
###############################################################################
targeting:
custom: # list (optional)
- name: "country"
values:
- "US"
- "CAN"
# One of the below either placemane_names or ad_unit_names is required
placement_names: # list of names
- "placement name 1"
- "placement name 2"
ad_unit_names: # list of names
- "ad unit name 1"
- "ad unit name 2"
###############################################################################
# Rate (required)
# NOTE: granularity in Prebid.js config must align with this granularity
# Allowed Templating Key Words: None
###############################################################################
rate:
currency: "USD" # required
granularity:
type: "custom"
custom:
- min: 0.10
max: 0.30
interval: 0.10
- min: 0.30
max: 1.30
interval: 0.50
# optional properties
# vcpm: 100000 # viewable impressions will be enabled

2 changes: 2 additions & 0 deletions tests/resources/video_expected.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1250000
Expand Down Expand Up @@ -47,6 +48,7 @@
targetedRequestPlatforms: VIDEO_PLAYER
unlimitedEndDateTime: true
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1500000
Expand Down
6 changes: 4 additions & 2 deletions tests/resources/video_expected_dry_run.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1250000
Expand All @@ -12,7 +13,7 @@
width: 320
creativeRotationType: EVEN
environmentType: VIDEO_PLAYER
id: 9999827713
id: 9999899367
lineItemType: PRICE_PRIORITY
name: Prebid-InteractiveOffers-video-01/02/2020-08:09:10 @ 1.25
orderId: 6001
Expand Down Expand Up @@ -47,6 +48,7 @@
targetedRequestPlatforms: VIDEO_PLAYER
unlimitedEndDateTime: true
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1500000
Expand All @@ -60,7 +62,7 @@
width: 320
creativeRotationType: EVEN
environmentType: VIDEO_PLAYER
id: 9999224642
id: 9999960551
lineItemType: PRICE_PRIORITY
name: Prebid-InteractiveOffers-video-01/02/2020-08:09:10 @ 1.50
orderId: 6001
Expand Down
2 changes: 2 additions & 0 deletions tests/resources/video_expected_no_targeting.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1250000
Expand Down Expand Up @@ -38,6 +39,7 @@
targetedRequestPlatforms: VIDEO_PLAYER
unlimitedEndDateTime: true
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1500000
Expand Down
2 changes: 2 additions & 0 deletions tests/resources/video_expected_one_custom_value.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1250000
Expand Down Expand Up @@ -46,6 +47,7 @@
targetedRequestPlatforms: VIDEO_PLAYER
unlimitedEndDateTime: true
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1500000
Expand Down
2 changes: 2 additions & 0 deletions tests/resources/video_expected_test_run.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1250000
Expand Down Expand Up @@ -47,6 +48,7 @@
targetedRequestPlatforms: VIDEO_PLAYER
unlimitedEndDateTime: true
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1500000
Expand Down
2 changes: 2 additions & 0 deletions tests/resources/video_single_order_expected.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1250000
Expand Down Expand Up @@ -47,6 +48,7 @@
targetedRequestPlatforms: VIDEO_PLAYER
unlimitedEndDateTime: true
- companionDeliveryOption: OPTIONAL
videoMaxDuration: 30000
costPerUnit:
currencyCode: USD
microAmount: 1500000
Expand Down
4 changes: 4 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ def test_custom_targeting_is_not_reportableType(cli_config):
assert config.custom_targeting_key_values() == \
[{'name': 'country', 'values': {'CAN', 'US'}, 'operator': 'IS_NOT', 'reportableType': 'ON'}]
assert config.targeting_bidder_key_config() == {'reportableType': 'ON'}

@pytest.mark.command(f'create tests/resources/cfg_video_max_duration.yml -k {KEY_FILE} -b ix -q')
def test_video_max_duration(cli_config):
assert config.user['creative']['video']['max_duration'] == 60000
8 changes: 4 additions & 4 deletions tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
CREATIVE_1 = int('9999' + str(num_hash(['CreativeVideo', str(VIDEO_CREATIVE)])))

DRY_RUN_EXPECTED_LICA = \
[[{'lineItemId': 9999827713, 'creativeId': CREATIVE_0, 'id': 9999534789},
{'lineItemId': 9999827713, 'creativeId': CREATIVE_1, 'id': 9999840404},
{'lineItemId': 9999224642, 'creativeId': CREATIVE_0, 'id': 9999813993},
{'lineItemId': 9999224642, 'creativeId': CREATIVE_1, 'id': 9999825404}]]
[[{'lineItemId': 9999899367, 'creativeId': CREATIVE_0, 'id': 9999164843},
{'lineItemId': 9999899367, 'creativeId': CREATIVE_1, 'id': 9999863541},
{'lineItemId': 9999960551, 'creativeId': CREATIVE_0, 'id': 9999333772},
{'lineItemId': 9999960551, 'creativeId': CREATIVE_1, 'id': 9999408383}]]

BANNER_EXPECTED_LICA = \
[[{'lineItemId': 8001, 'creativeId': 4001, 'sizes': [{'height': 20, 'width': 1000}], 'id': 9001},
Expand Down

0 comments on commit b593cfb

Please sign in to comment.