Setting all movies to have a no bad characters private field

This commit is contained in:
Jason House
2020-07-30 09:26:30 +09:00
parent a37bf0710b
commit 3eae2bd11e
2 changed files with 14 additions and 6 deletions

View File

@@ -45,10 +45,15 @@ public final class Movie implements Comparable<Movie> {
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<Movie> {
@NotNull
private final List<MovieFromCollection> 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<MovieFromCollection> 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<Movie> {
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<Movie> {
}
//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<Movie> {
private List<MovieFromCollection> moviesInCollection;
public Builder(String name, int year) {
public Builder(@NotNull String name, @NotNull Integer year) {
this.name = name;
this.year = year;
this.tvdbId = -1;

View File

@@ -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())) {