|
@@ -21,8 +21,8 @@ import de.nplusc.izc.iZpl.API.shared.InvalidPlayListFileException;
|
|
import de.nplusc.izc.iZpl.API.shared.MultiPlayListItem;
|
|
import de.nplusc.izc.iZpl.API.shared.MultiPlayListItem;
|
|
import de.nplusc.izc.iZpl.API.shared.PlayListFile;
|
|
import de.nplusc.izc.iZpl.API.shared.PlayListFile;
|
|
import de.nplusc.izc.iZpl.API.shared.PlayListItem;
|
|
import de.nplusc.izc.iZpl.API.shared.PlayListItem;
|
|
|
|
+import de.nplusc.izc.iZpl.API.shared.RawPlayListFile;
|
|
import de.nplusc.izc.iZpl.API.shared.SinglePlayListItem;
|
|
import de.nplusc.izc.iZpl.API.shared.SinglePlayListItem;
|
|
-//import de.nplusc.izc.iZpl.Main;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.BufferedReader;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileReader;
|
|
import java.io.FileReader;
|
|
@@ -45,7 +45,8 @@ public class PLFileIO
|
|
//Formatdefinition //basiert aufne verpackte #extm3u
|
|
//Formatdefinition //basiert aufne verpackte #extm3u
|
|
/*
|
|
/*
|
|
* #EXTM3U
|
|
* #EXTM3U
|
|
- * #iZPl
|
|
|
|
|
|
+ * #IZPL
|
|
|
|
+ * #IZPH:Fieldname|value
|
|
* #EXTINFO.......//Die VLC-Daten
|
|
* #EXTINFO.......//Die VLC-Daten
|
|
* #IZPL:PrioMultiplier|GroupID (IDS !=0 sind Verbunden. 0er immer einzeln)
|
|
* #IZPL:PrioMultiplier|GroupID (IDS !=0 sind Verbunden. 0er immer einzeln)
|
|
* /Pfad/zu/File1.mp3
|
|
* /Pfad/zu/File1.mp3
|
|
@@ -59,12 +60,13 @@ public class PLFileIO
|
|
|
|
|
|
//private static Yaml y = new Yaml();
|
|
//private static Yaml y = new Yaml();
|
|
private static final Logger l = LogManager.getLogger();
|
|
private static final Logger l = LogManager.getLogger();
|
|
- public static List<SinglePlayListItem> readSingleList(String path) throws InvalidPlayListFileException
|
|
|
|
|
|
+ public static RawPlayListFile readSingleList(String path) throws InvalidPlayListFileException
|
|
{
|
|
{
|
|
String plbd = new File(path).getParent()+File.separator;
|
|
String plbd = new File(path).getParent()+File.separator;
|
|
l.trace("Location:{}",new File(path).getAbsolutePath());
|
|
l.trace("Location:{}",new File(path).getAbsolutePath());
|
|
try
|
|
try
|
|
{
|
|
{
|
|
|
|
+ String rootDir="";
|
|
boolean syntaxError=false;
|
|
boolean syntaxError=false;
|
|
FileReader fra = new FileReader(path);
|
|
FileReader fra = new FileReader(path);
|
|
BufferedReader fr = new BufferedReader(fra);
|
|
BufferedReader fr = new BufferedReader(fra);
|
|
@@ -72,15 +74,40 @@ public class PLFileIO
|
|
if(!(fr.readLine().equalsIgnoreCase("#EXTM3U")))
|
|
if(!(fr.readLine().equalsIgnoreCase("#EXTM3U")))
|
|
{
|
|
{
|
|
l.error("Not a valid izpl or M3u-file");
|
|
l.error("Not a valid izpl or M3u-file");
|
|
- return new ArrayList<>();
|
|
|
|
|
|
+ return new RawPlayListFile("", new ArrayList<SinglePlayListItem>());
|
|
}
|
|
}
|
|
- if(!fr.readLine().startsWith("#IZPL"))
|
|
|
|
|
|
+ String ln = fr.readLine();
|
|
|
|
+ int lne=3;
|
|
|
|
+ if(!ln.startsWith("#IZPL"))
|
|
{
|
|
{
|
|
l.info("plain M3u detected");
|
|
l.info("plain M3u detected");
|
|
|
|
+ lne=2;
|
|
}
|
|
}
|
|
- int lne=3;
|
|
|
|
|
|
+ else//IZPL header processing
|
|
|
|
+ {
|
|
|
|
+ ln=fr.readLine();
|
|
|
|
+ while(ln!=null&&(ln.startsWith("#IZPH")||ln.trim().equals("")))
|
|
|
|
+ {
|
|
|
|
+ if(!ln.trim().equals(""))
|
|
|
|
+ {
|
|
|
|
+ String section = ln.split(":")[1];
|
|
|
|
+ section=section.toLowerCase();
|
|
|
|
+ switch(section)
|
|
|
|
+ {
|
|
|
|
+ case "basedir":
|
|
|
|
+ rootDir=section.substring(section.indexOf("|"));
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ l.info("Unknown Header field ({}) detected at line: {}",section,lne);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ lne++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
ArrayList<SinglePlayListItem> returndata = new ArrayList<>();
|
|
ArrayList<SinglePlayListItem> returndata = new ArrayList<>();
|
|
- String ln = fr.readLine();
|
|
|
|
|
|
+
|
|
boolean extinf=false;
|
|
boolean extinf=false;
|
|
SinglePlayListItem itm = new SinglePlayListItem();
|
|
SinglePlayListItem itm = new SinglePlayListItem();
|
|
while(ln!=null)
|
|
while(ln!=null)
|
|
@@ -213,11 +240,11 @@ public class PLFileIO
|
|
throw new InvalidPlayListFileException();
|
|
throw new InvalidPlayListFileException();
|
|
}
|
|
}
|
|
fr.close();
|
|
fr.close();
|
|
- return returndata;
|
|
|
|
|
|
+ return new RawPlayListFile(rootDir,returndata);
|
|
}
|
|
}
|
|
catch (IOException ex)
|
|
catch (IOException ex)
|
|
{
|
|
{
|
|
- return new ArrayList<>();
|
|
|
|
|
|
+ return new RawPlayListFile("", new ArrayList<SinglePlayListItem>());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -233,7 +260,7 @@ public class PLFileIO
|
|
HashMap<Integer,MultiPlayListItem> groups = new HashMap<>();
|
|
HashMap<Integer,MultiPlayListItem> groups = new HashMap<>();
|
|
List<PlayListItem> result = new ArrayList<>();
|
|
List<PlayListItem> result = new ArrayList<>();
|
|
|
|
|
|
- List<SinglePlayListItem> rootList = readSingleList(path);
|
|
|
|
|
|
+ List<SinglePlayListItem> rootList = readSingleList(path).getData();
|
|
try{
|
|
try{
|
|
Class yaml = Class.forName("org.yaml.snakeyaml.Yaml");
|
|
Class yaml = Class.forName("org.yaml.snakeyaml.Yaml");
|
|
Object y = yaml.getConstructor().newInstance();
|
|
Object y = yaml.getConstructor().newInstance();
|
|
@@ -295,7 +322,7 @@ public class PLFileIO
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
rd--;
|
|
rd--;
|
|
- List<SinglePlayListItem> raw = readSingleList(path);
|
|
|
|
|
|
+ List<SinglePlayListItem> raw = readSingleList(path).getData();
|
|
for (SinglePlayListItem spi : raw)
|
|
for (SinglePlayListItem spi : raw)
|
|
{
|
|
{
|
|
if(spi.isIncludeElement())
|
|
if(spi.isIncludeElement())
|