|
@@ -74,7 +74,7 @@ public class PLFileIO
|
|
|
l.trace("Parsing Folder {}.",path);
|
|
|
File f = new File(path);
|
|
|
File[] elements = f.listFiles();
|
|
|
- List<PlayListItem> virtualList = new LinkedList<>();
|
|
|
+ List<SinglePlayListItem> virtualList = new LinkedList<>();
|
|
|
for (File element : elements)
|
|
|
{
|
|
|
if(element.isDirectory())
|
|
@@ -87,24 +87,9 @@ public class PLFileIO
|
|
|
{
|
|
|
if(element.isFile()&&!element.isHidden())
|
|
|
{
|
|
|
-
|
|
|
- //TODO subfunction!
|
|
|
try
|
|
|
{
|
|
|
- //itm.setTitle("#EXTINF,0,"+new File(ln).getName());
|
|
|
- AudioFile file = AudioFileIO.read(element);
|
|
|
- int length = file.getAudioHeader().getTrackLength();
|
|
|
- Tag tag = file.getTag();
|
|
|
- String metadata = "#EXTINF,length,";
|
|
|
- if(tag!=null)
|
|
|
- {
|
|
|
- metadata+= tag.getFirst(FieldKey.ARTIST)+" - "+tag.getFirst(FieldKey.TITLE);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- metadata+=element.getName();
|
|
|
- }
|
|
|
- SinglePlayListItem item = new SinglePlayListItem(element.getPath(), metadata, length);
|
|
|
+ SinglePlayListItem item = new SinglePlayListItem(element.getPath(), getExtM3uLine(element.getPath()), 1);
|
|
|
l.trace("Added File ({})to the list.",element.getPath());
|
|
|
virtualList.add(item);
|
|
|
} catch (CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException ex)
|
|
@@ -120,7 +105,7 @@ public class PLFileIO
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- return null;
|
|
|
+ return new RawPlayListFile(path, virtualList);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -129,6 +114,10 @@ public class PLFileIO
|
|
|
private static final Logger l = LogManager.getLogger();
|
|
|
public static RawPlayListFile readSingleList(String path) throws InvalidPlayListFileException
|
|
|
{
|
|
|
+ if(new File(path).isDirectory())
|
|
|
+ {
|
|
|
+ return readFolderAsVirtualPlayListFile(path);
|
|
|
+ }
|
|
|
String plbd = new File(path).getParent()+File.separator;
|
|
|
l.trace("Location:{}",new File(path).getAbsolutePath());
|
|
|
try
|
|
@@ -299,7 +288,14 @@ public class PLFileIO
|
|
|
{
|
|
|
if(!extinf)
|
|
|
{
|
|
|
- itm.setTitle("#EXTINF,0,"+new File(ln).getName()); //TODO ID3parse
|
|
|
+ try
|
|
|
+ {
|
|
|
+ itm.setTitle(getExtM3uLine(ln));
|
|
|
+ } catch (CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException ex)
|
|
|
+ {
|
|
|
+ l.warn("Skipped invalid File ({})",ln);
|
|
|
+ }
|
|
|
+ itm.setTitle("#EXTINF:0,"+new File(ln).getName()); //TODO ID3parse
|
|
|
}
|
|
|
if(!(ln.substring(1).startsWith(":")||ln.startsWith(File.separator)))
|
|
|
{
|
|
@@ -524,11 +520,28 @@ public class PLFileIO
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ private static String getExtM3uLine(String path) throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException
|
|
|
+ {
|
|
|
+ File element = new File(path);
|
|
|
+ //itm.setTitle("#EXTINF,0,"+new File(ln).getName());
|
|
|
+ AudioFile file = AudioFileIO.read(element);
|
|
|
+ int length = file.getAudioHeader().getTrackLength();
|
|
|
+ Tag tag = file.getTag();
|
|
|
+ String metadata = "#EXTINF:"+length+",";
|
|
|
+ if(tag!=null)
|
|
|
+ {
|
|
|
+ metadata+= tag.getFirst(FieldKey.ARTIST)+" - "+tag.getFirst(FieldKey.TITLE);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ metadata+=element.getName();
|
|
|
+ }
|
|
|
+ return metadata;
|
|
|
+ }
|
|
|
|
|
|
private PLFileIO()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|
|
|
+
|