|
@@ -11,8 +11,14 @@ import de.nplusc.izc.iZpl.API.IZPLApi;
|
|
import de.nplusc.izc.iZpl.API.PlayListItem;
|
|
import de.nplusc.izc.iZpl.API.PlayListItem;
|
|
import de.nplusc.izc.iZpl.API.SinglePlayListItem;
|
|
import de.nplusc.izc.iZpl.API.SinglePlayListItem;
|
|
import de.nplusc.izc.tools.IOtools.FileTK;
|
|
import de.nplusc.izc.tools.IOtools.FileTK;
|
|
|
|
+import de.nplusc.izc.tools.WinToolz.Commands;
|
|
|
|
+import de.nplusc.izc.tools.baseTools.Detectors;
|
|
|
|
+import de.schlichtherle.truezip.file.TFile;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import javax.swing.JOptionPane;
|
|
import org.apache.logging.log4j.Level;
|
|
import org.apache.logging.log4j.Level;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
import org.apache.logging.log4j.Logger;
|
|
@@ -23,7 +29,7 @@ import org.apache.logging.log4j.Logger;
|
|
*/
|
|
*/
|
|
public class RadioManager implements FeaturePlugin
|
|
public class RadioManager implements FeaturePlugin
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ private HashMap<PlayListItem,String> ConvertLookupCache = new Hashmap<>();
|
|
private static final Logger l = LogManager.getLogger(RadioManager.class.getName());
|
|
private static final Logger l = LogManager.getLogger(RadioManager.class.getName());
|
|
|
|
|
|
|
|
|
|
@@ -35,6 +41,9 @@ public class RadioManager implements FeaturePlugin
|
|
SYMLINKED,COPY,INTERACTIVE;
|
|
SYMLINKED,COPY,INTERACTIVE;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static String jarschiv = RadioManager.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void parseParameter(String param)
|
|
public void parseParameter(String param)
|
|
{
|
|
{
|
|
@@ -88,6 +97,7 @@ public class RadioManager implements FeaturePlugin
|
|
String baseDir = param.substring((cstring[0]+":"+cstring[1]+":"+cstring[2]+":"+cstring[3]+
|
|
String baseDir = param.substring((cstring[0]+":"+cstring[1]+":"+cstring[2]+":"+cstring[3]+
|
|
cstring[4]+":"+cstring[5]+":"+cstring[6]+":"+cstring[7]+":"+cstring[8]+":").length()+1);
|
|
cstring[4]+":"+cstring[5]+":"+cstring[6]+":"+cstring[7]+":"+cstring[8]+":").length()+1);
|
|
l.trace(baseDir);
|
|
l.trace(baseDir);
|
|
|
|
+ baseDir=new File(baseDir).getAbsolutePath();//Hack der später wichtig wird
|
|
if(!(new File(baseDir).exists()))
|
|
if(!(new File(baseDir).exists()))
|
|
{
|
|
{
|
|
|
|
|
|
@@ -130,6 +140,18 @@ public class RadioManager implements FeaturePlugin
|
|
+ "\n"+"Amount of stations: {}"+"\n"
|
|
+ "\n"+"Amount of stations: {}"+"\n"
|
|
+ "Stations as file: {}"+"\n"+"Station name base: {}"
|
|
+ "Stations as file: {}"+"\n"+"Station name base: {}"
|
|
+ "\n"+"Base directory: {}", new Object[]{m, tracks, mergeTracks, stations, fileStations, stationBase, baseDir});
|
|
+ "\n"+"Base directory: {}", new Object[]{m, tracks, mergeTracks, stations, fileStations, stationBase, baseDir});
|
|
|
|
+
|
|
|
|
+ if(!checkConsent(baseDir, stationBase, stations))
|
|
|
|
+ {
|
|
|
|
+ l.warn("User abort on overwriting");
|
|
|
|
+ IZPLApi.quickQuitWithoutSaving();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!interner_ratzeputz(baseDir, stationBase, stations))
|
|
|
|
+ {
|
|
|
|
+ l.error("Unable to delete files");
|
|
|
|
+ System.exit(9263);
|
|
|
|
+ }
|
|
if(m==Mode.COPY)
|
|
if(m==Mode.COPY)
|
|
{
|
|
{
|
|
if(!mergeTracks)
|
|
if(!mergeTracks)
|
|
@@ -150,6 +172,32 @@ public class RadioManager implements FeaturePlugin
|
|
throw new UnsupportedOperationException("Dont do that!");
|
|
throw new UnsupportedOperationException("Dont do that!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if(m==Mode.SYMLINKED)
|
|
|
|
+ {
|
|
|
|
+ String mklink_bätsch=baseDir.substring(0,2)+"\n";//LW-buchstaben
|
|
|
|
+
|
|
|
|
+ for(int i=0;i<stations;i++)
|
|
|
|
+ {
|
|
|
|
+ mklink_bätsch+="cd \""+baseDir+File.separator+stationBase+"_"+i+"\"\n";
|
|
|
|
+ for(int j=0;j<tracks;j++)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ String pli = getPlayListItemPath();
|
|
|
|
+ File d = new File(baseDir+File.separator+stationBase+"_"+i+File.separator+FileTK.getFileName(pli));
|
|
|
|
+ d.getParentFile().mkdirs();
|
|
|
|
+ mklink_bätsch+="mklink \""+FileTK.getFileName(d.getPath()) +"\" \""+ pli+"\"\n";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ l.trace("\n-----------------------------------\n"+mklink_bätsch+"\n--------------------------------------\n");
|
|
|
|
+ String bätschpfad = System.getenv("temp")+File.separator+"izpl-symlink.bat";
|
|
|
|
+ l.trace(bätschpfad);
|
|
|
|
+ FileTK.writeFile(mklink_bätsch, bätschpfad);
|
|
|
|
+ Commands.executeAsAdministrator("cmd", "/c "+bätschpfad);
|
|
|
|
+ l.info("Batch started");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if(!GUIOpen)
|
|
if(!GUIOpen)
|
|
{
|
|
{
|
|
IZPLApi.quickQuitWithoutSaving();
|
|
IZPLApi.quickQuitWithoutSaving();
|
|
@@ -183,13 +231,58 @@ public class RadioManager implements FeaturePlugin
|
|
@Override
|
|
@Override
|
|
public void initializePlugin()
|
|
public void initializePlugin()
|
|
{
|
|
{
|
|
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
|
|
|
|
+ l.info("extracting GameRadio natives");
|
|
|
|
+ String[] osmetadata = Detectors.getSystemClassification();
|
|
|
|
+ l.info("Os-data:"+Arrays.toString(osmetadata));
|
|
|
|
+ if (osmetadata[0].equals("windows"))
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ File target = new File(IZPLApi.PLUGINPATH+File.separator+"GameRadioManager"+File.separator+"binaries"+File.separator+"ffmpeg.exe");
|
|
|
|
+ target.getParentFile().mkdirs();
|
|
|
|
+ if (!target.exists())
|
|
|
|
+ {
|
|
|
|
+ TFile zippo = new TFile(jarschiv + "\\binaries\\"+osmetadata[0]+"\\ffmpeg.exe");
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ zippo.cp(target);
|
|
|
|
+ TFile jarschcrap = new TFile(jarschiv + "\\binaries\\");
|
|
|
|
+ jarschcrap.rm_r();//removal of the embedded FFMPEG binary after init
|
|
|
|
+ }
|
|
|
|
+ catch (IOException ex)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException("ERROR! invalid OSType detected, embedded VLC doesnt work here");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void prepareUpgrade()
|
|
public void prepareUpgrade()
|
|
{
|
|
{
|
|
- //NO-OP
|
|
|
|
|
|
+ if(new TFile(jarschiv + "\\binaries").exists()) //nullroute falls reinit nicht möglich da files schon ausgepackt wurden
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ //killen der alten vlc-natives
|
|
|
|
+ TFile f = new TFile(IZPLApi.PLUGINPATH+File.separator+"GameRadioManager"+File.separator+"binaries");
|
|
|
|
+ if(f.exists())
|
|
|
|
+ f.rm_r();
|
|
|
|
+ }
|
|
|
|
+ catch (IOException ex)
|
|
|
|
+ {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ l.warn("");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private String getPlayListItemPath()
|
|
private String getPlayListItemPath()
|
|
@@ -202,5 +295,40 @@ public class RadioManager implements FeaturePlugin
|
|
return ((SinglePlayListItem) itm).getPath();
|
|
return ((SinglePlayListItem) itm).getPath();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private boolean checkConsent(String baseDir,String stationBase,int stationcount)
|
|
|
|
+ {
|
|
|
|
+ boolean existingDir=false;
|
|
|
|
+ for (int i = 0; i < stationcount; i++)
|
|
|
|
+ {
|
|
|
|
+ existingDir|= new File(baseDir+File.separator+stationBase+"_"+i).exists();
|
|
|
|
+ }
|
|
|
|
+ if(existingDir)
|
|
|
|
+ {
|
|
|
|
+ return JOptionPane.showConfirmDialog(null, "Delete existing stations", "Existing stations detected", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.YES_OPTION;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private boolean interner_ratzeputz(String baseDir,String stationBase,int stationcount)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < stationcount; i++)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ TFile kf = new TFile(baseDir+File.separator+stationBase+"_"+i);
|
|
|
|
+ if(kf.exists())
|
|
|
|
+ kf.rm_r();
|
|
|
|
+ }
|
|
|
|
+ catch (IOException ex)
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|