Skip to content

Commit

Permalink
- always perform duplicate check when reading filmlist
Browse files Browse the repository at this point in the history
  • Loading branch information
derreisende77 committed Oct 21, 2024
1 parent 16322d7 commit f02f2de
Showing 1 changed file with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -50,19 +51,7 @@ private void checkDuplicates() {
Stopwatch watch = Stopwatch.createStarted();
listeFilme.stream()
.filter(f -> !f.isLivestream())
.sorted((s1, s2) -> {
// "ARD" und "ZDF" immer am Ende um die kleineren Mediatheken nicht zu benachteiligen
final var s1_sender = s1.getSender();
final var s2_sender = s2.getSender();
if (s1_sender.equals("ARD") || s1_sender.equals("ZDF")) {
return 1;
}
if (s2_sender.equals("ARD") || s2_sender.equals("ZDF")) {
return -1;
}
// Alphabetisch sortieren für alle anderen
return s1.compareTo(s2);
})
.sorted(new BigSenderPenaltyComparator())
.forEach(film -> {
final var url = film.getUrlNormalQuality();
film.setDuplicate(urlCache.contains(url));
Expand Down Expand Up @@ -102,4 +91,21 @@ public void run() {
checkDuplicates();
printDuplicateStatistics();
}

private static class BigSenderPenaltyComparator implements Comparator<DatenFilm> {
@Override
public int compare(DatenFilm s1, DatenFilm s2) {
// "ARD" und "ZDF" immer am Ende um die kleineren Mediatheken nicht zu benachteiligen
final var s1_sender = s1.getSender();
final var s2_sender = s2.getSender();
if (s1_sender.equals("ARD") || s1_sender.equals("ZDF")) {
return 1;
}
if (s2_sender.equals("ARD") || s2_sender.equals("ZDF")) {
return -1;
}
// Alphabetisch sortieren für alle anderen
return s1.compareTo(s2);
}
}
}

0 comments on commit f02f2de

Please sign in to comment.