Skip to content

Commit

Permalink
Merge Konflikt behoben bei merge von fix unicode encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
alex1702 committed Nov 23, 2021
2 parents cd77047 + 285cd06 commit ab544f9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/main/java/de/mediathekview/mlib/daten/DatenFilm.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
package de.mediathekview.mlib.daten;

import java.text.Normalizer;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import org.apache.commons.lang3.time.FastDateFormat;
Expand Down Expand Up @@ -132,14 +134,14 @@ public DatenFilm(String ssender, String tthema, String filmWebsite, String ttite
long dauerSekunden, String description) {
// da werden die gefundenen Filme beim Absuchen der Senderwebsites erstellt, und nur die!!
arr[FILM_SENDER] = ssender;
arr[FILM_THEMA] = tthema.isEmpty() ? ssender : cleanWhitespaces(tthema.trim());
arr[FILM_THEMA] = tthema.isEmpty() ? ssender : normalize(cleanWhitespaces(tthema.trim()));
setTitle(ttitel.isEmpty() ? tthema : ttitel.trim());
arr[FILM_URL] = uurl;
arr[FILM_URL_RTMP] = uurlRtmp;
arr[FILM_WEBSEITE] = filmWebsite;
checkDatum(datum, arr[FILM_SENDER] + ' ' + arr[FILM_THEMA] + ' ' + arr[FILM_TITEL]);
checkZeit(arr[FILM_DATUM], zeit, arr[FILM_SENDER] + ' ' + arr[FILM_THEMA] + ' ' + arr[FILM_TITEL]);
arr[FILM_BESCHREIBUNG] = cleanDescription(description);
arr[FILM_BESCHREIBUNG] = normalize(cleanDescription(description));

// Filmlänge
checkFilmDauer(dauerSekunden);
Expand All @@ -150,7 +152,7 @@ private void setTitle(String title) {
title = title.substring(0, title.indexOf(COPYRIGHT_CHAR_HTML));
title = title.trim();
}
arr[FILM_TITEL] = cleanWhitespaces(title);
arr[FILM_TITEL] = normalize(cleanWhitespaces(title));
}

/**
Expand All @@ -162,6 +164,15 @@ public void setFileSize() {
}
}

private static String normalize(String s) {
// some websites uses NFD normalization instead of NFC => normalize
if (s != null) {
return Normalizer.normalize(s, Normalizer.Form.NFC);
}

return null;
}

public static String cleanWhitespaces(String text) {
return text.replaceAll("[\\t\\n\\x0B\\f\\r]", "")
.replace("\u00a0", " ") // repalce no-break-space with space
Expand Down

0 comments on commit ab544f9

Please sign in to comment.