From ea73fab1d832c5e9b815042c6a6a61634125977e Mon Sep 17 00:00:00 2001 From: ulrich Date: Fri, 30 Apr 2021 16:03:25 +0000 Subject: [PATCH] ID3-Tag-Verarbeitung verbessert --- www/js/app.js | 5 ++--- src/de/uhilger/tango/api/ListFileHandler.java | 26 ++++++++++++++++++++------ README.md | 3 +++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5b3c56f..0fd4433 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,6 @@ [Mustache](http://mustache.github.io/) - "Logic-less templates." [RobotoRegular](https://fonts.google.com/specimen/Roboto) - Schriftart +## Lizenz + +Veröffentlicht unter den Bedingungen der [GNU Affero Genreal Public License](http://www.gnu.org/licenses/agpl-3.0) \ No newline at end of file diff --git a/src/de/uhilger/tango/api/ListFileHandler.java b/src/de/uhilger/tango/api/ListFileHandler.java index 8bde1fc..3aed9e0 100644 --- a/src/de/uhilger/tango/api/ListFileHandler.java +++ b/src/de/uhilger/tango/api/ListFileHandler.java @@ -39,6 +39,7 @@ import java.util.logging.Logger; import org.farng.mp3.MP3File; import org.farng.mp3.TagException; +import org.farng.mp3.id3.AbstractID3v2; import org.farng.mp3.id3.ID3v1; /** @@ -52,6 +53,8 @@ private static final String[] specialChars = {new String("\u00c4"), new String("\u00d6"), new String("\u00dc"), new String("\u00e4"), new String("\u00f6"), new String("\u00fc"), new String("\u00df")}; + + public static final String UNWANTED_PATTERN = "[^a-zA-Z_0-9 ]"; Map extMap = new HashMap(); @@ -123,7 +126,8 @@ } } //Collections.sort(list); - String json = escapeHtml(jsonWithCustomType(list, "Medialiste")); + String rawjson = jsonWithCustomType(list, "Medialiste"); + String json = escapeHtml(rawjson); logger.fine(json); Headers headers = e.getResponseHeaders(); @@ -163,12 +167,22 @@ try { MP3File mp3 = new MP3File(file); ID3v1 tag = mp3.getID3v1Tag(); - sf.setInterpret(tag.getArtist()); - String trackTitel = tag.getTitle(); - if(trackTitel != null && trackTitel.length() > 0) { - sf.setTitelAnzName(trackTitel); + if(tag == null) { + AbstractID3v2 tag2 = mp3.getID3v2Tag(); + sf.setInterpret(tag2.getLeadArtist().replaceAll(UNWANTED_PATTERN, "")); + String trackTitel = tag2.getSongTitle().replaceAll(UNWANTED_PATTERN, ""); + if(trackTitel != null && trackTitel.length() > 0) { + sf.setTitelAnzName(trackTitel); + } + sf.setAlbum(tag2.getAlbumTitle().replaceAll(UNWANTED_PATTERN, "")); + } else { + sf.setInterpret(tag.getArtist().replaceAll(UNWANTED_PATTERN, "")); + String trackTitel = tag.getTitle().replaceAll(UNWANTED_PATTERN, ""); + if(trackTitel != null && trackTitel.length() > 0) { + sf.setTitelAnzName(trackTitel); + } + sf.setAlbum(tag.getAlbumTitle().replaceAll(UNWANTED_PATTERN, "")); } - sf.setAlbum(tag.getAlbumTitle()); } catch (IOException ex) { Logger.getLogger(ListFileHandler.class.getName()).log(Level.SEVERE, null, ex); } catch (TagException ex) { diff --git a/www/js/app.js b/www/js/app.js index 8fbd573..38da416 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -712,15 +712,14 @@ self.http_call('DELETE', u, data, cb); }; - this.http_call = function (method, u, data, scallback) { + this.http_call = function (method, callurl, data, scallback) { var xhr = new XMLHttpRequest(); - var url = u; xhr.onreadystatechange = function () { if (this.readyState === 4 && this.status === 200) { scallback(this.responseText); } }; - xhr.open(method, url); + xhr.open(method, callurl); if (method === 'GET') { xhr.send(); } else if (method === 'POST' || method === 'PUT' || method === 'DELETE') { -- Gitblit v1.9.3