Skip to content

Commit

Permalink
Merge pull request #41 from SRGSSR/develop
Browse files Browse the repository at this point in the history
Update ParsePlayUrl javascript version to v24
  • Loading branch information
pyby authored Apr 10, 2020
2 parents d72a7e1 + c01544b commit a549e45
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 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>20</version>
<version>21</version>
<packaging>jar</packaging>

<name>pfff</name>
Expand Down
29 changes: 22 additions & 7 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 = 23;
var parsePlayUrlVersion = 24;
var parsePlayUrlBuild = "mmf";

if(! console) {
Expand All @@ -20,19 +20,19 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
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";
break;
case hostname.includes("rts.ch") || hostname.includes("srgplayer-rts") || (hostname.includes("play-mmf") && pathname.startsWith("/rts/")):
case hostname.includes("rts.ch") || hostname.includes("srgplayer-rts") || (hostname.includes("play-mmf") && pathname.startsWith("/rts/")) || (hostname.includes("play-web") && pathname.startsWith("/rts/")):
bu = "rts";
break;
case hostname.includes("rsi.ch") || hostname.includes("srgplayer-rsi") || (hostname.includes("play-mmf") && pathname.startsWith("/rsi/")):
case hostname.includes("rsi.ch") || hostname.includes("srgplayer-rsi") || (hostname.includes("play-mmf") && pathname.startsWith("/rsi/")) || (hostname.includes("play-web") && pathname.startsWith("/rsi/")):
bu = "rsi";
break;
case hostname.includes("rtr.ch") || hostname.includes("srgplayer-rtr") || (hostname.includes("play-mmf") && pathname.startsWith("/rtr/")):
case hostname.includes("rtr.ch") || hostname.includes("srgplayer-rtr") || (hostname.includes("play-mmf") && pathname.startsWith("/rtr/")) || (hostname.includes("play-web") && pathname.startsWith("/rtr/")):
bu = "rtr";
break;
case hostname.includes("swissinfo.ch") || hostname.includes("srgplayer-swi") || (hostname.includes("play-mmf") && pathname.startsWith("/swi/")):
case hostname.includes("swissinfo.ch") || hostname.includes("srgplayer-swi") || (hostname.includes("play-mmf") && pathname.startsWith("/swi/")) || (hostname.includes("play-web") && pathname.startsWith("/swi/")):
bu = "swi";
break;
case hostname.includes("srf.ch") || hostname.includes("srgplayer-srf") || (hostname.includes("play-mmf") && pathname.startsWith("/srf/")):
case hostname.includes("srf.ch") || hostname.includes("srgplayer-srf") || (hostname.includes("play-mmf") && pathname.startsWith("/srf/")) || (hostname.includes("play-web") && pathname.startsWith("/srf/")):
bu = "srf";
break;
case hostname.includes("play-mmf") && pathname.startsWith("/mmf/"):
Expand Down Expand Up @@ -130,6 +130,12 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
pathname = pathname.substring(4);
}

if (hostname.includes("play-web")) {
pathname = pathname.substring(4);
pathname = pathname.replace("/stage/play", "/play");
pathname = pathname.replace("/test/play", "/play");
}

/**
* Catch special case: shared RTS media urls built by RTS MAM.
*
Expand Down Expand Up @@ -260,8 +266,9 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
* Catch live radio urls
*
* Ex: https://www.rsi.ch/play/radio/livepopup/rete-uno
* Ex: https://www.rsi.ch/play/radio/legacy-livepopup/rete-uno
*/
if (pathname.includes("/radio/livepopup/")) {
if (pathname.includes("/radio/livepopup/") || pathname.includes("/radio/legacy-livepopup/")) {
var mediaBu = null;
var mediaId = null;
switch (pathname.substr(pathname.lastIndexOf('/') + 1)) {
Expand Down Expand Up @@ -785,5 +792,13 @@ function serverForUrl(hostname, pathname, queryParams) {
}
}
}
else if (hostname.includes("play-web")) {
if (pathname.includes("/stage/play")) {
server = "stage";
}
else if (pathname.includes("/test/play")) {
server = "test";
}
}
return server;
}
29 changes: 22 additions & 7 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 = 23;
var parsePlayUrlVersion = 24;
var parsePlayUrlBuild = "mmf";

if(! console) {
Expand Down Expand Up @@ -102,6 +102,12 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
pathname = pathname.substring(4);
}

if (hostname.includes("play-web")) {
pathname = pathname.substring(4);
pathname = pathname.replace("/stage/play", "/play");
pathname = pathname.replace("/test/play", "/play");
}

/**
* Catch special case: shared RTS media urls built by RTS MAM.
*
Expand Down Expand Up @@ -232,8 +238,9 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
* Catch live radio urls
*
* Ex: https://www.rsi.ch/play/radio/livepopup/rete-uno
* Ex: https://www.rsi.ch/play/radio/legacy-livepopup/rete-uno
*/
if (pathname.includes("/radio/livepopup/")) {
if (pathname.includes("/radio/livepopup/") || pathname.includes("/radio/legacy-livepopup/")) {
var mediaBu = null;
var mediaId = null;
switch (pathname.substr(pathname.lastIndexOf('/') + 1)) {
Expand Down Expand Up @@ -803,22 +810,30 @@ function serverForUrl(hostname, pathname, queryParams) {
}
}
}
else if (hostname.includes("play-web")) {
if (pathname.includes("/stage/play")) {
server = "stage";
}
else if (pathname.includes("/test/play")) {
server = "test";
}
}
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/")):
case hostname.includes("rts.ch") || hostname.includes("srgplayer-rts") || (hostname.includes("play-mmf") && pathname.startsWith("/rts/")) || (hostname.includes("play-web") && pathname.startsWith("/rts/")):
return "rts";
case hostname.includes("rsi.ch") || hostname.includes("srgplayer-rsi") || (hostname.includes("play-mmf") && pathname.startsWith("/rsi/")):
case hostname.includes("rsi.ch") || hostname.includes("srgplayer-rsi") || (hostname.includes("play-mmf") && pathname.startsWith("/rsi/")) || (hostname.includes("play-web") && pathname.startsWith("/rsi/")):
return "rsi";
case hostname.includes("rtr.ch") || hostname.includes("srgplayer-rtr") || (hostname.includes("play-mmf") && pathname.startsWith("/rtr/")):
case hostname.includes("rtr.ch") || hostname.includes("srgplayer-rtr") || (hostname.includes("play-mmf") && pathname.startsWith("/rtr/")) || (hostname.includes("play-web") && pathname.startsWith("/rtr/")):
return "rtr";
case hostname.includes("swissinfo.ch") || hostname.includes("srgplayer-swi") || (hostname.includes("play-mmf") && pathname.startsWith("/swi/")):
case hostname.includes("swissinfo.ch") || hostname.includes("srgplayer-swi") || (hostname.includes("play-mmf") && pathname.startsWith("/swi/")) || (hostname.includes("play-web") && pathname.startsWith("/swi/")):
return "swi";
case hostname.includes("srf.ch") || hostname.includes("srgplayer-srf") || (hostname.includes("play-mmf") && pathname.startsWith("/srf/")):
case hostname.includes("srf.ch") || hostname.includes("srgplayer-srf") || (hostname.includes("play-mmf") && pathname.startsWith("/srf/")) || (hostname.includes("play-web") && pathname.startsWith("/srf/")):
return "srf";
case hostname.includes("play-mmf") && pathname.startsWith("/mmf/"):
return "mmf";
Expand Down

0 comments on commit a549e45

Please sign in to comment.