Skip to content

Commit

Permalink
fix unknown duration "Sek."
Browse files Browse the repository at this point in the history
  • Loading branch information
pidoubleyou committed Dec 3, 2023
1 parent 9e44db2 commit 5a91a39
Show file tree
Hide file tree
Showing 3 changed files with 288 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static Optional<Duration> parseDuration(final Document aDocument) {
}

final ChronoUnit unitValue = unit.get();
if (unitValue == ChronoUnit.MINUTES) {
if (unitValue == ChronoUnit.SECONDS || unitValue == ChronoUnit.MINUTES) {
return Optional.of(
Duration.ofMinutes(Long.parseLong(parts[0])).plusSeconds(Long.parseLong(parts[1])));
}
Expand All @@ -112,6 +112,9 @@ private static Optional<ChronoUnit> determineChronoUnit(final String aDuration)
if (aDuration.contains("Std.")) {
return Optional.of(ChronoUnit.HOURS);
}
if (aDuration.contains("Sek.")) {
return Optional.of(ChronoUnit.SECONDS);
}

return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
package de.mediathekview.mserver.crawler.orf.tasks;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;

import de.mediathekview.mlib.daten.Film;
import de.mediathekview.mlib.daten.GeoLocations;
import de.mediathekview.mlib.daten.Sender;
import de.mediathekview.mserver.base.webaccess.JsoupConnection;
import de.mediathekview.mserver.crawler.orf.OrfCrawler;
import de.mediathekview.mserver.testhelper.AssertFilm;
import de.mediathekview.mserver.testhelper.JsoupMock;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.io.IOException;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Collection;
import java.util.Set;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

@RunWith(Parameterized.class)
public class OrfFilmDetailTaskTest extends OrfFilmDetailTaskTestBase {
Expand Down Expand Up @@ -174,6 +173,24 @@ public static Collection<Object[]> data() {
"",
"",
new GeoLocations[] {GeoLocations.GEO_NONE}
},
{
"https://tvthek.orf.at/profile/Burgenland-heute-kompakt/13891025/Burgenland-heute-kompakt/14203644",
"/orf/orf_film_with_seconds.html",
"Burgenland heute kompakt",
"Burgenland heute kompakt",
"Burgenland heute kompakt",
LocalDateTime.of(2023, 12, 1, 16, 57, 0),
Duration.ofSeconds(49),
"",
"",
"https://apasfiis.sf.apa.at/ipad/cms-worldwide/2023-12-01_1657_tl_23_Burgenland-heut_____14203644__o__1338501503__s15520121_1__BLBHD_16570412P_16575304P_Q4A.mp4/playlist.m3u8",
"https://apasfiis.sf.apa.at/ipad/cms-worldwide/2023-12-01_1657_tl_23_Burgenland-heut_____14203644__o__1338501503__s15520121_1__BLBHD_16570412P_16575304P_Q6A.mp4/playlist.m3u8",
"https://apasfiis.sf.apa.at/ipad/cms-worldwide/2023-12-01_1657_tl_23_Burgenland-heut_____14203644__o__1338501503__s15520121_1__BLBHD_16570412P_16575304P_Q8C.mp4/playlist.m3u8",
"",
"",
"",
new GeoLocations[] {GeoLocations.GEO_NONE}
}
});
}
Expand Down
Loading

0 comments on commit 5a91a39

Please sign in to comment.