|
@@ -1,409 +1,430 @@
|
|
|
-/*
|
|
|
- * Copyright (C) 2015 iZc
|
|
|
- *
|
|
|
- * This program is free software: you can redistribute it and/or modify
|
|
|
- * it under the terms of the GNU General Public License as published by
|
|
|
- * the Free Software Foundation, either version 3 of the License, or
|
|
|
- * (at your option) any later version.
|
|
|
- *
|
|
|
- * This program is distributed in the hope that it will be useful,
|
|
|
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
- * GNU General Public License for more details.
|
|
|
- *
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
- */
|
|
|
-
|
|
|
-package de.nplusc.izc.Utilities.WPCMgr;
|
|
|
-
|
|
|
-import de.nplusc.izc.tools.IOtools.FileTK;
|
|
|
-import de.nplusc.izc.tools.baseTools.Tools;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.List;
|
|
|
-import org.yaml.snakeyaml.DumperOptions;
|
|
|
-import org.yaml.snakeyaml.Yaml;
|
|
|
-
|
|
|
-/**
|
|
|
- *
|
|
|
- * @author LH
|
|
|
- */
|
|
|
-public class Synchronizer
|
|
|
-{
|
|
|
- public static void main(String[] args)
|
|
|
- {
|
|
|
- String path = "";
|
|
|
- String res = "";
|
|
|
- if(args.length>1)
|
|
|
- {
|
|
|
- path = args[0];
|
|
|
- res = args[1];
|
|
|
- }
|
|
|
- //DEBUG
|
|
|
- //path="T:\\wpc";
|
|
|
- //res="1920x1080";
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- folderOptimize(path);
|
|
|
- LinkedHashMap<String,Object> data = (LinkedHashMap<String,Object>) new Yaml().load(new FileInputStream(path+"\\00_meta\\state.yml"));
|
|
|
- if(data.get("HEAD")==null)
|
|
|
- {
|
|
|
- initPipeLine(path, res);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- updatePipeLine(path, res);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (FileNotFoundException ex)
|
|
|
- {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public static void initPipeLine(String path,String res)
|
|
|
- {
|
|
|
- String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/path,true);
|
|
|
- final int pid[] = new int[]{0};
|
|
|
- List<String[]> cmdQueue = new ArrayList<>();
|
|
|
- List<String> resultFiles = new ArrayList<>();
|
|
|
- List<String> packagesInitialized = new ArrayList<>();
|
|
|
- Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(path+"\\" + t).isDirectory()).forEach(t ->
|
|
|
- {
|
|
|
- packagesInitialized.add(t);
|
|
|
- Object[] rv = processPackage(/*args[0]+*/path+"\\" + t, pid[0]++, res);
|
|
|
- cmdQueue.addAll((List<String[]>) rv[0]);
|
|
|
- resultFiles.addAll((List<String>) rv[1]);
|
|
|
- });
|
|
|
- DumperOptions yamlOptions = new DumperOptions();
|
|
|
- yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
|
|
- Yaml y = new Yaml(yamlOptions);
|
|
|
-
|
|
|
- //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
|
|
|
-
|
|
|
- //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
|
|
|
- final int length = cmdQueue.size();
|
|
|
- cmdQueue.forEach(x ->
|
|
|
- {
|
|
|
- Tools.runCmdWithPassthru(null, x);
|
|
|
- System.out.println("\rVerarbeitet: "+(++pos)+"/"+length);
|
|
|
- });
|
|
|
- System.out.println("\nFertigstellen....");
|
|
|
-
|
|
|
-
|
|
|
- pos=0;
|
|
|
- try
|
|
|
- {
|
|
|
- LinkedHashMap<String,Object> data = (LinkedHashMap<String,Object>) y.load(new FileInputStream(path+"\\00_meta\\state.yml"));
|
|
|
- String targetDir = (String) data.get("Outdir");
|
|
|
- resultFiles.forEach(entry ->
|
|
|
- {
|
|
|
- String fn = FileTK.getFileName(entry);
|
|
|
- FileTK.kopierpaste(new File(entry),new File(targetDir+"\\"+fn));
|
|
|
- pos++;
|
|
|
- if(pos%100==0)
|
|
|
- {
|
|
|
- System.out.print(pos+" Dateien kopiert");
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- System.out.print(pos+" Dateien kopiert");
|
|
|
- System.out.println("\nFertig....");
|
|
|
- data.put("HEAD", packagesInitialized);
|
|
|
- String o = y.dump(data);
|
|
|
- FileTK.writeFile(o, path+"\\00_meta\\state.yml");
|
|
|
- }
|
|
|
-
|
|
|
- catch (FileNotFoundException ex)
|
|
|
- {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
- System.exit(0);
|
|
|
- }
|
|
|
-
|
|
|
- private static int pos;
|
|
|
- public static void updatePipeLine(String path,String res)
|
|
|
- {
|
|
|
- DumperOptions yamlOptions = new DumperOptions();
|
|
|
- yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
|
|
- Yaml y = new Yaml(yamlOptions);
|
|
|
- LinkedHashMap<String,Object> data = null;
|
|
|
- try
|
|
|
- {
|
|
|
- data = (LinkedHashMap<String,Object>) y.load(new FileInputStream(path+"\\00_meta\\state.yml"));
|
|
|
- }
|
|
|
- catch(IOException lm)
|
|
|
- {
|
|
|
- }
|
|
|
- if(data==null)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/path,true);
|
|
|
- List<String[]> cmdQueue = new ArrayList<>();
|
|
|
- List<String> resultFiles = new ArrayList<>();
|
|
|
- List<String> packagesInitialized = (List<String>) data.get("HEAD");
|
|
|
- Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(path+"\\" + t).isDirectory()).forEach(t ->
|
|
|
- {
|
|
|
- if(!packagesInitialized.contains(t)&&FileTK.getDirectoryContent(path+"\\" + t+"\\proc").length>0) //package initialisiert sich erst wenn mindestens ein WP in proc
|
|
|
- {
|
|
|
- packagesInitialized.add(t); //vv-- highest IDX of package list aka current -> results in counter continuity
|
|
|
- Object[] rv = processPackage(/*args[0]+*/path+"\\" + t, packagesInitialized.size()-1, res);
|
|
|
- cmdQueue.addAll((List<String[]>) rv[0]);
|
|
|
- resultFiles.addAll((List<String>) rv[1]);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
|
|
|
- final int length = cmdQueue.size();
|
|
|
- cmdQueue.forEach(x ->
|
|
|
- {
|
|
|
- Tools.runCmdWithPassthru(null, x);
|
|
|
- System.out.println("\rVerarbeitet: "+(++pos)+"/"+length);
|
|
|
- });
|
|
|
- System.out.println("\nFertigstellen....");
|
|
|
-
|
|
|
- pos=0;
|
|
|
-
|
|
|
- String targetDir = (String) data.get("Outdir");
|
|
|
- resultFiles.forEach(entry ->
|
|
|
- {
|
|
|
- String fn = FileTK.getFileName(entry);
|
|
|
- FileTK.kopierpaste(new File(entry),new File(targetDir+"\\"+fn));
|
|
|
- pos++;
|
|
|
- if(pos%100==0)
|
|
|
- {
|
|
|
- System.out.print(pos+" Dateien kopiert");
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- data.put("HEAD", packagesInitialized);
|
|
|
- String o = y.dump(data);
|
|
|
- FileTK.writeFile(o, path+"\\00_meta\\state.yml");
|
|
|
- System.out.print(pos+" Dateien kopiert");
|
|
|
- System.out.println("\nFertig....");
|
|
|
- System.exit(0);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public static Object[] processPackage(String path,int packID,String res)
|
|
|
- {
|
|
|
- /*
|
|
|
- if(false)
|
|
|
- {
|
|
|
- System.out.println(packID+"|"+path);
|
|
|
- return;
|
|
|
- }*/
|
|
|
- System.out.println(path);
|
|
|
- FileTK.verzeichnisKillen(new File(path+"\\p"));
|
|
|
- new File(path+"\\p\\b\\").mkdirs();
|
|
|
- String[] availablePackagesNormal = FileTK.getDirectoryContent(path+"\\proc",true);
|
|
|
- String[] availablePackagesNoResize = FileTK.getDirectoryContent(path+"\\k-i-p",true);
|
|
|
- String[] availablePackagesBFrames = FileTK.getDirectoryContent(path+"\\b-frames",true);
|
|
|
-
|
|
|
- int c1 = availablePackagesNormal==null?0:availablePackagesNormal.length;
|
|
|
- int c2 = availablePackagesNoResize==null?0:availablePackagesNoResize.length;
|
|
|
- //System.out.println(c1+"|"+c2+"||"+(c1+c2));
|
|
|
- String[][] mergedList = new String[c1+c2][2];
|
|
|
- for (int i = 0; i < c1 ; i++)
|
|
|
- {
|
|
|
- String pth = availablePackagesNormal[i];
|
|
|
- String dst = "proc";
|
|
|
-
|
|
|
- String fex = FileTK.getFileExt(pth);
|
|
|
- if(fex!=null&&fex.equals("loc"))
|
|
|
- {
|
|
|
- dst ="src";
|
|
|
- pth=pth.substring(0, pth.length()-4);
|
|
|
- }
|
|
|
- mergedList[i][0] = pth;
|
|
|
- mergedList[i][1] = dst;
|
|
|
- }
|
|
|
- for (int i = 0; i < c2; i++)
|
|
|
- {
|
|
|
- String pth = availablePackagesNoResize[i];
|
|
|
- String dst = "k-i-p";
|
|
|
-
|
|
|
- String fex = FileTK.getFileExt(pth);
|
|
|
- if(fex!=null&&fex.equals("loc"))
|
|
|
- {
|
|
|
- dst ="src";
|
|
|
- pth=pth.substring(0, pth.length()-4);
|
|
|
- }
|
|
|
- mergedList[i+c1][0] = pth;
|
|
|
- mergedList[i+c1][1] = dst;
|
|
|
- }
|
|
|
- //main inited_b's b_loop
|
|
|
- int[] cntr = new int[]{0,0,0};//HAX
|
|
|
- //Arrays.sort(mergedList, ); //verwursteln....
|
|
|
- List<String[]> commandQueue = new ArrayList<>();
|
|
|
- List<String> resultFiles = new ArrayList<>();
|
|
|
- Arrays.stream(mergedList).sorted((x, y) ->
|
|
|
- {
|
|
|
- return x[0].compareToIgnoreCase(y[0]);
|
|
|
- }).forEach((x) ->
|
|
|
- {
|
|
|
- String outFile = path + "\\p\\" + String.format("%04d", packID) + "_" + String.format("%04d", cntr[0]++);
|
|
|
-
|
|
|
- String[] y = x[1].equals("proc")
|
|
|
- ? new String[]
|
|
|
- {
|
|
|
- "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\" + x[1] + "\\" + x[0], "-resize", res + "!", outFile + ".jpg"
|
|
|
- }
|
|
|
- : new String[]
|
|
|
- {
|
|
|
- "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\" + x[1] + "\\" + x[0], "-resize", res + ">", "-background", "black", "-gravity", "center", "-extent",res, outFile + ".jpg"
|
|
|
- };
|
|
|
- resultFiles.add(outFile+ ".jpg");
|
|
|
-
|
|
|
- //System.out.println(Arrays.toString(y));
|
|
|
- if (cntr[0] % 5 == 0)
|
|
|
- {
|
|
|
- if (cntr[1] < availablePackagesBFrames.length)
|
|
|
- {
|
|
|
- String bp = path+"\\p\\b\\"+cntr[1]+".jpg";
|
|
|
- String dst = "b-frames";
|
|
|
- String pth = availablePackagesBFrames[cntr[1]];
|
|
|
- String fex = FileTK.getFileExt(pth);
|
|
|
- if(fex!=null&fex.equals("loc"))
|
|
|
- {
|
|
|
- dst="src";
|
|
|
- pth=pth.substring(0, pth.length()-4);
|
|
|
- }
|
|
|
- commandQueue.add(new String[]
|
|
|
- {
|
|
|
- "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\"+dst+"\\" + pth, "-resize", res + "!", bp
|
|
|
- });
|
|
|
- availablePackagesBFrames[cntr[1]]=bp;
|
|
|
- cntr[1]++;
|
|
|
- }
|
|
|
- commandQueue.add(new String[]{"cmd.exe","/c","copy",availablePackagesBFrames[cntr[2]],outFile+"b.jpg"});
|
|
|
- cntr[2]=((cntr[2]+1)%availablePackagesBFrames.length);
|
|
|
- resultFiles.add(outFile+ "b.jpg");
|
|
|
- }
|
|
|
- commandQueue.add(y);
|
|
|
-
|
|
|
- }
|
|
|
- ); //System.out.println(packID+"|"+x[0])
|
|
|
-
|
|
|
-
|
|
|
- //DBG FileTK.writeFile(new Yaml().dump(commandQueue),"T:\\wpc\\00_meta\\debug_"+packID+".yaml");
|
|
|
- //normal
|
|
|
- //convert in.image -resize res! out.image
|
|
|
-
|
|
|
- //keepaspect's
|
|
|
- // res+">"
|
|
|
-
|
|
|
-
|
|
|
- //convert in.image -resize res+">" -background black -gravity center -extent res out.image
|
|
|
- return new Object[]{commandQueue,resultFiles};
|
|
|
- }
|
|
|
-
|
|
|
- private static void folderOptimize(String basepath)
|
|
|
- {
|
|
|
- String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/basepath,true);
|
|
|
-
|
|
|
- Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(basepath+"\\" + t).isDirectory()).forEach(t ->
|
|
|
- {
|
|
|
-
|
|
|
- System.out.println("Optimieren: Verzeichnis "+t+"(@"+pos+")");
|
|
|
- String path = basepath+"\\" + t;
|
|
|
- FileTK.verzeichnisKillen(new File(path+"\\p"));
|
|
|
-
|
|
|
- List<String> availablePackagesNormal = Arrays.asList(FileTK.getDirectoryContent(path+"\\proc",true));
|
|
|
- List<String> availablePackagesNoResize = Arrays.asList(FileTK.getDirectoryContent(path+"\\k-i-p",true));
|
|
|
- List<String> availablePackagesBFrames = Arrays.asList(FileTK.getDirectoryContent(path+"\\b-frames",true));
|
|
|
-
|
|
|
- String[] sourceFiles = FileTK.getDirectoryContent(path+"\\src",true);
|
|
|
-
|
|
|
- for (String sourceFile : sourceFiles)
|
|
|
- {
|
|
|
-
|
|
|
- String fex = FileTK.getFileExt(sourceFile);
|
|
|
- if(fex!=null&&fex.equals("loc"))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- String fp = path+"\\src\\"+sourceFile;
|
|
|
- File src = new File(fp);
|
|
|
- if(!src.isFile())
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- long fs = src.length();
|
|
|
- if(availablePackagesNormal.contains(sourceFile))
|
|
|
- {
|
|
|
- String tfp = path+"\\proc\\"+sourceFile;
|
|
|
- File cp = new File(tfp);
|
|
|
- if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
|
|
|
- {
|
|
|
- //System.out.println("DELETE "+tfp);
|
|
|
- cp.delete();
|
|
|
- //System.out.println("CREATE "+tfp+".loc");
|
|
|
- try
|
|
|
- {
|
|
|
- new File(tfp+".loc").createNewFile();
|
|
|
- }
|
|
|
- catch (IOException ex)
|
|
|
- {
|
|
|
- ex.printStackTrace();
|
|
|
- }/**/
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- if(availablePackagesNoResize.contains(sourceFile))
|
|
|
- {
|
|
|
- String tfp = path+"\\k-i-p\\"+sourceFile;
|
|
|
- File cp = new File(tfp);
|
|
|
- if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
|
|
|
- {
|
|
|
- //System.out.println("DELETE "+tfp);
|
|
|
- cp.delete();
|
|
|
- //System.out.println("CREATE "+tfp+".loc");
|
|
|
- try
|
|
|
- {
|
|
|
- new File(tfp+".loc").createNewFile();
|
|
|
- }
|
|
|
- catch (IOException ex)
|
|
|
- {
|
|
|
- ex.printStackTrace();
|
|
|
- }/**/
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- if(availablePackagesBFrames.contains(sourceFile))
|
|
|
- {
|
|
|
- String tfp = path+"\\b-frames\\"+sourceFile;
|
|
|
- File cp = new File(tfp);
|
|
|
- if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
|
|
|
- {
|
|
|
- //System.out.println("DELETE "+tfp);
|
|
|
- cp.delete();
|
|
|
- //System.out.println("CREATE "+tfp+".loc");
|
|
|
- try
|
|
|
- {
|
|
|
- new File(tfp+".loc").createNewFile();
|
|
|
- }
|
|
|
- catch (IOException ex)
|
|
|
- {
|
|
|
- ex.printStackTrace();
|
|
|
- }/**/
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+/*
|
|
|
+ * Copyright (C) 2015 iZc
|
|
|
+ *
|
|
|
+ * This program is free software: you can redistribute it and/or modify
|
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
|
+ * the Free Software Foundation, either version 3 of the License, or
|
|
|
+ * (at your option) any later version.
|
|
|
+ *
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+ * GNU General Public License for more details.
|
|
|
+ *
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
+ */
|
|
|
+
|
|
|
+package de.nplusc.izc.Utilities.WPCMgr;
|
|
|
+
|
|
|
+import de.nplusc.izc.tools.IOtools.FileTK;
|
|
|
+import de.nplusc.izc.tools.baseTools.Tools;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import org.apache.logging.log4j.LogManager;
|
|
|
+import org.apache.logging.log4j.Logger;
|
|
|
+import org.yaml.snakeyaml.DumperOptions;
|
|
|
+import org.yaml.snakeyaml.Yaml;
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @author LH
|
|
|
+ */
|
|
|
+public class Synchronizer
|
|
|
+{
|
|
|
+ private static final Logger l = LogManager.getLogger();
|
|
|
+ public static void main(String cachedir) throws FileNotFoundException
|
|
|
+ {
|
|
|
+ //DEBUG
|
|
|
+ //path="T:\\wpc";
|
|
|
+ //res="1920x1080";
|
|
|
+ LinkedHashMap<String,Object> data = (LinkedHashMap<String,Object>) WPCUtils.getConfig(cachedir);
|
|
|
+ //calculate screen coverages
|
|
|
+ //2x16:9 allowed in 3x4:3
|
|
|
+
|
|
|
+ //structure
|
|
|
+ //screenratio>screencount>[screenbase_coord[x,y],virtualsize[x,y]];
|
|
|
+
|
|
|
+ int[][] screenratios={{16,9},{21,9},{16,10},{4,3}/*,{5,4}*/};
|
|
|
+
|
|
|
+ int[][] dualratios={{32,9},{42,9},{32,10},{8,3}};
|
|
|
+
|
|
|
+ int[][] tripleratios = {{48,9},{63,9},{48,10},{12,3}};
|
|
|
+
|
|
|
+ //install hack for using certain ratio multiscreen WPs in other multiscreen ratios
|
|
|
+ //int[][] tri
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ folderOptimize(cachedir);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ folderOptimize(cachedir);
|
|
|
+ /*
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ LinkedHashMap<String,Object>) new Yaml().load(new FileInputStream(path+"\\00_meta\\state.yml"));
|
|
|
+ if(data.get("HEAD")==null)
|
|
|
+ {
|
|
|
+ initPipeLine(path, res);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ updatePipeLine(path, res);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (FileNotFoundException ex)
|
|
|
+ {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }*/
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void initPipeLine(String path,String res)
|
|
|
+ {
|
|
|
+ String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/path,true);
|
|
|
+ final int pid[] = new int[]{0};
|
|
|
+ List<String[]> cmdQueue = new ArrayList<>();
|
|
|
+ List<String> resultFiles = new ArrayList<>();
|
|
|
+ List<String> packagesInitialized = new ArrayList<>();
|
|
|
+ Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(path+"\\" + t).isDirectory()).forEach(t ->
|
|
|
+ {
|
|
|
+ packagesInitialized.add(t);
|
|
|
+ Object[] rv = processPackage(/*args[0]+*/path+"\\" + t, pid[0]++, res);
|
|
|
+ cmdQueue.addAll((List<String[]>) rv[0]);
|
|
|
+ resultFiles.addAll((List<String>) rv[1]);
|
|
|
+ });
|
|
|
+ DumperOptions yamlOptions = new DumperOptions();
|
|
|
+ yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
|
|
+ Yaml y = new Yaml(yamlOptions);
|
|
|
+
|
|
|
+ //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
|
|
|
+
|
|
|
+ //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
|
|
|
+ final int length = cmdQueue.size();
|
|
|
+ cmdQueue.forEach(x ->
|
|
|
+ {
|
|
|
+ Tools.runCmdWithPassthru(null, x);
|
|
|
+ System.out.println("\rVerarbeitet: "+(++pos)+"/"+length);
|
|
|
+ });
|
|
|
+ System.out.println("\nFertigstellen....");
|
|
|
+
|
|
|
+
|
|
|
+ pos=0;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ LinkedHashMap<String,Object> data = (LinkedHashMap<String,Object>) y.load(new FileInputStream(path+"\\00_meta\\state.yml"));
|
|
|
+ String targetDir = (String) data.get("Outdir");
|
|
|
+ resultFiles.forEach(entry ->
|
|
|
+ {
|
|
|
+ String fn = FileTK.getFileName(entry);
|
|
|
+ FileTK.kopierpaste(new File(entry),new File(targetDir+"\\"+fn));
|
|
|
+ pos++;
|
|
|
+ if(pos%100==0)
|
|
|
+ {
|
|
|
+ System.out.print(pos+" Dateien kopiert");
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ System.out.print(pos+" Dateien kopiert");
|
|
|
+ System.out.println("\nFertig....");
|
|
|
+ data.put("HEAD", packagesInitialized);
|
|
|
+ String o = y.dump(data);
|
|
|
+ FileTK.writeFile(o, path+"\\00_meta\\state.yml");
|
|
|
+ }
|
|
|
+
|
|
|
+ catch (FileNotFoundException ex)
|
|
|
+ {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ System.exit(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static int pos;
|
|
|
+ public static void updatePipeLine(String path,String res)
|
|
|
+ {
|
|
|
+ DumperOptions yamlOptions = new DumperOptions();
|
|
|
+ yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
|
|
+ Yaml y = new Yaml(yamlOptions);
|
|
|
+ LinkedHashMap<String,Object> data = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ data = (LinkedHashMap<String,Object>) y.load(new FileInputStream(path+"\\00_meta\\state.yml"));
|
|
|
+ }
|
|
|
+ catch(IOException lm)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ if(data==null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/path,true);
|
|
|
+ List<String[]> cmdQueue = new ArrayList<>();
|
|
|
+ List<String> resultFiles = new ArrayList<>();
|
|
|
+ List<String> packagesInitialized = (List<String>) data.get("HEAD");
|
|
|
+ Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(path+"\\" + t).isDirectory()).forEach(t ->
|
|
|
+ {
|
|
|
+ if(!packagesInitialized.contains(t)&&FileTK.getDirectoryContent(path+"\\" + t+"\\proc").length>0) //package initialisiert sich erst wenn mindestens ein WP in proc
|
|
|
+ {
|
|
|
+ packagesInitialized.add(t); //vv-- highest IDX of package list aka current -> results in counter continuity
|
|
|
+ Object[] rv = processPackage(/*args[0]+*/path+"\\" + t, packagesInitialized.size()-1, res);
|
|
|
+ cmdQueue.addAll((List<String[]>) rv[0]);
|
|
|
+ resultFiles.addAll((List<String>) rv[1]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ //FileTK.writeFile(new Yaml().dump(cmdQueue),"T:\\wpc\\00_meta\\debug_.yaml");
|
|
|
+ final int length = cmdQueue.size();
|
|
|
+ cmdQueue.forEach(x ->
|
|
|
+ {
|
|
|
+ Tools.runCmdWithPassthru(null, x);
|
|
|
+ System.out.println("\rVerarbeitet: "+(++pos)+"/"+length);
|
|
|
+ });
|
|
|
+ System.out.println("\nFertigstellen....");
|
|
|
+
|
|
|
+ pos=0;
|
|
|
+
|
|
|
+ String targetDir = (String) data.get("Outdir");
|
|
|
+ resultFiles.forEach(entry ->
|
|
|
+ {
|
|
|
+ String fn = FileTK.getFileName(entry);
|
|
|
+ FileTK.kopierpaste(new File(entry),new File(targetDir+"\\"+fn));
|
|
|
+ pos++;
|
|
|
+ if(pos%100==0)
|
|
|
+ {
|
|
|
+ System.out.print(pos+" Dateien kopiert");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ data.put("HEAD", packagesInitialized);
|
|
|
+ String o = y.dump(data);
|
|
|
+ FileTK.writeFile(o, path+"\\00_meta\\state.yml");
|
|
|
+ System.out.print(pos+" Dateien kopiert");
|
|
|
+ System.out.println("\nFertig....");
|
|
|
+ System.exit(0);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Object[] processPackage(String path,int packID,String res)
|
|
|
+ {
|
|
|
+ /*
|
|
|
+ if(false)
|
|
|
+ {
|
|
|
+ System.out.println(packID+"|"+path);
|
|
|
+ return;
|
|
|
+ }*/
|
|
|
+ System.out.println(path);
|
|
|
+ FileTK.verzeichnisKillen(new File(path+"\\p"));
|
|
|
+ new File(path+"\\p\\b\\").mkdirs();
|
|
|
+ String[] availablePackagesNormal = FileTK.getDirectoryContent(path+"\\proc",true);
|
|
|
+ String[] availablePackagesNoResize = FileTK.getDirectoryContent(path+"\\k-i-p",true);
|
|
|
+ String[] availablePackagesBFrames = FileTK.getDirectoryContent(path+"\\b-frames",true);
|
|
|
+
|
|
|
+ int c1 = availablePackagesNormal==null?0:availablePackagesNormal.length;
|
|
|
+ int c2 = availablePackagesNoResize==null?0:availablePackagesNoResize.length;
|
|
|
+ //System.out.println(c1+"|"+c2+"||"+(c1+c2));
|
|
|
+ String[][] mergedList = new String[c1+c2][2];
|
|
|
+ for (int i = 0; i < c1 ; i++)
|
|
|
+ {
|
|
|
+ String pth = availablePackagesNormal[i];
|
|
|
+ String dst = "proc";
|
|
|
+
|
|
|
+ String fex = FileTK.getFileExt(pth);
|
|
|
+ if(fex!=null&&fex.equals("loc"))
|
|
|
+ {
|
|
|
+ dst ="src";
|
|
|
+ pth=pth.substring(0, pth.length()-4);
|
|
|
+ }
|
|
|
+ mergedList[i][0] = pth;
|
|
|
+ mergedList[i][1] = dst;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < c2; i++)
|
|
|
+ {
|
|
|
+ String pth = availablePackagesNoResize[i];
|
|
|
+ String dst = "k-i-p";
|
|
|
+
|
|
|
+ String fex = FileTK.getFileExt(pth);
|
|
|
+ if(fex!=null&&fex.equals("loc"))
|
|
|
+ {
|
|
|
+ dst ="src";
|
|
|
+ pth=pth.substring(0, pth.length()-4);
|
|
|
+ }
|
|
|
+ mergedList[i+c1][0] = pth;
|
|
|
+ mergedList[i+c1][1] = dst;
|
|
|
+ }
|
|
|
+ //main inited_b's b_loop
|
|
|
+ int[] cntr = new int[]{0,0,0};//HAX
|
|
|
+ //Arrays.sort(mergedList, ); //verwursteln....
|
|
|
+ List<String[]> commandQueue = new ArrayList<>();
|
|
|
+ List<String> resultFiles = new ArrayList<>();
|
|
|
+ Arrays.stream(mergedList).sorted((x, y) ->
|
|
|
+ {
|
|
|
+ return x[0].compareToIgnoreCase(y[0]);
|
|
|
+ }).forEach((x) ->
|
|
|
+ {
|
|
|
+ String outFile = path + "\\p\\" + String.format("%04d", packID) + "_" + String.format("%04d", cntr[0]++);
|
|
|
+
|
|
|
+ String[] y = x[1].equals("proc")
|
|
|
+ ? new String[]
|
|
|
+ {
|
|
|
+ "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\" + x[1] + "\\" + x[0], "-resize", res + "!", outFile + ".jpg"
|
|
|
+ }
|
|
|
+ : new String[]
|
|
|
+ {
|
|
|
+ "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\" + x[1] + "\\" + x[0], "-resize", res + ">", "-background", "black", "-gravity", "center", "-extent",res, outFile + ".jpg"
|
|
|
+ };
|
|
|
+ resultFiles.add(outFile+ ".jpg");
|
|
|
+
|
|
|
+ //System.out.println(Arrays.toString(y));
|
|
|
+ if (cntr[0] % 5 == 0)
|
|
|
+ {
|
|
|
+ if (cntr[1] < availablePackagesBFrames.length)
|
|
|
+ {
|
|
|
+ String bp = path+"\\p\\b\\"+cntr[1]+".jpg";
|
|
|
+ String dst = "b-frames";
|
|
|
+ String pth = availablePackagesBFrames[cntr[1]];
|
|
|
+ String fex = FileTK.getFileExt(pth);
|
|
|
+ if(fex!=null&fex.equals("loc"))
|
|
|
+ {
|
|
|
+ dst="src";
|
|
|
+ pth=pth.substring(0, pth.length()-4);
|
|
|
+ }
|
|
|
+ commandQueue.add(new String[]
|
|
|
+ {
|
|
|
+ "C:\\Program Files\\ImageMagick-6.8.8-Q16\\convert.exe", path + "\\"+dst+"\\" + pth, "-resize", res + "!", bp
|
|
|
+ });
|
|
|
+ availablePackagesBFrames[cntr[1]]=bp;
|
|
|
+ cntr[1]++;
|
|
|
+ }
|
|
|
+ commandQueue.add(new String[]{"cmd.exe","/c","copy",availablePackagesBFrames[cntr[2]],outFile+"b.jpg"});
|
|
|
+ cntr[2]=((cntr[2]+1)%availablePackagesBFrames.length);
|
|
|
+ resultFiles.add(outFile+ "b.jpg");
|
|
|
+ }
|
|
|
+ commandQueue.add(y);
|
|
|
+
|
|
|
+ }
|
|
|
+ ); //System.out.println(packID+"|"+x[0])
|
|
|
+
|
|
|
+
|
|
|
+ //DBG FileTK.writeFile(new Yaml().dump(commandQueue),"T:\\wpc\\00_meta\\debug_"+packID+".yaml");
|
|
|
+ //normal
|
|
|
+ //convert in.image -resize res! out.image
|
|
|
+
|
|
|
+ //keepaspect's
|
|
|
+ // res+">"
|
|
|
+
|
|
|
+
|
|
|
+ //convert in.image -resize res+">" -background black -gravity center -extent res out.image
|
|
|
+ return new Object[]{commandQueue,resultFiles};
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void folderOptimize(String basepath)
|
|
|
+ {
|
|
|
+ String[] dirsExist = FileTK.getDirectoryContent(/*args[0]*/basepath,true);
|
|
|
+
|
|
|
+ Arrays.stream(dirsExist).filter(t -> !t.startsWith("00_") && new File(basepath+"\\" + t).isDirectory()).forEach(t ->
|
|
|
+ {
|
|
|
+
|
|
|
+ System.out.println("Optimieren: Verzeichnis "+t+"(@"+pos+")");
|
|
|
+ String path = basepath+"\\" + t;
|
|
|
+ FileTK.verzeichnisKillen(new File(path+"\\p"));
|
|
|
+
|
|
|
+ List<String> availablePackagesNormal = Arrays.asList(FileTK.getDirectoryContent(path+"\\proc",true));
|
|
|
+ List<String> availablePackagesNoResize = Arrays.asList(FileTK.getDirectoryContent(path+"\\k-i-p",true));
|
|
|
+ List<String> availablePackagesBFrames = Arrays.asList(FileTK.getDirectoryContent(path+"\\b-frames",true));
|
|
|
+
|
|
|
+ String[] sourceFiles = FileTK.getDirectoryContent(path+"\\src",true);
|
|
|
+
|
|
|
+ for (String sourceFile : sourceFiles)
|
|
|
+ {
|
|
|
+
|
|
|
+ String fex = FileTK.getFileExt(sourceFile);
|
|
|
+ if(fex!=null&&fex.equals("loc"))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String fp = path+"\\src\\"+sourceFile;
|
|
|
+ File src = new File(fp);
|
|
|
+ if(!src.isFile())
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ long fs = src.length();
|
|
|
+ if(availablePackagesNormal.contains(sourceFile))
|
|
|
+ {
|
|
|
+ String tfp = path+"\\proc\\"+sourceFile;
|
|
|
+ File cp = new File(tfp);
|
|
|
+ if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
|
|
|
+ {
|
|
|
+ //System.out.println("DELETE "+tfp);
|
|
|
+ cp.delete();
|
|
|
+ //System.out.println("CREATE "+tfp+".loc");
|
|
|
+ try
|
|
|
+ {
|
|
|
+ new File(tfp+".loc").createNewFile();
|
|
|
+ }
|
|
|
+ catch (IOException ex)
|
|
|
+ {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }/**/
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(availablePackagesNoResize.contains(sourceFile))
|
|
|
+ {
|
|
|
+ String tfp = path+"\\k-i-p\\"+sourceFile;
|
|
|
+ File cp = new File(tfp);
|
|
|
+ if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
|
|
|
+ {
|
|
|
+ //System.out.println("DELETE "+tfp);
|
|
|
+ cp.delete();
|
|
|
+ //System.out.println("CREATE "+tfp+".loc");
|
|
|
+ try
|
|
|
+ {
|
|
|
+ new File(tfp+".loc").createNewFile();
|
|
|
+ }
|
|
|
+ catch (IOException ex)
|
|
|
+ {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }/**/
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(availablePackagesBFrames.contains(sourceFile))
|
|
|
+ {
|
|
|
+ String tfp = path+"\\b-frames\\"+sourceFile;
|
|
|
+ File cp = new File(tfp);
|
|
|
+ if(cp.exists()&&(!cp.isDirectory())&&cp.length()==fs)
|
|
|
+ {
|
|
|
+ //System.out.println("DELETE "+tfp);
|
|
|
+ cp.delete();
|
|
|
+ //System.out.println("CREATE "+tfp+".loc");
|
|
|
+ try
|
|
|
+ {
|
|
|
+ new File(tfp+".loc").createNewFile();
|
|
|
+ }
|
|
|
+ catch (IOException ex)
|
|
|
+ {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }/**/
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|