From 6275752c90b1298e3b9606440230ebba9326ee18 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Bertholon Date: Sun, 6 Jun 2021 16:48:03 +0200 Subject: [PATCH 1/3] Bump version number --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a87f48a..e57d6ec 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ ch.srgssr playfff - 32 + 33 jar pfff From 0e1d009b6d8737e0f3b58ea78f349b99421618af Mon Sep 17 00:00:00 2001 From: Pierre-Yves Bertholon Date: Tue, 22 Jun 2021 12:55:18 +0200 Subject: [PATCH 2/3] Update ParsePlayUrl JS to version 28 with new section page urls and deeplink feedbacks from 06.2020 --- .../resources/deeplink/v1/parsePlayUrl.js | 128 ++++++++++++++---- .../resources/deeplink/v2/parsePlayUrl.js | 128 ++++++++++++++---- 2 files changed, 208 insertions(+), 48 deletions(-) diff --git a/src/main/resources/deeplink/v1/parsePlayUrl.js b/src/main/resources/deeplink/v1/parsePlayUrl.js index 32116f6..ab1a734 100644 --- a/src/main/resources/deeplink/v1/parsePlayUrl.js +++ b/src/main/resources/deeplink/v1/parsePlayUrl.js @@ -1,6 +1,6 @@ // parsePlayUrl -var parsePlayUrlVersion = 27; +var parsePlayUrlVersion = 28; var parsePlayUrlBuild = "mmf"; if(! console) { @@ -10,10 +10,13 @@ if(! console) { } function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { - // fix path issue pathname = pathname.replace("//", "/"); + // Case insensitive + hostname = hostname.toLowerCase(); + pathname = pathname.toLowerCase(); + // Get BU var bu = null; switch (true) { @@ -59,8 +62,8 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { */ if (bu == "lb") { if (pathname.startsWith("/p/")) { - var mediaURN = queryParams["urn"]; - if (mediaURN) { + var mediaUrn = queryParams["urn"]; + if (mediaUrn) { var redirectBu = "lb"; switch (true) { case pathname.startsWith("/p/srf/"): @@ -80,14 +83,14 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { break; } var startTime = queryParams["start"]; - return openMediaURN(server, redirectBu, mediaURN, startTime); + return openMediaUrn(server, redirectBu, mediaUrn, startTime); } } else if (pathname.startsWith("/srgletterbox-web")) { - var mediaURN = queryParams["urn"]; - if (mediaURN) { + var mediaUrn = queryParams["urn"]; + if (mediaUrn) { var startTime = queryParams["pendingSeek"]; - return openMediaURN(server, "lb", mediaURN, startTime); + return openMediaUrn(server, "lb", mediaUrn, startTime); } } } @@ -125,8 +128,8 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { */ if (bu == "mmf") { if (pathname.includes("/media/")) { - var lastPathComponent = pathname.split("/").slice(-1)[0]; - return openMediaURN(server, bu, lastPathComponent, null); + var mediaUrn = pathname.split("/").slice(-1)[0]; + return openMediaUrn(server, bu, mediaUrn, null); } // Returns default TV homepage @@ -154,8 +157,8 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { var mediaId = null; if (pathname.endsWith(".html")) { - var lastPath = pathname.substr(pathname.lastIndexOf('/') + 1); - mediaId = lastPath.split('.')[0].split('-')[0]; + var lastPathComponent = pathname.split("/").slice(-1)[0]; + mediaId = lastPathComponent.split('.')[0].split('-')[0]; } if (mediaId) { @@ -217,7 +220,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { var mediaId = queryParams["id"]; var startTime = queryParams["startTime"]; if (mediaUrn) { - return openMediaURN(server, bu, mediaUrn, startTime); + return openMediaUrn(server, bu, mediaUrn, startTime); } else if (mediaId) { return openMedia(server, bu, mediaType, mediaId, startTime); @@ -231,6 +234,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * Catch redirect media urls * * Ex: https://www.rts.ch/play/tv/redirect/detail/9938530 + * Ex: http://www.srf.ch/play/tv/redirect/Detail/99f040e9-b1e6-4d7a-bc08-d5639d600aa1 */ switch (true) { case pathname.includes("/tv/redirect/detail/"): @@ -242,7 +246,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { } if (mediaType) { - var mediaId = pathname.substr(pathname.lastIndexOf('/') + 1); + var mediaId = pathname.split("/").slice(-1)[0]; if (mediaId) { var startTime = queryParams["startTime"]; return openMedia(server, bu, mediaType, mediaId, startTime); @@ -259,10 +263,10 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * Ex: https://www.rts.ch/play/embed?urn=urn:rts:video:580545&startTime=60 */ if (pathname.endsWith("/embed")) { - var mediaURN = queryParams["urn"]; - if (mediaURN) { + var mediaUrn = queryParams["urn"]; + if (mediaUrn) { var startTime = queryParams["startTime"]; - return openMediaURN(server, bu, mediaURN, startTime); + return openMediaUrn(server, bu, mediaUrn, startTime); } else { // Returns default TV homepage @@ -291,13 +295,41 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { /** * Catch live radio urls * + * Ex: https://www.rsi.ch/play/radio/livepopup * 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/") || pathname.includes("/radio/legacy-livepopup/")) { + if (pathname.endsWith("/radio/livepopup") || pathname.endsWith("/radio/legacy-livepopup") || pathname.endsWith("/radio/livepopup/") || pathname.endsWith("/radio/legacy-livepopup/")) { + var mediaId = null; + + switch (bu) { + case "srf": + mediaId = "69e8ac16-4327-4af4-b873-fd5cd6e895a7"; + break; + case "rts": + mediaId = "3262320"; + break; + case "rsi": + mediaId = "livestream_ReteUno"; + break; + case "rtr": + mediaId = "a029e818-77a5-4c2e-ad70-d573bb865e31"; + break; + default: + } + + if (mediaId) { + return openMedia(server, bu, "audio", mediaId, null); + } + else { + // Returns default radio homepage + return openPage(server, bu, "radio:home", null, null); + } + } + else if (pathname.includes("/radio/livepopup/") || pathname.includes("/radio/legacy-livepopup/")) { var mediaBu = null; var mediaId = null; - switch (pathname.substr(pathname.lastIndexOf('/') + 1)) { + switch (pathname.split("/").slice(-1)[0]) { case "radio-srf-1": mediaBu = "srf"; mediaId = "69e8ac16-4327-4af4-b873-fd5cd6e895a7"; @@ -440,7 +472,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { } if (showTransmission) { - var showId = pathname.substr(pathname.lastIndexOf('/') + 1); + var showId = pathname.split("/").slice(-1)[0]; if (showId) { return openShow(server, bu, showTransmission, showId); } @@ -520,6 +552,26 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { return openPage(server, bu, "tv:bydate", null, options); } + /** + * Catch new by date TV urls + * + * Ex: https://www.rts.ch/play/tv/emissions-par-dates/2021-06-21 + */ + if (pathname.includes("/tv/sendungen-nach-datum/") || pathname.includes("/tv/emissions-par-dates/") || pathname.includes("/tv/programmi-per-data/") || pathname.includes("/tv/emissiuns-tenor-data/")) { + var lastPathComponent = pathname.split("/").slice(-1)[0]; + + var date = null; + if (lastPathComponent) { + // Returns an ISO format + var dateArray = lastPathComponent.split("-"); + if (dateArray.length == 3 && dateArray[0].length == 4 && dateArray[1].length == 2 && dateArray[2].length == 2) { + date = lastPathComponent; + } + } + var options = new Array( { key: "date", value: date } ); + return openPage(server, bu, "tv:bydate", null, options); + } + /** * Catch by date radio urls * @@ -594,7 +646,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * Catch TV event urls * * Ex: https://www.srf.ch/play/tv/event/10-jahre-auf-und-davon - *. Ex: https://www.rsi.ch/play/tv/event/event-playrsi-8858482 + * Ex: https://www.rsi.ch/play/tv/event/event-playrsi-8858482 */ if (pathname.endsWith("/tv/event")) { return openPage(server, bu, "tv:home", null, null); @@ -618,11 +670,31 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { } } + /** + * Catch TV section page urls + * + * Ex: https://www.rts.ch/play/tv/detail/bulles-dair?id=f75179d9-f621-4855-b695-a9ba206864c2 + * Ex: https://www.rsi.ch/play/tv/detail/il-giardino-di-albert-lis?id=bd8d8352-4512-4f24-86b0-c380f94ab701 + */ + if (pathname.endsWith("/tv/detail")) { + return openPage(server, bu, "tv:home", null, null); + } + else if (pathname.includes("/tv/detail")) { + var sectionId = queryParams["id"]; + + if (sectionId) { + return openSection(server, bu, sectionId); + } + else { + return openPage(server, bu, "tv:home", null, null); + } + } + /** * Catch base play urls * * Ex: https://www.srf.ch/play/ - *. Ex: https://www.rsi.ch/play + * Ex: https://www.rsi.ch/play */ if (pathname.endsWith("/play/") || pathname.endsWith("/play")) { return openPage(server, bu, "tv:home", null, null); @@ -667,8 +739,8 @@ function openMedia(server, bu, mediaType, mediaId, startTime) { return redirect; } -function openMediaURN(server, bu, mediaURN, startTime) { - var redirect = schemeForBu(bu) + "://open?media=" + mediaURN; +function openMediaUrn(server, bu, mediaUrn, startTime) { + var redirect = schemeForBu(bu) + "://open?media=" + mediaUrn; if (startTime) { redirect = redirect + "&start-time=" + startTime; } @@ -702,6 +774,14 @@ function openModule(server, bu, moduleType, moduleId) { return redirect; } +function openSection(server, bu, sectionId) { + var redirect = schemeForBu(bu) + "://open?section=" + sectionId; + if (server) { + redirect = redirect + "&server=" + encodeURIComponent(server); + } + return redirect; +} + function openPage(server, bu, page, channelId, options) { if (! page) { page = "tv:home"; diff --git a/src/main/resources/deeplink/v2/parsePlayUrl.js b/src/main/resources/deeplink/v2/parsePlayUrl.js index d5b9701..1492b8f 100644 --- a/src/main/resources/deeplink/v2/parsePlayUrl.js +++ b/src/main/resources/deeplink/v2/parsePlayUrl.js @@ -1,6 +1,6 @@ // parsePlayUrl -var parsePlayUrlVersion = 27; +var parsePlayUrlVersion = 28; var parsePlayUrlBuild = "mmf"; if(! console) { @@ -13,6 +13,10 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { // fix path issue pathname = pathname.replace("//", "/"); + // Case insensitive + hostname = hostname.toLowerCase(); + pathname = pathname.toLowerCase(); + // Get BU var bu = getBuFromHostname(hostname,pathname); if (! bu) { @@ -31,8 +35,8 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { */ if (bu == "lb") { if (pathname.startsWith("/p/")) { - var mediaURN = queryParams["urn"]; - if (mediaURN) { + var mediaUrn = queryParams["urn"]; + if (mediaUrn) { var redirectBu = "lb"; switch (true) { case pathname.startsWith("/p/srf/"): @@ -52,14 +56,14 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { break; } var startTime = queryParams["start"]; - return openMediaURN(server, redirectBu, mediaURN, startTime); + return openMediaUrn(server, redirectBu, mediaUrn, startTime); } } else if (pathname.startsWith("/srgletterbox-web")) { - var mediaURN = queryParams["urn"]; - if (mediaURN) { + var mediaUrn = queryParams["urn"]; + if (mediaUrn) { var startTime = queryParams["pendingSeek"]; - return openMediaURN(server, "lb", mediaURN, startTime); + return openMediaUrn(server, "lb", mediaUrn, startTime); } } } @@ -97,8 +101,8 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { */ if (bu == "mmf") { if (pathname.includes("/media/")) { - var lastPathComponent = pathname.split("/").slice(-1)[0]; - return openMediaURN(server, bu, lastPathComponent, null); + var mediaUrn = pathname.split("/").slice(-1)[0]; + return openMediaUrn(server, bu, mediaUrn, null); } // Returns default TV homepage @@ -126,8 +130,8 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { var mediaId = null; if (pathname.endsWith(".html")) { - var lastPath = pathname.substr(pathname.lastIndexOf('/') + 1); - mediaId = lastPath.split('.')[0].split('-')[0]; + var lastPathComponent = pathname.split("/").slice(-1)[0]; + mediaId = lastPathComponent.split('.')[0].split('-')[0]; } if (mediaId) { @@ -189,7 +193,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { var mediaId = queryParams["id"]; var startTime = queryParams["startTime"]; if (mediaUrn) { - return openMediaURN(server, bu, mediaUrn, startTime); + return openMediaUrn(server, bu, mediaUrn, startTime); } else if (mediaId) { return openMedia(server, bu, mediaType, mediaId, startTime); @@ -203,6 +207,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * Catch redirect media urls * * Ex: https://www.rts.ch/play/tv/redirect/detail/9938530 + * Ex: http://www.srf.ch/play/tv/redirect/Detail/99f040e9-b1e6-4d7a-bc08-d5639d600aa1 */ switch (true) { case pathname.includes("/tv/redirect/detail/"): @@ -214,7 +219,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { } if (mediaType) { - var mediaId = pathname.substr(pathname.lastIndexOf('/') + 1); + var mediaId = pathname.split("/").slice(-1)[0]; if (mediaId) { var startTime = queryParams["startTime"]; return openMedia(server, bu, mediaType, mediaId, startTime); @@ -231,10 +236,10 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * Ex: https://www.rts.ch/play/embed?urn=urn:rts:video:580545&startTime=60 */ if (pathname.endsWith("/embed")) { - var mediaURN = queryParams["urn"]; - if (mediaURN) { + var mediaUrn = queryParams["urn"]; + if (mediaUrn) { var startTime = queryParams["startTime"]; - return openMediaURN(server, bu, mediaURN, startTime); + return openMediaUrn(server, bu, mediaUrn, startTime); } else { // Returns default TV homepage @@ -263,13 +268,41 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { /** * Catch live radio urls * + * Ex: https://www.rsi.ch/play/radio/livepopup * 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/") || pathname.includes("/radio/legacy-livepopup/")) { + if (pathname.endsWith("/radio/livepopup") || pathname.endsWith("/radio/legacy-livepopup") || pathname.endsWith("/radio/livepopup/") || pathname.endsWith("/radio/legacy-livepopup/")) { + var mediaId = null; + + switch (bu) { + case "srf": + mediaId = "69e8ac16-4327-4af4-b873-fd5cd6e895a7"; + break; + case "rts": + mediaId = "3262320"; + break; + case "rsi": + mediaId = "livestream_ReteUno"; + break; + case "rtr": + mediaId = "a029e818-77a5-4c2e-ad70-d573bb865e31"; + break; + default: + } + + if (mediaId) { + return openMedia(server, bu, "audio", mediaId, null); + } + else { + // Returns default radio homepage + return openRadioHomePage(server, bu, null); + } + } + else if (pathname.includes("/radio/livepopup/") || pathname.includes("/radio/legacy-livepopup/")) { var mediaBu = null; var mediaId = null; - switch (pathname.substr(pathname.lastIndexOf('/') + 1)) { + switch (pathname.split("/").slice(-1)[0]) { case "radio-srf-1": mediaBu = "srf"; mediaId = "69e8ac16-4327-4af4-b873-fd5cd6e895a7"; @@ -412,7 +445,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { } if (showTransmission) { - var showId = pathname.substr(pathname.lastIndexOf('/') + 1); + var showId = pathname.split("/").slice(-1)[0]; if (showId) { return openShow(server, bu, showTransmission, showId); } @@ -489,6 +522,25 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { return openByDate(server, bu, null, date); } + /** + * Catch new by date TV urls + * + * Ex: https://www.rts.ch/play/tv/emissions-par-dates/2021-06-21 + */ + if (pathname.includes("/tv/sendungen-nach-datum/") || pathname.includes("/tv/emissions-par-dates/") || pathname.includes("/tv/programmi-per-data/") || pathname.includes("/tv/emissiuns-tenor-data/")) { + var lastPathComponent = pathname.split("/").slice(-1)[0]; + + var date = null; + if (lastPathComponent) { + // Returns an ISO format + var dateArray = lastPathComponent.split("-"); + if (dateArray.length == 3 && dateArray[0].length == 4 && dateArray[1].length == 2 && dateArray[2].length == 2) { + date = lastPathComponent; + } + } + return openByDate(server, bu, null, date); + } + /** * Catch by date radio urls * @@ -559,7 +611,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * Catch TV event urls * * Ex: https://www.srf.ch/play/tv/event/10-jahre-auf-und-davon - *. Ex: https://www.rsi.ch/play/tv/event/event-playrsi-8858482 + * Ex: https://www.rsi.ch/play/tv/event/event-playrsi-8858482 */ if (pathname.endsWith("/tv/event")) { return openTvHomePage(server, bu); @@ -583,11 +635,31 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { } } + /** + * Catch TV section page urls + * + * Ex: https://www.rts.ch/play/tv/detail/bulles-dair?id=f75179d9-f621-4855-b695-a9ba206864c2 + * Ex: https://www.rsi.ch/play/tv/detail/il-giardino-di-albert-lis?id=bd8d8352-4512-4f24-86b0-c380f94ab701 + */ + if (pathname.endsWith("/tv/detail")) { + return openTvHomePage(server, bu); + } + else if (pathname.includes("/tv/detail")) { + var sectionId = queryParams["id"]; + + if (sectionId) { + return openSection(server, bu, sectionId); + } + else { + return openTvHomePage(server, bu); + } + } + /** * Catch base play urls * * Ex: https://www.srf.ch/play/ - *. Ex: https://www.rsi.ch/play + * Ex: https://www.rsi.ch/play */ if (pathname.endsWith("/play/") || pathname.endsWith("/play")) { return openTvHomePage(server, bu); @@ -626,10 +698,10 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { function openMedia(server, bu, mediaType, mediaId, startTime) { var urn="urn:" + bu + ":" + mediaType + ":" + mediaId; - return openMediaURN(server, bu, urn, startTime); + return openMediaUrn(server, bu, urn, startTime); } -function openMediaURN(server, bu, mediaURN, startTime) { +function openMediaUrn(server, bu, mediaUrn, startTime) { var options = {}; if (startTime) { options['start_time'] = startTime; @@ -637,7 +709,7 @@ function openMediaURN(server, bu, mediaURN, startTime) { if (server) { options['server'] = server; } - return buildBuUri(bu,"media",mediaURN,options); + return buildBuUri(bu,"media",mediaUrn,options); } function openShow(server, bu, showTransmission, showId) { @@ -667,6 +739,14 @@ function openModule(server, bu, moduleType, moduleId) { return buildBuUri(bu,"module",topicUrn,options); } +function openSection(server, bu, sectionId) { + var options = {}; + if (server) { + options['server'] = server; + } + return buildBuUri(bu,"section",sectionId,options); +} + function openTvHomePage(server,bu){ var options = {}; if (server) { From d3f3c565dff5b3a01c8320265ad375083ac5169d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Bertholon Date: Fri, 25 Jun 2021 17:07:34 +0200 Subject: [PATCH 3/3] Update ParsePlayUrl JS to version 28 with LB-demo url update --- src/main/resources/deeplink/v1/parsePlayUrl.js | 3 +++ src/main/resources/deeplink/v2/parsePlayUrl.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/main/resources/deeplink/v1/parsePlayUrl.js b/src/main/resources/deeplink/v1/parsePlayUrl.js index ab1a734..dec33de 100644 --- a/src/main/resources/deeplink/v1/parsePlayUrl.js +++ b/src/main/resources/deeplink/v1/parsePlayUrl.js @@ -920,14 +920,17 @@ function serverForUrl(hostname, pathname, queryParams) { var serverParam = queryParams["env"]; switch (serverParam) { case "stage": + case "il-stage.srgssr.ch": server = "stage"; break; case "test": + case "il-test.srgssr.ch": server = "test"; break; case "play mmf": case "play+mmf": case "mmf": + case "play-mmf.herokuapp.com": server = "play mmf"; break; } diff --git a/src/main/resources/deeplink/v2/parsePlayUrl.js b/src/main/resources/deeplink/v2/parsePlayUrl.js index 1492b8f..2d90126 100644 --- a/src/main/resources/deeplink/v2/parsePlayUrl.js +++ b/src/main/resources/deeplink/v2/parsePlayUrl.js @@ -938,14 +938,17 @@ function serverForUrl(hostname, pathname, queryParams) { var serverParam = queryParams["env"]; switch (serverParam) { case "stage": + case "il-stage.srgssr.ch": server = "stage"; break; case "test": + case "il-test.srgssr.ch": server = "test"; break; case "play mmf": case "play+mmf": case "mmf": + case "play-mmf.herokuapp.com": server = "play mmf"; break; }