[LIB-10] WorldSnooker URL utils
authorgotty <gotty@fb0bcced-7025-49ed-a12f-f98bce993226>
Fri, 22 Nov 2019 06:15:35 +0000 (06:15 +0000)
committergotty <gotty@fb0bcced-7025-49ed-a12f-f98bce993226>
Fri, 22 Nov 2019 06:15:35 +0000 (06:15 +0000)
git-svn-id: https://svn.hedgecode.org/lib/snooker-score-api/trunk@192 fb0bcced-7025-49ed-a12f-f98bce993226

src/main/java/org/hedgecode/snooker/SnookerURLUtils.java

index b240d2a..33e978c 100644 (file)
@@ -51,6 +51,10 @@ public final class SnookerURLUtils {
     private static final String TWITTER_URL = "https://twitter.com/";
     private static final String TWITTER_HASHTAG = "hashtag/";
 
     private static final String TWITTER_URL = "https://twitter.com/";
     private static final String TWITTER_HASHTAG = "hashtag/";
 
+    private static final String WORLDSNOOKER_URL = "http://livescores.worldsnookerdata.com/";
+    private static final String WORLDSNOOKER_EVENT_MATCHES = "Matches/Index/";
+    private static final String WORLDSNOOKER_MATCH_RESULT = "Matches/Result/";
+
     public static List<SnookerURL> parseUrls(Map<String, String> htmlStrings) throws APIException {
         List<SnookerURL> result = new ArrayList<>();
         htmlStrings.forEach( (name, htmlString) -> {
     public static List<SnookerURL> parseUrls(Map<String, String> htmlStrings) throws APIException {
         List<SnookerURL> result = new ArrayList<>();
         htmlStrings.forEach( (name, htmlString) -> {
@@ -147,4 +151,16 @@ public final class SnookerURLUtils {
                 : null;
     }
 
                 : null;
     }
 
+    public static String worldSnookerEventUrl(int wsEventId) {
+        return wsEventId > 0
+                ? String.format("%s%s%d", WORLDSNOOKER_URL, WORLDSNOOKER_EVENT_MATCHES, wsEventId)
+                : null;
+    }
+
+    public static String worldSnookerMatchUrl(int wsEventId, int wsMatchId) {
+        return wsEventId > 0 && wsMatchId > 0
+                ? String.format("%s%s%d/%d", WORLDSNOOKER_URL, WORLDSNOOKER_MATCH_RESULT, wsEventId, wsMatchId)
+                : null;
+    }
+
 }
 }