Added dynamic affiliate URLs and video player restrictions.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import format from 'template-format';
|
||||
|
||||
function getWatchUrl(scene) {
|
||||
if (scene.url) {
|
||||
return scene.url;
|
||||
@@ -29,6 +31,16 @@ export function getAffiliateSceneUrl(scene) {
|
||||
? scene.affiliate.parameters.replaceScene.url
|
||||
: scene.affiliate.url;
|
||||
|
||||
if (scene.affiliate.parameters.dynamicScene) {
|
||||
const scenePath = new URL(watchUrl).pathname;
|
||||
|
||||
return format(scene.affiliate.parameters.dynamicScene, {
|
||||
scenePath: scene.affiliate.parameters.prefixSlash
|
||||
? scenePath
|
||||
: scenePath.replace(/^\//, ''),
|
||||
});
|
||||
}
|
||||
|
||||
if (affiliateUrl?.includes('/track')
|
||||
&& scene.affiliate.parameters.scene !== false
|
||||
&& (!scene.channel.isIndependent || scene.channel.id === scene.affiliate.entityId)) { // standard NATS redirect
|
||||
@@ -58,8 +70,6 @@ export function getAffiliateEntityUrl(entity) {
|
||||
? entity.affiliate.parameters.replaceEntity.url
|
||||
: entity.affiliate.url;
|
||||
|
||||
console.log(entity.affiliate, entity.url);
|
||||
|
||||
if (entity.id === entity.affiliate.entityId) {
|
||||
return affiliateUrl;
|
||||
}
|
||||
@@ -73,6 +83,16 @@ export function getAffiliateEntityUrl(entity) {
|
||||
return entity.url;
|
||||
}
|
||||
|
||||
if (entity.affiliate.parameters.dynamicEntity) {
|
||||
const entityPath = new URL(entity.url).pathname;
|
||||
|
||||
return format(entity.affiliate.parameters.dynamicEntity, {
|
||||
entityPath: entity.affiliate.parameters.prefixSlash
|
||||
? entityPath
|
||||
: entityPath.replace(/^\//, ''),
|
||||
});
|
||||
}
|
||||
|
||||
if (affiliateUrl?.includes('/track')
|
||||
&& entity.affiliate.parameters.channel !== false) {
|
||||
const { pathname, search } = new URL(entity.url);
|
||||
|
||||
Reference in New Issue
Block a user