From f70acbb491c6421623cca57292a75f1820efad4d Mon Sep 17 00:00:00 2001
From: ulrich
Date: Thu, 06 May 2021 16:41:59 +0000
Subject: [PATCH] Nicht erforderliche globale Variablen entfernt
---
src/de/uhilger/tango/api/ListFileHandler.java | 36 ++++++++++++++++++++++++++----------
1 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/src/de/uhilger/tango/api/ListFileHandler.java b/src/de/uhilger/tango/api/ListFileHandler.java
index 8bde1fc..12c44db 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;
/**
@@ -53,9 +54,13 @@
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();
- public ListFileHandler(String absoluteDirectoryPathAndName) {
+ private String conf;
+
+ public ListFileHandler(String absoluteDirectoryPathAndName, String conf) {
super(absoluteDirectoryPathAndName);
/*
Ermittlung von Dateifiltern.
@@ -63,9 +68,9 @@
jeweils als Dateierweiterungen mit Komma getrennt
z.B. "mp4,m4v"
*/
- FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF)));
- initMap(fs, App.getRs(App.RB_AUDIOEXTS), StorageFile.TYP_AUDIO);
- initMap(fs, App.getRs(App.RB_VIDEOEXTS), StorageFile.TYP_VIDEO);
+ FileStorage fs = new FileStorage(conf);
+ initMap(fs, getResString(App.RB_AUDIOEXTS), StorageFile.TYP_AUDIO);
+ initMap(fs, getResString(App.RB_VIDEOEXTS), StorageFile.TYP_VIDEO);
}
private void initMap(Storage s, String key, String typ) {
@@ -123,7 +128,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 +169,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) {
--
Gitblit v1.9.3