diff --git a/Core/src/main/java/com/jasonhhouse/gaps/Movie.java b/Core/src/main/java/com/jasonhhouse/gaps/Movie.java index 505b8f8..a27eaf5 100755 --- a/Core/src/main/java/com/jasonhhouse/gaps/Movie.java +++ b/Core/src/main/java/com/jasonhhouse/gaps/Movie.java @@ -45,10 +45,15 @@ public final class Movie implements Comparable { public static final String MOVIES_IN_COLLECTION = "movies_in_collection"; + @NotNull private final String name; + @NotNull private final Integer year; + @NotNull + private final String nameWithoutBadCharacters; + @Nullable @JsonProperty("poster_url") private final String posterUrl; @@ -67,9 +72,10 @@ public final class Movie implements Comparable { @NotNull private final List moviesInCollection; - private Movie(String name, Integer year, @Nullable String posterUrl, @Nullable String collection, @NotNull Integer collectionId, @NotNull Integer tvdbId, + private Movie(@NotNull String name, @NotNull Integer year, @Nullable String posterUrl, @Nullable String collection, @NotNull Integer collectionId, @NotNull Integer tvdbId, @Nullable String imdbId, @Nullable String language, @Nullable String overview, @NotNull List moviesInCollection) { this.name = name; + this.nameWithoutBadCharacters = name.replaceAll("[<>`~\\[\\]()*&^%$#@!|{}.,?\\-_=+:;]", ""); this.year = year; this.posterUrl = posterUrl; this.collection = collection; @@ -97,11 +103,13 @@ public final class Movie implements Comparable { this.tvdbId = tvdbId; } + @NotNull public String getName() { return name; } - public int getYear() { + @NotNull + public Integer getYear() { return year; } @@ -157,7 +165,7 @@ public final class Movie implements Comparable { } //Fallback is year and title - return year.equals(movie.year) && name.equals(movie.name); + return year.equals(movie.year) && nameWithoutBadCharacters.equals(movie.nameWithoutBadCharacters); } @Override @@ -211,7 +219,7 @@ public final class Movie implements Comparable { private List moviesInCollection; - public Builder(String name, int year) { + public Builder(@NotNull String name, @NotNull Integer year) { this.name = name; this.year = year; this.tvdbId = -1; diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java index 7013180..9e614d8 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java @@ -424,7 +424,7 @@ public class GapsSearchService implements GapsSearch { if (collection.has("parts")) { JsonNode parts = collection.get("parts"); parts.iterator().forEachRemaining(jsonNode -> { - String title = jsonNode.get("title").asText().replaceAll("[<>`~\\[\\]()*&^%$#@!|{}.,?\\-_=+:;]", ""); + String title = jsonNode.get("title").asText(); int year = -1; if(jsonNode.has("year")) { year = jsonNode.get("year").asInt(-1); @@ -465,7 +465,7 @@ public class GapsSearchService implements GapsSearch { for (JsonNode part : parts) { int tvdbId = part.get("id").asInt(); //Files can't have : so need to remove to find matches correctly - String title = part.get("title").asText().replaceAll("[<>`~\\[\\]()*&^%$#@!|{}.,?\\-_=+:;]", ""); + String title = part.get("title").asText(); int year; try { if (part.has("release_date") && StringUtils.isNotEmpty(part.get("release_date").asText())) {