From 1c32320e2ed6c0e4353e016f179e474a6ef25e64 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Thu, 29 Apr 2021 15:54:33 +0000
Subject: [PATCH] Livestreams aus Medialiste entfernt

---
 src/de/uhilger/tango/api/ListFileHandler.java |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/de/uhilger/tango/api/ListFileHandler.java b/src/de/uhilger/tango/api/ListFileHandler.java
index ad074e3..8bde1fc 100644
--- a/src/de/uhilger/tango/api/ListFileHandler.java
+++ b/src/de/uhilger/tango/api/ListFileHandler.java
@@ -26,7 +26,6 @@
 import de.uhilger.tango.store.FileStorage;
 import de.uhilger.tango.store.Storage;
 import de.uhilger.tango.store.StorageFile;
-import de.uhilger.tango.store.Track;
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
@@ -38,6 +37,9 @@
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.farng.mp3.MP3File;
+import org.farng.mp3.TagException;
+import org.farng.mp3.id3.ID3v1;
 
 /**
  *
@@ -112,7 +114,7 @@
             Object o = extMap.get(ext);
             if(o instanceof String) {
               sf.setTyp(o.toString());
-              getTrack(file, sf);
+              getMetadata(file, sf);
             } else {
               sf.setTyp(StorageFile.TYP_FILE);
             }
@@ -156,15 +158,22 @@
     return text;
   }
   
-  private void getTrack(File file, StorageFile sf) {
+  private void getMetadata(File file, StorageFile sf) {
     if(sf.getTyp().equalsIgnoreCase(StorageFile.TYP_AUDIO)) {
-      Track track = new Track(file);
-      sf.setInterpret(track.getArtist());
-      String trackTitel = track.getTitle();
-      if(trackTitel != null && trackTitel.length() > 0) {
-        sf.setTitelAnzName(trackTitel);
+      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);
+        }
+        sf.setAlbum(tag.getAlbumTitle());
+      } catch (IOException ex) {
+        Logger.getLogger(ListFileHandler.class.getName()).log(Level.SEVERE, null, ex);
+      } catch (TagException ex) {
+        Logger.getLogger(ListFileHandler.class.getName()).log(Level.SEVERE, null, ex);
       }
-      sf.setAlbum(track.getAlbum());
     }
   }
   

--
Gitblit v1.9.3