Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arte fixes #826

Merged
merged 3 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove arte extrait-urls
  • Loading branch information
pidoubleyou committed May 9, 2022
commit 8345220c053ece69964662db19ac1dfa9b5834b7
17 changes: 15 additions & 2 deletions src/main/java/mServer/crawler/AddToFilmlist.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public void run() {
if (response.isSuccessful()) {
long respLength = determineContentLength(response);

if (isRelevantContentType(response) && !orfRemovedVideo(film, response) &&
if (isRelevantContentType(response) && !removedVideo(film, response) &&
// ignore file length of m3u8-files because it is always too small
(isM3u8File(url) || respLength > MIN_SIZE_ADD_OLD)) {
addOld(film);
Expand All @@ -320,7 +320,7 @@ public void run() {
if (Long.parseLong(film.arr[DatenFilm.FILM_GROESSE]) > MIN_SIZE_ADD_OLD) {
Request request = createOnlineCheckRequest(url);
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful() && isRelevantContentType(response) && !orfRemovedVideo(film, response)) {
if (response.isSuccessful() && isRelevantContentType(response) && !removedVideo(film, response)) {
addOld(film);
} else {
Log.sysLog("film removed: code: " + response.code() + ": " + url);
Expand All @@ -335,6 +335,19 @@ public void run() {
threadCounter.decrementAndGet();
}

private boolean removedVideo(DatenFilm film, Response response) {
return orfRemovedVideo(film, response) || arteRemovedVideo(film, response);
}

private boolean arteRemovedVideo(DatenFilm film, Response response) {
if (film.arr[DatenFilm.FILM_SENDER].equals(Const.ARTE_DE)) {
String path = response.request().url().encodedPath();
return path.contains("_EXTRAIT_");
}

return false;
}

private boolean orfRemovedVideo(DatenFilm film, Response response) {
if (film.arr[DatenFilm.FILM_SENDER].equals(Const.ORF)) {
String path = response.request().url().encodedPath();
Expand Down
12 changes: 12 additions & 0 deletions src/test/developTest/java/mServer/crawler/AddToFilmlistTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class AddToFilmlistTest {
private static final String FILM_NAME_ONLINE_M3U8 = "onlinefilm.m3u8";
private static final String FILM_NAME_OFFLINE_M3U8 = "offlinefilm.m3u8";
private static final String FILM_NAME_OFFLINE_BUT_HTML_RESPONSE = "ardofflinefilm.mp4";
private static final String FILM_NAME_ARTE_EXTRAIT = "/am/ptweb/106000/106200/106287-011-A_EXT_EQ_1_VA-STA_06707579_MP4-1500_AMM-PTWEB_EXTRAIT_1mQDhYFo2y.mp4";
private static final String FILM_NAME_ORF_JUGENDSCHUTZ = "ipad/gp/Jugendschutz0600b2000_Q8C.mp4/playlist.m3u8";
private static final String FILM_TOPIC1 = "Topic 1";
private static final String FILM_TOPIC2 = "Topic 2";
Expand All @@ -53,6 +54,7 @@ public MockResponse dispatch(RecordedRequest request) throws InterruptedExceptio
switch (request.getPath()) {
case "/" + FILM_NAME_ONLINE:
case "/" + FILM_NAME_ONLINE2:
case "/" + FILM_NAME_ARTE_EXTRAIT:
return new MockResponse()
.setResponseCode(200);
case "/" + FILM_NAME_OFFLINE_BUT_HTML_RESPONSE:
Expand Down Expand Up @@ -311,6 +313,16 @@ public void testNotAddOrfGeoBlockOffline() {
assertThat(list.size(), equalTo(2));
}

@Test
public void testNotAddArteExtraits() {
listToAdd.add(createTestFilm(Const.ARTE_DE, FILM_TOPIC1, FILM_TITLE1, FILM_NAME_ARTE_EXTRAIT));

AddToFilmlist target = new AddToFilmlist(list, listToAdd);
target.addOldList();

assertThat(list.size(), equalTo(2));
}

@Test
public void testRefreshArdWebsite() {
final DatenFilm testFilmUpdated = createTestFilm(Const.ARD, "Tatort", "Test Tatort", FILM_NAME_ONLINE);
Expand Down