diff --git a/src/main/java/de/mediathekview/mserver/base/utils/FilmlistDebugHelper.java b/src/main/java/de/mediathekview/mserver/base/utils/FilmlistDebugHelper.java deleted file mode 100644 index 92bbae310..000000000 --- a/src/main/java/de/mediathekview/mserver/base/utils/FilmlistDebugHelper.java +++ /dev/null @@ -1,111 +0,0 @@ -package de.mediathekview.mserver.base.utils; - -import java.util.ArrayList; -import java.util.Set; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import de.mediathekview.mlib.daten.Film; -import de.mediathekview.mlib.daten.Filmlist; -import de.mediathekview.mlib.daten.Resolution; -import de.mediathekview.mserver.crawler.kika.KikaApiCrawler; - -public class FilmlistDebugHelper { - private static final Logger LOG = LogManager.getLogger(FilmlistDebugHelper.class); - - - - public static Film getFilmFromSet(Set base, Film searchFilm) { - for (Film e : base) { - if (e.equals(searchFilm)) { - return e; - } - } - return null; - } - - public static void printFilmlistForSender(Filmlist list, String sender, boolean printFullDetails) { - list.getFilms().values().stream().forEach( e -> { - if (e.getSenderName().equalsIgnoreCase(sender)) { - if (printFullDetails) { - LOG.debug("{} {} {}", e.getTitel(), e.getThema(), e); - } else { - LOG.debug("{} {}", e.getTitel(), e.getThema()); - } - } - }); - } - - public static void printFilmlistForThema(Filmlist list, String thema, boolean printFullDetails) { - list.getFilms().values().stream().forEach( e -> { - if (e.getThema().equalsIgnoreCase(thema)) { - if (printFullDetails) { - LOG.debug("{} {} {} {}", e.getSenderName(), e.getTitel(), e.getThema(), e); - } else { - LOG.debug("{} {} {}", e.getSenderName(), e.getTitel(), e.getThema()); - } - } - }); - } - - - - - public static void compareFilmlist(Filmlist aFilmlist, Filmlist bFilmlist) { - ArrayList bFilms = new ArrayList<>(bFilmlist.getFilms().values()); - aFilmlist.getFilms().values().forEach( f -> { - if (bFilms.indexOf(f) == -1) { - LOG.info("Missing Film in source list"); - LOG.info(f.toString()); - } else { - Film expectedFilm = bFilms.get(bFilms.indexOf(f)); - compare(f, expectedFilm); - } - }); - ArrayList aFilms = new ArrayList<>(aFilmlist.getFilms().values()); - bFilms.forEach( f -> { - if (aFilms.indexOf(f) == -1) { - LOG.info("Missing Film in target list"); - LOG.info(f.toString()); - } - }); - } - - private static void compare(Film aFilm, Film bFilm) { - String error = ""; - if (!aFilm.getSenderName().equalsIgnoreCase(bFilm.getSenderName())) { - error = "Incorrect Sender"; - } else if (!aFilm.getTitel().equalsIgnoreCase(bFilm.getTitel())){ - error = "Incorrect Title"; - } else if (!aFilm.getThema().equalsIgnoreCase(bFilm.getThema())){ - error = "Incorrect Topic"; - } else if (!aFilm.getDuration().equals(bFilm.getDuration())){ - error = "Incorrect Duration"; - } else if (!aFilm.getBeschreibung().equalsIgnoreCase(bFilm.getBeschreibung())){ - error = "Incorrect Description"; - } else if (!aFilm.getWebsite().toString().equalsIgnoreCase(bFilm.getWebsite().toString())){ - error = "Incorrect website"; - } else if (!aFilm.getTime().equals(bFilm.getTime())){ - error = "Incorrect Time"; - } else if (!aFilm.getSubtitles().equals(bFilm.getSubtitles())){ - error = "Incorrect subtitle"; - } else if (bFilm.getUrl(Resolution.SMALL) != null && - !aFilm.getUrl(Resolution.SMALL).toString().equalsIgnoreCase(bFilm.getUrl(Resolution.SMALL).toString())) { - error = "URL SMALL"; - } else if (bFilm.getUrl(Resolution.NORMAL) != null && - !aFilm.getUrl(Resolution.NORMAL).toString().equalsIgnoreCase(bFilm.getUrl(Resolution.NORMAL).toString())) { - error = "URL NORMAL"; - } else if (bFilm.getUrl(Resolution.HD) != null && - !aFilm.getUrl(Resolution.HD).toString().equalsIgnoreCase(bFilm.getUrl(Resolution.HD).toString())) { - error = "URL HD"; - } - // - if (error != "") { - LOG.info(error); - LOG.info(aFilm.toString()); - LOG.info(bFilm.toString()); - } - } - -} diff --git a/src/main/java/de/mediathekview/mserver/crawler/ard/json/ArdMediaArrayToDownloadUrlsConverter.java b/src/main/java/de/mediathekview/mserver/crawler/ard/json/ArdMediaArrayToDownloadUrlsConverter.java index 70710a283..d7bd39ad1 100644 --- a/src/main/java/de/mediathekview/mserver/crawler/ard/json/ArdMediaArrayToDownloadUrlsConverter.java +++ b/src/main/java/de/mediathekview/mserver/crawler/ard/json/ArdMediaArrayToDownloadUrlsConverter.java @@ -145,8 +145,7 @@ private static Resolution getQualityForNumber(final int qualityIndicator) { case 1 -> Resolution.SMALL; case 3, 4 -> Resolution.HD; case 5 -> Resolution.UHD; - case 2 -> Resolution.NORMAL; - default -> Resolution.NORMAL; + case 2, default -> Resolution.NORMAL; }; } diff --git a/src/main/java/de/mediathekview/mserver/crawler/funk/tasks/NexxCloudSessionInitiationTask.java b/src/main/java/de/mediathekview/mserver/crawler/funk/tasks/NexxCloudSessionInitiationTask.java index 04e60f201..95fb98511 100644 --- a/src/main/java/de/mediathekview/mserver/crawler/funk/tasks/NexxCloudSessionInitiationTask.java +++ b/src/main/java/de/mediathekview/mserver/crawler/funk/tasks/NexxCloudSessionInitiationTask.java @@ -36,7 +36,7 @@ public NexxCloudSessionInitiationTask(final AbstractCrawler aCrawler) { @Override public Long call() { final Gson gson = createGson(); -/* + try(final Client client = createClient()) { final WebTarget target = client.target(FunkUrls.NEXX_CLOUD_SESSION_INIT.getAsString(crawler.getRuntimeConfig())); @@ -55,7 +55,7 @@ public Long call() { response.getStatus()); } } - }*/ + } return null; } diff --git a/src/test/java/de/mediathekview/mserver/crawler/CompareFilmlistsTest.java b/src/test/java/de/mediathekview/mserver/crawler/CompareFilmlistsTest.java deleted file mode 100644 index 0fd55c3bb..000000000 --- a/src/test/java/de/mediathekview/mserver/crawler/CompareFilmlistsTest.java +++ /dev/null @@ -1,148 +0,0 @@ -package de.mediathekview.mserver.crawler; - -import de.mediathekview.mlib.daten.Film; -import de.mediathekview.mlib.daten.Filmlist; -import de.mediathekview.mlib.daten.Resolution; -import de.mediathekview.mlib.filmlisten.reader.FilmlistOldFormatReader; -import de.mediathekview.mlib.filmlisten.writer.FilmlistOldFormatWriter; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.Test; - -import com.google.common.base.Objects; - -import static org.junit.jupiter.api.Assertions.assertTrue; - - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Optional; - - - -public class CompareFilmlistsTest { - private static final Logger LOG = LogManager.getLogger(CompareFilmlistsTest.class); - private int fullmatch = 0; - private int missingLeft = 0; - private int missingRight = 0; - private int diff = 0; - - - @Test - void readFilmlistOldFormatIncludingBrokenRecords() - throws IOException { - // - - if (false) { - return; - } - - String aList = "C:/Users/steph/git/MServer/target/filmlists/filmliste_old.json"; - String bList = "C:/Users/steph/git2/MServer/dist/filmlisten/filme.json"; - ClassLoader classLoader = getClass().getClassLoader(); - final Path aListPath = new File(aList).toPath(); - Optional aFilmlist = new FilmlistOldFormatReader().read(new FileInputStream(aListPath.toString())); - assertTrue(aFilmlist.isPresent()); - final Path bListPath = new File(bList).toPath(); - Optional bFilmlist = new FilmlistOldFormatReader().read(new FileInputStream(bListPath.toString())); - assertTrue(bFilmlist.isPresent()); - // - ArrayList bFilms = new ArrayList<>(bFilmlist.get().getFilms().values()); - aFilmlist.get().getFilms().values().forEach( f -> { - Film target = index(bFilms, f); - if (target != null) { - compare(f, target); - } - }); - aFilmlist.get().getFilms().values().forEach( f -> { - if (index(bFilms, f) == null) { - LOG.info("Missing Film in source list"); - LOG.info(f.toString()); - missingLeft++; - } - }); - ArrayList aFilms = new ArrayList<>(aFilmlist.get().getFilms().values()); - bFilms.forEach( f -> { - Film target = index(aFilms, f); - if (target == null) { - LOG.info("Missing Film in target list"); - LOG.info(f.toString()); - missingRight++; - } - }); - new FilmlistOldFormatWriter().write(aFilmlist.get(), Path.of("c:/tmp/aFilmlist.json")); - new FilmlistOldFormatWriter().write(bFilmlist.get(), Path.of("c:/tmp/bFilmlist.json")); - // - LOG.info("Matching: {} MissingLeft: {} MissingRight: {} Diff: {}", fullmatch, missingLeft, missingRight, diff); - } - - private void compare(Film aFilm, Film bFilm) { - String error = ""; - if (!aFilm.getSenderName().equalsIgnoreCase(bFilm.getSenderName())) { - error += "Incorrect Sender"; - } - if (!aFilm.getTitel().equalsIgnoreCase(bFilm.getTitel())){ - error += "Incorrect Title"; - } - if (!aFilm.getThema().equalsIgnoreCase(bFilm.getThema())){ - error += "Incorrect Topic"; - } - if (!aFilm.getDuration().equals(bFilm.getDuration())){ - error += "Incorrect Duration"; - } - if (!aFilm.getBeschreibung().equalsIgnoreCase(bFilm.getBeschreibung())) { - // new parser cuts out last char - if (aFilm.getBeschreibung().length() > 70 && bFilm.getBeschreibung().length() > 70 && - !aFilm.getBeschreibung().substring(1,aFilm.getBeschreibung().length()-19).equalsIgnoreCase(bFilm.getBeschreibung().substring(1,bFilm.getBeschreibung().length()-18))){ - error += "Incorrect Description"; - } else if (aFilm.getBeschreibung().length() > 20 && bFilm.getBeschreibung().length() > 20 && - !aFilm.getBeschreibung().substring(1,20).equalsIgnoreCase(bFilm.getBeschreibung().substring(1,20))){ - error += "Incorrect Description"; - } - } - if (!aFilm.getWebsite().toString().equalsIgnoreCase(bFilm.getWebsite().toString())){ - error += "Incorrect website"; - } - if (!aFilm.getTime().equals(bFilm.getTime())){ - error += "Incorrect Time"; - } - if (!aFilm.getSubtitles().equals(bFilm.getSubtitles())){ - error += "Incorrect subtitle"; - } - if (!Objects.equal(bFilm.getUrl(Resolution.SMALL), bFilm.getUrl(Resolution.SMALL))) { - error += "URL SMALL"; - } - if (!Objects.equal(bFilm.getUrl(Resolution.NORMAL), bFilm.getUrl(Resolution.NORMAL))) { - error += "URL NORMAL"; - } - if (!Objects.equal(bFilm.getUrl(Resolution.HD), bFilm.getUrl(Resolution.HD))) { - error += "URL HD"; - } - // - if (error != "") { - LOG.info(error); - LOG.info(aFilm.toString()); - LOG.info(bFilm.toString()); - diff++; - } else { - fullmatch++; - } - } - - private static Film index(ArrayList list, Film aFilm) { - for (Film e : list) { - if (e.getSenderName().equalsIgnoreCase(aFilm.getSenderName()) && - e.getTitel().equalsIgnoreCase(aFilm.getTitel()) && - e.getThema().equalsIgnoreCase(aFilm.getThema()) && - e.getTime().equals(aFilm.getTime())) { - return e; - } - } - return null; -} - -}