Skip to content

Commit

Permalink
Merge pull request #43 from SRGSSR/develop
Browse files Browse the repository at this point in the history
Update ParsePlayUrl javascript version to v25
  • Loading branch information
pyby authored May 17, 2020
2 parents a549e45 + 3120717 commit ac7ba2d
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>ch.srgssr</groupId>
<artifactId>playfff</artifactId>
<version>21</version>
<version>22</version>
<packaging>jar</packaging>

<name>pfff</name>
Expand Down
49 changes: 36 additions & 13 deletions src/main/resources/deeplink/v1/parsePlayUrl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// parsePlayUrl

var parsePlayUrlVersion = 24;
var parsePlayUrlVersion = 25;
var parsePlayUrlBuild = "mmf";

if(! console) {
Expand All @@ -17,22 +17,22 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
// Get BU
var bu = null;
switch (true) {
case hostname.endsWith("tp.srgssr.ch") || hostname.endsWith("player.rts.ch") || hostname.endsWith("player.rsi.ch") || hostname.endsWith("player.rtr.ch") || hostname.endsWith("player.swissinfo.ch") || hostname.endsWith("player.srf.ch"):
bu = "tp";
case hostname.endsWith("tp.srgssr.ch") || hostname.endsWith("player.rts.ch") || hostname.endsWith("player.rsi.ch") || hostname.endsWith("player.rtr.ch") || hostname.endsWith("player.swissinfo.ch") || hostname.endsWith("player.srf.ch") || (hostname.includes("srgssr") && pathname.startsWith("/srgletterbox-web")):
bu = "lb";
break;
case hostname.includes("rts.ch") || hostname.includes("srgplayer-rts") || (hostname.includes("play-mmf") && pathname.startsWith("/rts/")) || (hostname.includes("play-web") && pathname.startsWith("/rts/")):
case (hostname.includes("rts.ch") && !hostname.includes("play-staging")) || hostname.includes("srgplayer-rts") || (hostname.includes("play-mmf") && pathname.startsWith("/rts/")) || ((hostname.includes("play-web") || hostname.includes("play-staging")) && pathname.startsWith("/rts/")):
bu = "rts";
break;
case hostname.includes("rsi.ch") || hostname.includes("srgplayer-rsi") || (hostname.includes("play-mmf") && pathname.startsWith("/rsi/")) || (hostname.includes("play-web") && pathname.startsWith("/rsi/")):
case hostname.includes("rsi.ch") || hostname.includes("srgplayer-rsi") || (hostname.includes("play-mmf") && pathname.startsWith("/rsi/")) || ((hostname.includes("play-web") || hostname.includes("play-staging")) && pathname.startsWith("/rsi/")):
bu = "rsi";
break;
case hostname.includes("rtr.ch") || hostname.includes("srgplayer-rtr") || (hostname.includes("play-mmf") && pathname.startsWith("/rtr/")) || (hostname.includes("play-web") && pathname.startsWith("/rtr/")):
case hostname.includes("rtr.ch") || hostname.includes("srgplayer-rtr") || (hostname.includes("play-mmf") && pathname.startsWith("/rtr/")) || ((hostname.includes("play-web") || hostname.includes("play-staging")) && pathname.startsWith("/rtr/")):
bu = "rtr";
break;
case hostname.includes("swissinfo.ch") || hostname.includes("srgplayer-swi") || (hostname.includes("play-mmf") && pathname.startsWith("/swi/")) || (hostname.includes("play-web") && pathname.startsWith("/swi/")):
case hostname.includes("swissinfo.ch") || hostname.includes("srgplayer-swi") || (hostname.includes("play-mmf") && pathname.startsWith("/swi/")) || ((hostname.includes("play-web") || hostname.includes("play-staging")) && pathname.startsWith("/swi/")):
bu = "swi";
break;
case hostname.includes("srf.ch") || hostname.includes("srgplayer-srf") || (hostname.includes("play-mmf") && pathname.startsWith("/srf/")) || (hostname.includes("play-web") && pathname.startsWith("/srf/")):
case hostname.includes("srf.ch") || hostname.includes("srgplayer-srf") || (hostname.includes("play-mmf") && pathname.startsWith("/srf/")) || ((hostname.includes("play-web") || hostname.includes("play-staging")) && pathname.startsWith("/srf/")):
bu = "srf";
break;
case hostname.includes("play-mmf") && pathname.startsWith("/mmf/"):
Expand All @@ -57,11 +57,11 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
* Ex: https://tp.srgssr.ch/p/rts/default?urn=urn:rts:video:6735513
* Ex: https://player.rts.ch/p/rts/default?urn=urn:rts:video:6735513&start=60
*/
if (bu == "tp") {
if (bu == "lb") {
if (pathname.startsWith("/p/")) {
var mediaURN = queryParams["urn"];
if (mediaURN) {
var redirectBu = "tp";
var redirectBu = "lb";
switch (true) {
case pathname.startsWith("/p/srf/"):
redirectBu = "srf";
Expand All @@ -83,6 +83,13 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
return openMediaURN(server, redirectBu, mediaURN, startTime);
}
}
else if (pathname.startsWith("/srgletterbox-web")) {
var mediaURN = queryParams["urn"];
if (mediaURN) {
var startTime = queryParams["pendingSeek"];
return openMediaURN(server, "lb", mediaURN, startTime);
}
}
}

/**
Expand Down Expand Up @@ -130,7 +137,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
pathname = pathname.substring(4);
}

if (hostname.includes("play-web")) {
if (hostname.includes("play-web") || hostname.includes("play-staging")) {
pathname = pathname.substring(4);
pathname = pathname.replace("/stage/play", "/play");
pathname = pathname.replace("/test/play", "/play");
Expand Down Expand Up @@ -760,7 +767,7 @@ function schemeForBu(bu) {
return "playswi";
break;
case "mmf":
case "tp":
case "lb":
return "letterbox";
break;
default:
Expand Down Expand Up @@ -792,13 +799,29 @@ function serverForUrl(hostname, pathname, queryParams) {
}
}
}
else if (hostname.includes("play-web")) {
else if (hostname.includes("play-web") || hostname.includes("play-staging")) {
if (pathname.includes("/stage/play")) {
server = "stage";
}
else if (pathname.includes("/test/play")) {
server = "test";
}
}
else if (pathname.startsWith("/srgletterbox-web")) {
var serverParam = queryParams["env"];
switch (serverParam) {
case "stage":
server = "stage";
break;
case "test":
server = "test";
break;
case "play mmf":
case "play+mmf":
case "mmf":
server = "play mmf";
break;
}
}
return server;
}
49 changes: 36 additions & 13 deletions src/main/resources/deeplink/v2/parsePlayUrl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// parsePlayUrl

var parsePlayUrlVersion = 24;
var parsePlayUrlVersion = 25;
var parsePlayUrlBuild = "mmf";

if(! console) {
Expand Down Expand Up @@ -29,11 +29,11 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
* Ex: https://tp.srgssr.ch/p/rts/default?urn=urn:rts:video:6735513
* Ex: https://player.rts.ch/p/rts/default?urn=urn:rts:video:6735513&start=60
*/
if (bu == "tp") {
if (bu == "lb") {
if (pathname.startsWith("/p/")) {
var mediaURN = queryParams["urn"];
if (mediaURN) {
var redirectBu = "tp";
var redirectBu = "lb";
switch (true) {
case pathname.startsWith("/p/srf/"):
redirectBu = "srf";
Expand All @@ -55,6 +55,13 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
return openMediaURN(server, redirectBu, mediaURN, startTime);
}
}
else if (pathname.startsWith("/srgletterbox-web")) {
var mediaURN = queryParams["urn"];
if (mediaURN) {
var startTime = queryParams["pendingSeek"];
return openMediaURN(server, "lb", mediaURN, startTime);
}
}
}

/**
Expand Down Expand Up @@ -102,7 +109,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
pathname = pathname.substring(4);
}

if (hostname.includes("play-web")) {
if (hostname.includes("play-web") || hostname.includes("play-staging")) {
pathname = pathname.substring(4);
pathname = pathname.replace("/stage/play", "/play");
pathname = pathname.replace("/test/play", "/play");
Expand Down Expand Up @@ -778,7 +785,7 @@ function schemeForBu(bu) {
return "playswi";
break;
case "mmf":
case "tp":
case "lb":
return "letterbox";
break;
default:
Expand Down Expand Up @@ -810,30 +817,46 @@ function serverForUrl(hostname, pathname, queryParams) {
}
}
}
else if (hostname.includes("play-web")) {
else if (hostname.includes("play-web") || hostname.includes("play-staging")) {
if (pathname.includes("/stage/play")) {
server = "stage";
}
else if (pathname.includes("/test/play")) {
server = "test";
}
}
else if (pathname.startsWith("/srgletterbox-web")) {
var serverParam = queryParams["env"];
switch (serverParam) {
case "stage":
server = "stage";
break;
case "test":
server = "test";
break;
case "play mmf":
case "play+mmf":
case "mmf":
server = "play mmf";
break;
}
}
return server;
}

function getBuFromHostname(hostname, pathname) {
switch (true) {
case hostname.endsWith("tp.srgssr.ch") || hostname.endsWith("player.rts.ch") || hostname.endsWith("player.rsi.ch") || hostname.endsWith("player.rtr.ch") || hostname.endsWith("player.swissinfo.ch") || hostname.endsWith("player.srf.ch"):
return "tp";
case hostname.includes("rts.ch") || hostname.includes("srgplayer-rts") || (hostname.includes("play-mmf") && pathname.startsWith("/rts/")) || (hostname.includes("play-web") && pathname.startsWith("/rts/")):
case hostname.endsWith("tp.srgssr.ch") || hostname.endsWith("player.rts.ch") || hostname.endsWith("player.rsi.ch") || hostname.endsWith("player.rtr.ch") || hostname.endsWith("player.swissinfo.ch") || hostname.endsWith("player.srf.ch") || (hostname.includes("srgssr") && pathname.startsWith("/srgletterbox-web")):
return "lb";
case (hostname.includes("rts.ch") && !hostname.includes("play-staging")) || hostname.includes("srgplayer-rts") || (hostname.includes("play-mmf") && pathname.startsWith("/rts/")) || ((hostname.includes("play-web") || hostname.includes("play-staging")) && pathname.startsWith("/rts/")):
return "rts";
case hostname.includes("rsi.ch") || hostname.includes("srgplayer-rsi") || (hostname.includes("play-mmf") && pathname.startsWith("/rsi/")) || (hostname.includes("play-web") && pathname.startsWith("/rsi/")):
case hostname.includes("rsi.ch") || hostname.includes("srgplayer-rsi") || (hostname.includes("play-mmf") && pathname.startsWith("/rsi/")) || ((hostname.includes("play-web") || hostname.includes("play-staging")) && pathname.startsWith("/rsi/")):
return "rsi";
case hostname.includes("rtr.ch") || hostname.includes("srgplayer-rtr") || (hostname.includes("play-mmf") && pathname.startsWith("/rtr/")) || (hostname.includes("play-web") && pathname.startsWith("/rtr/")):
case hostname.includes("rtr.ch") || hostname.includes("srgplayer-rtr") || (hostname.includes("play-mmf") && pathname.startsWith("/rtr/")) || ((hostname.includes("play-web") || hostname.includes("play-staging")) && pathname.startsWith("/rtr/")):
return "rtr";
case hostname.includes("swissinfo.ch") || hostname.includes("srgplayer-swi") || (hostname.includes("play-mmf") && pathname.startsWith("/swi/")) || (hostname.includes("play-web") && pathname.startsWith("/swi/")):
case hostname.includes("swissinfo.ch") || hostname.includes("srgplayer-swi") || (hostname.includes("play-mmf") && pathname.startsWith("/swi/")) || ((hostname.includes("play-web") || hostname.includes("play-staging")) && pathname.startsWith("/swi/")):
return "swi";
case hostname.includes("srf.ch") || hostname.includes("srgplayer-srf") || (hostname.includes("play-mmf") && pathname.startsWith("/srf/")) || (hostname.includes("play-web") && pathname.startsWith("/srf/")):
case hostname.includes("srf.ch") || hostname.includes("srgplayer-srf") || (hostname.includes("play-mmf") && pathname.startsWith("/srf/")) || ((hostname.includes("play-web") || hostname.includes("play-staging")) && pathname.startsWith("/srf/")):
return "srf";
case hostname.includes("play-mmf") && pathname.startsWith("/mmf/"):
return "mmf";
Expand Down

0 comments on commit ac7ba2d

Please sign in to comment.