Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
705 changes: 135 additions & 570 deletions README.md

Large diffs are not rendered by default.

31 changes: 15 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.immutables/value -->
<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
Expand Down Expand Up @@ -59,12 +53,6 @@
<artifactId>okhttp</artifactId>
<version>4.9.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
Expand All @@ -83,6 +71,11 @@
<artifactId>commons-text</artifactId>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
<version>0.10.6</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
Expand All @@ -91,6 +84,12 @@
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down Expand Up @@ -176,12 +175,12 @@
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>com.coveo</groupId>
<groupId>com.spotify.fmt</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>check</goal>
<goal>format</goal>
</goals>
</execution>
</executions>
Expand Down
30 changes: 4 additions & 26 deletions src/main/java/org/sundbybergheat/baseballstreaming/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.sundbybergheat.baseballstreaming.clients.FilesClient;
import org.sundbybergheat.baseballstreaming.clients.StatsClient;
import org.sundbybergheat.baseballstreaming.clients.FilesClient.ImageIOHandler;
import org.sundbybergheat.baseballstreaming.clients.WBSCPlayClient;
import org.sundbybergheat.baseballstreaming.services.FilesService;
import org.sundbybergheat.baseballstreaming.services.PlayByPlayService;
Expand All @@ -26,17 +26,11 @@ public static void main(String[] args) throws IOException {

options.addOption(
"t", "target", true, "Target directory for the output. E.g., '~/obs/resources'");
options.addOption(
"S",
"stats-base-url",
true,
"Base url where to fetch stats from. Defaults to 'https://stats.baseboll-softboll.se'");
options.addOption(
"P",
"plays-base-url",
true,
"Base url where to fetch plays from. Defaults to 'https://game.wbsc.org'");
options.addOption("s", "series", true, "Series ID. E.g., '2021-juniorserien-baseboll'");
options.addOption("g", "game", true, "Game ID. E.g., '84917'");
options.addOption("c", "config-file", true, "Path to config file");
options.addOption(
Expand All @@ -46,7 +40,6 @@ public static void main(String[] args) throws IOException {
"delay",
true,
"Delay (milliseconds) between fetching plays. Defaults to 500 for live and 3000 for replay.");
options.addOption("l", "limit-stats", false, "Only use stats from this series");
options.addOption("h", "help", false, "Print this help section");

HelpFormatter formatter = new HelpFormatter();
Expand All @@ -66,13 +59,8 @@ public static void main(String[] args) throws IOException {
return;
}

// Due to rate-limiting on WBSC APIs, always only fetch this series stats
final boolean onlyUseThisSeriesStats = true;

String target = null;
String seriesId = null;
String gameId = null;
String statsBaseUrl = null;
String playsBaseUrl = null;
String runMode = RunMode.live.toString();
String delay = null;
Expand All @@ -88,16 +76,12 @@ public static void main(String[] args) throws IOException {
}

target = properties.getProperty("target");
seriesId = properties.getProperty("series");
gameId = properties.getProperty("game");
statsBaseUrl = properties.getProperty("stats-base-url", "https://stats.baseboll-softboll.se");
playsBaseUrl = properties.getProperty("plays-base-url", "https://game.wbsc.org");
runMode = properties.getProperty("run-mode", RunMode.live.toString());
} else {
target = cmd.getOptionValue("t");
seriesId = cmd.getOptionValue("s");
gameId = cmd.getOptionValue("g");
statsBaseUrl = cmd.getOptionValue("S", "https://stats.baseboll-softboll.se");
playsBaseUrl = cmd.getOptionValue("P", "https://game.wbsc.org");
runMode = cmd.getOptionValue("m", RunMode.live.toString());
delay = cmd.getOptionValue("d", runMode.equals(RunMode.live.toString()) ? "500" : "3000");
Expand All @@ -108,11 +92,6 @@ public static void main(String[] args) throws IOException {
formatter.printHelp("baseball-streaming", options);
return;
}
if (seriesId == null) {
System.err.println("Missing required config/option: series");
formatter.printHelp("baseball-streaming", options);
return;
}
if (gameId == null) {
System.err.println("Missing required config/option: game");
formatter.printHelp("baseball-streaming", options);
Expand All @@ -126,10 +105,9 @@ public static void main(String[] args) throws IOException {
}

OkHttpClient okHttpClient = new OkHttpClient();
FilesClient filesClient = new FilesClient(target);
StatsClient statsClient = new StatsClient(okHttpClient, statsBaseUrl);
FilesService filesService =
new FilesService(filesClient, statsClient, seriesId, onlyUseThisSeriesStats);
ImageIOHandler imageIOHandler = new ImageIOHandler();
FilesClient filesClient = new FilesClient(target, imageIOHandler);
FilesService filesService = new FilesService(filesClient);
WBSCPlayClient wbscPlayClient = new WBSCPlayClient(okHttpClient, playsBaseUrl);

filesService.initResources();
Expand Down

This file was deleted.

Loading