|
@@ -267,15 +267,185 @@ public class PLReader
|
|
|
|
|
|
return mergedLists;
|
|
return mergedLists;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
|
|
|
|
+ private static List<String[]> readListAlternativeNoexpandAux(String path,int rd)
|
|
|
|
+ {
|
|
|
|
+ List<String[]> retval = new ArrayList<>();
|
|
|
|
+ if(rd<0)//zählt runter um beliebigen startwert z erlauben :P
|
|
|
|
+ {
|
|
|
|
+ return retval;//leere hashmap :P
|
|
|
|
+ }
|
|
|
|
+ List<String[]> tempo = readListAlternativeAuxPrepare(path);
|
|
|
|
+ if(tempo!=null)
|
|
|
|
+ {
|
|
|
|
+ for (String[] elements : tempo)
|
|
|
|
+ {
|
|
|
|
+ String[] metadata=elements[2].substring(6).split("\\|");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
- public static HashMap<String,PlayListItem> readListAlternative(String path, int rd,int prioritybase)
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private static List<String[]> readListAlternativeAuxPrepare(String path)
|
|
{
|
|
{
|
|
String[] playListRaw = FileTK.fileload(path);//temporär ne bestimmte hardcoden
|
|
String[] playListRaw = FileTK.fileload(path);//temporär ne bestimmte hardcoden
|
|
|
|
+ ArrayList<String[]> tempo=new ArrayList<>();
|
|
|
|
+ if(playListRaw.length>=2 && playListRaw[0].equalsIgnoreCase("EXTM3U")&&playListRaw[1].equalsIgnoreCase("#IZPL"))
|
|
|
|
+ {
|
|
|
|
+ String[] buffer = new String[3]; //0 path; 1=extm3u,2=izpl-data
|
|
|
|
+ int cntr=0;
|
|
|
|
+ // erste zwo zeilen überspringen...
|
|
|
|
+ // dann datei ummodeln...
|
|
|
|
+ for (int i = 2; i < playListRaw.length; i++)
|
|
|
|
+ {
|
|
|
|
+ System.out.println(i);
|
|
|
|
+ String line = playListRaw[i];
|
|
|
|
+ if(cntr==0&&line.startsWith("#EXTINF:"))
|
|
|
|
+ {
|
|
|
|
+ buffer[1]=line;
|
|
|
|
+ cntr++;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if((cntr==1||cntr==0)&&line.startsWith("#IZPL:"))
|
|
|
|
+ {
|
|
|
|
+ buffer[2]=line;cntr++;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ cntr=0;
|
|
|
|
+ buffer[0]=line;
|
|
|
|
+ tempo.add(buffer);
|
|
|
|
+ buffer[0]="";
|
|
|
|
+ buffer[1]="";
|
|
|
|
+ buffer[2]="#IZPL:1|0";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ tempo=null;
|
|
|
|
+ }
|
|
|
|
+ return tempo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static HashMap<String,PlayListItem> readListAlternative(String path, int rd,int prioritybase)
|
|
|
|
+ {
|
|
|
|
+ HashMap<String,PlayListItem> retval = new HashMap<>();
|
|
|
|
+ if(rd<0)//zählt runter um beliebigen startwert z erlauben :P
|
|
|
|
+ {
|
|
|
|
+ return retval;//leere hashmap :P
|
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ List<String[]> tempo = readListAlternativeAuxPrepare(path);
|
|
|
|
+ if(tempo!=null)
|
|
|
|
+ {
|
|
|
|
+ //\\//\\//
|
|
|
|
+ //0 pfad; 1=extinf;2=izpl;
|
|
|
|
+ //verarbeiten.....
|
|
|
|
+ HashMap<Integer,ArrayList<String[]>> groupprep = new HashMap<>();
|
|
|
|
+ groupprep.put(0,new ArrayList<String[]>());
|
|
|
|
+ for (String[] elements : tempo)
|
|
|
|
+ {
|
|
|
|
+ String lfid=elements[0];
|
|
|
|
+ if(!lfid.substring(1,2).equals(":"))//absoluterPfad
|
|
|
|
+ {
|
|
|
|
+ lfid=FileTK.getFilePath(path)+"\\"+lfid;
|
|
|
|
+ }
|
|
|
|
+ elements[0]=lfid;
|
|
|
|
+ String[] metadata=elements[2].substring(6).split("\\|");
|
|
|
|
+ if(metadata[1].equalsIgnoreCase("include"))
|
|
|
|
+ {
|
|
|
|
+ System.out.println("Includebranch");
|
|
|
|
+ if(metadata[2].equalsIgnoreCase("EXPAND"))
|
|
|
|
+ {
|
|
|
|
+ HashMap<String,PlayListItem> recurseret = readListAlternative(elements[0], rd-1, Integer.valueOf(metadata[1]));//nätig in beiden fällen
|
|
|
|
+ Set<String> keys= recurseret.keySet();
|
|
|
|
+ for (String itemkey : keys)
|
|
|
|
+ {
|
|
|
|
+ PlayListItem pli = recurseret.get(itemkey);
|
|
|
|
+ if(pli instanceof SinglePlayListItem)//multiitems instapasthru
|
|
|
|
+ {
|
|
|
|
+ if(retval.containsKey(itemkey))
|
|
|
|
+ {
|
|
|
|
+ PlayListItem tpli = retval.get(itemkey);
|
|
|
|
+ tpli.setTargetPlaycount(tpli.getTargetPlaycount()+prioritybase*pli.getTargetPlaycount());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ retval.put(itemkey,pli);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ retval.put(itemkey,pli);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ MultiPlayListItem pli = new MultiPlayListItem(new String[]{}, new String[]{}, Integer.valueOf(metadata[1])*prioritybase);
|
|
|
|
+ //target der liste :P
|
|
|
|
+ List<String[]> listraw = readListAlternativeNoexpandAux(elements[0], rd-1);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //1,0=fefault :P
|
|
|
|
+ int gid = Integer.valueOf(metadata[1]);
|
|
|
|
+ if(gid>0)
|
|
|
|
+ {
|
|
|
|
+ if(!groupprep.containsKey(gid))
|
|
|
|
+ {
|
|
|
|
+ groupprep.put(gid,new ArrayList<String[]>());
|
|
|
|
+ }
|
|
|
|
+ List<String[]> groupcontent = groupprep.get(gid);
|
|
|
|
+ groupcontent.add(elements);//kein dupecheck da liste auch widerholungen enthalten kann; dupecheck nur bei einzel da dort aufsummiert wird :P
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if(retval.containsKey(elements[0]))//summieren...
|
|
|
|
+ {
|
|
|
|
+ PlayListItem it = retval.get(elements[0]);
|
|
|
|
+ int cpc = it.getTargetPlaycount();
|
|
|
|
+ it.setTargetPlaycount(cpc+(prioritybase*Integer.valueOf(metadata[1])));//zusammenaddieren da unter dem =en path nur das selbe lied liegen kann also de-dupe
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ PlayListItem it = new SinglePlayListItem(elements[0], elements[1], Integer.valueOf(metadata[1])*prioritybase);
|
|
|
|
+ retval.put(elements[0],it);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Set<Integer> keys = groupprep.keySet();
|
|
|
|
+ for (Integer i:keys)
|
|
|
|
+ { //HAXX
|
|
|
|
+ MultiPlayListItem pli = new MultiPlayListItem(new String[]{}, new String[]{}, prioritybase*Integer.valueOf(tempo.get(0)[2].substring(6).split("\\|")[1]));
|
|
|
|
+ tempo=groupprep.get(i);
|
|
|
|
+ for (String[] elem : tempo)
|
|
|
|
+ {
|
|
|
|
+ String lfid=elem[0];
|
|
|
|
+ if(!lfid.substring(1,2).equals(":"))//absoluterPfad
|
|
|
|
+ {
|
|
|
|
+ lfid=FileTK.getFilePath(path)+"\\"+lfid;
|
|
|
|
+ }
|
|
|
|
+ elem[0]=lfid;
|
|
|
|
+ pli.addTitle(elem[0], elem[1]);
|
|
|
|
+ }
|
|
|
|
+ retval.put(pli+"", pli);//multiItems sind nicht mit pfad referenziert...
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|