Skip to content

Commit

Permalink
Merge pull request #58 from SRGSSR/develop
Browse files Browse the repository at this point in the history
Release build 35
  • Loading branch information
pyby authored Jul 30, 2021
2 parents f4326a8 + c13e1bc commit e45adb1
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 20 deletions.
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ A wide list of parameters are available.
* `MAX_DEEP_LINK_REPORTS` (optional, integer): Maximum number of deep link reports in the database. If not set, defaults is `2500`.
* `DEEP_LINK_ENVIRONMENTS` (optional, string, multiple): List of `Environment`s to pull deep link dynamic informations. If not set, defaults is `PROD`.
* `UPDATE_CHECK_DISABLED` (optional, boolean): Disable checking if a recommended or required update is available, if set to `true`. If not set, defaults is `false`.
* `RTS_RECOMMENDATION_USED` (optional, boolean): Use RTS recommendation engine (RE) in usages validated by the BU, if set to `true`. Otherwise, use default RE. If not set, defaults is `true`.
* `SRF_RECOMMENDATION_USED` (optional, boolean): Use SRF recommendation engine (RE) in usages validated by the BU, if set to `true`. Otherwise, use default RE. If not set, defaults is `true`.

## API
* `urn` (string): an unique identifier.
Expand Down
6 changes: 4 additions & 2 deletions docs/RECOMMENDATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Since July 2018, Play Android (2.0.207 and more) and Play iOS (2.8.3-272 and mor

The API doesn't not support paginations, therefore mobile applications didn't implement pagination. The media recommendation list must have at least 49 items, the 50th is the requested media, put on the first position of the list. If there is no recommended media, the returned list is empty.

### Purposes
### Usages

By default, here are the used recommendation engines (RE). `RTS_RECOMMENDATION_USED` and `SRF_RECOMMENDATION_USED` environment variables can fallback to default **Pfff RE** recommendation engine.

- `continuousPlayback` is used to display one proposition, with a count down and an autoplay.
- `relatedContent` is used to display some propositions in a swimlane or a grid, without an autoplay.
Expand All @@ -32,7 +34,7 @@ The API doesn't not support paginations, therefore mobile applications didn't im
| Event videos | N/A | N/A |
| Swisstxt videos | N/A | N/A |

### Recommendation engines used
### Recommendation engine descriptions

#### RTS recommendation engine (RTS RE)

Expand Down
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>34</version>
<version>35</version>
<packaging>jar</packaging>

<name>pfff</name>
Expand Down
33 changes: 27 additions & 6 deletions src/main/java/ch/srgssr/playfff/service/RecommendationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
Expand All @@ -32,23 +33,39 @@ public class RecommendationService {

private RestTemplate restTemplate;

public RecommendationService() {
private Boolean rtsRecommendationUsed;
private Boolean srfRecommendationUsed;

public RecommendationService(
@Value("${RTS_RECOMMENDATION_USED:true}") String rtsRecommendationUsedString,
@Value("${SRF_RECOMMENDATION_USED:true}") String srfRecommendationUsedString
) {
restTemplate = new RestTemplate();
rtsRecommendationUsed = Boolean.valueOf(rtsRecommendationUsedString);
srfRecommendationUsed = Boolean.valueOf(srfRecommendationUsedString);
}

public RecommendedList getRecommendedUrns(String purpose, String urnString, boolean standalone) {
IlUrn urn = new IlUrn(urnString);
if (purpose.equals("relatedContent")) {
switch (urn.getMam()) {
case RTS:
if (urn.getMediaType() == MediaType.VIDEO) {
return rtsVideoRecommendedList(purpose, urnString, standalone);
} else if (urn.getMediaType() == MediaType.AUDIO) {
return pfffRecommendedList(urnString, MediaType.AUDIO, standalone);
if (rtsRecommendationUsed) {
if (urn.getMediaType() == MediaType.VIDEO) {
return rtsVideoRecommendedList(purpose, urnString, standalone);
} else if (urn.getMediaType() == MediaType.AUDIO) {
return pfffRecommendedList(urnString, MediaType.AUDIO, standalone);
}
} else {
return pfffRecommendedList(urnString, urn.getMediaType(), standalone);
}
break;
case SRF:
return srfRecommendedList(purpose, urnString, standalone);
if (srfRecommendationUsed) {
return srfRecommendedList(purpose, urnString, standalone);
} else {
return pfffRecommendedList(urnString, urn.getMediaType(), standalone);
}
case RSI:
case RTR:
case SWI:
Expand All @@ -58,11 +75,15 @@ public RecommendedList getRecommendedUrns(String purpose, String urnString, bool
else {
switch (urn.getMam()) {
case RTS:
if (rtsRecommendationUsed) {
if (urn.getMediaType() == MediaType.VIDEO) {
return rtsVideoRecommendedList(purpose, urnString, standalone);
} else if (urn.getMediaType() == MediaType.AUDIO) {
return pfffRecommendedList(urnString, MediaType.AUDIO, standalone);
}
} else {
return pfffRecommendedList(urnString, urn.getMediaType(), standalone);
}
break;
case RSI:
case RTR:
Expand Down
8 changes: 4 additions & 4 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 = 29;
var parsePlayUrlVersion = 30;
var parsePlayUrlBuild = "mmf";

if(! console) {
Expand Down Expand Up @@ -558,9 +558,9 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
* Ex: https://www.rts.ch/play/tv/emissions-par-dates/2021-06-21
* Ex: https://www.srf.ch/play/tv/programm/2021-07-03
*/
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/") ||
pathname.endsWith("/tv/programm") || pathname.includes("/tv/programme") || pathname.includes("/tv/program") ||
pathname.includes("/tv/programm/") || pathname.includes("/tv/programme/") || pathname.includes("/tv/program/")) {
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/") ||
pathname.endsWith("/tv/programm") || pathname.includes("/tv/programme") || pathname.includes("/tv/guida-programmi") || pathname.includes("/tv/program") ||
pathname.includes("/tv/programm/") || pathname.includes("/tv/programme/") || pathname.includes("/tv/guida-programmi/") || pathname.includes("/tv/program/")) {
var lastPathComponent = pathname.split("/").slice(-1)[0];

var date = null;
Expand Down
8 changes: 4 additions & 4 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 = 29;
var parsePlayUrlVersion = 30;
var parsePlayUrlBuild = "mmf";

if(! console) {
Expand Down Expand Up @@ -528,9 +528,9 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
* Ex: https://www.rts.ch/play/tv/emissions-par-dates/2021-06-21
* Ex: https://www.srf.ch/play/tv/programm/2021-07-03
*/
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/") ||
pathname.endsWith("/tv/programm") || pathname.includes("/tv/programme") || pathname.includes("/tv/program") ||
pathname.includes("/tv/programm/") || pathname.includes("/tv/programme/") || pathname.includes("/tv/program/")) {
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/") ||
pathname.endsWith("/tv/programm") || pathname.includes("/tv/programme") || pathname.includes("/tv/guida-programmi") || pathname.includes("/tv/program") ||
pathname.includes("/tv/programm/") || pathname.includes("/tv/programme/") || pathname.includes("/tv/guida-programmi/") || pathname.includes("/tv/program/")) {
var lastPathComponent = pathname.split("/").slice(-1)[0];

var date = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static class MediaListResult {

@Test
public void getRecommendationRTSVideoURNFormat() throws Exception {
String mediaURN = "urn:rts:video:9691670";
String mediaURN = "urn:rts:video:12184168";

getRecommendationURNFormat(mediaURN, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RecommendationServiceTests {
@Test
public void getRecommendedUrnsContinuousplaybackRTSVideoTest() {
String purpose = "continuousplayback";
String mediaURN = "urn:rts:video:9691670";
String mediaURN = "urn:rts:video:12184168";
boolean standalone = false;
RecommendedList recommendedList = recommendationService.getRecommendedUrns(purpose, mediaURN, standalone);

Expand All @@ -31,7 +31,7 @@ public void getRecommendedUrnsContinuousplaybackRTSVideoTest() {
@Test
public void getRecommendedUrnsContinuousplaybackStandaloneRTSVideoTest() {
String purpose = "continuousplayback";
String mediaURN = "urn:rts:video:9691670";
String mediaURN = "urn:rts:video:12184168";
boolean standalone = true;
RecommendedList recommendedList = recommendationService.getRecommendedUrns(purpose, mediaURN, standalone);

Expand Down

0 comments on commit e45adb1

Please sign in to comment.