CropAssetCopyTool
This commit is contained in:
@@ -24,6 +24,10 @@ public class CropAssetCopyTool {
|
|||||||
|
|
||||||
private static Logger log = Logger.getLogger(CropAssetCopyTool.class);
|
private static Logger log = Logger.getLogger(CropAssetCopyTool.class);
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean dryRun = true;
|
||||||
|
|
||||||
|
|
||||||
private static String toolboxExportFilePath = "C:\\Temp\\Migration CS - SQL Server\\export-2017-08-15.csv";
|
private static String toolboxExportFilePath = "C:\\Temp\\Migration CS - SQL Server\\export-2017-08-15.csv";
|
||||||
private static String assetPath = "D:\\Toolbox\\Assets";
|
private static String assetPath = "D:\\Toolbox\\Assets";
|
||||||
private static String videoPath = "D:\\Toolbox\\Movies\\";
|
private static String videoPath = "D:\\Toolbox\\Movies\\";
|
||||||
@@ -37,15 +41,17 @@ public class CropAssetCopyTool {
|
|||||||
private CsvParserSettings parserSettings = new CsvParserSettings();
|
private CsvParserSettings parserSettings = new CsvParserSettings();
|
||||||
private List<String[]> inputRows;
|
private List<String[]> inputRows;
|
||||||
|
|
||||||
public CropAssetCopyTool() throws ZipException, IOException {
|
public CropAssetCopyTool() throws IOException {
|
||||||
readToolboxExport();
|
readToolboxExport();
|
||||||
|
|
||||||
int lineNo = 0;
|
int lineNo = 0;
|
||||||
|
int noFile = 0;
|
||||||
int noContent = 0;
|
int noContent = 0;
|
||||||
int wrongSize = 0;
|
int wrongSize = 0;
|
||||||
int video = 0;
|
int video = 0;
|
||||||
int videosExtracted = 0;
|
int videosExtracted = 0;
|
||||||
int videosZipped = 0;
|
int videosZipped = 0;
|
||||||
|
int zipCorrupt = 0;
|
||||||
|
|
||||||
for (String[] line : inputRows) {
|
for (String[] line : inputRows) {
|
||||||
lineNo++;
|
lineNo++;
|
||||||
@@ -63,43 +69,57 @@ public class CropAssetCopyTool {
|
|||||||
if (fileLength < 1) {
|
if (fileLength < 1) {
|
||||||
noContent++;
|
noContent++;
|
||||||
log.warn("Skipping '" + filePath + "' (AssetID " + assetId + "), no content");
|
log.warn("Skipping '" + filePath + "' (AssetID " + assetId + "), no content");
|
||||||
|
|
||||||
|
// TODO update spreadsheet?
|
||||||
}
|
}
|
||||||
else if (expectedSize != fileLength) {
|
else if (expectedSize != fileLength) {
|
||||||
|
|
||||||
File videoFile = new File(videoPath + assetId + ".zip");
|
File videoFile = new File(videoPath + assetId + ".zip");
|
||||||
if (videoFile.exists()) {
|
if (videoFile.exists()) {
|
||||||
ZipFile zipFile = new ZipFile(videoFile.getAbsolutePath());
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
ZipFile zipFile;
|
||||||
List fileList = zipFile.getFileHeaders();
|
try {
|
||||||
|
zipFile = new ZipFile(videoFile.getAbsolutePath());
|
||||||
if (fileList.size() == 1) {
|
|
||||||
log.info("Extracting " + videoFile.getAbsolutePath());
|
|
||||||
// zipFile.extractAll(videoTargetPath);
|
|
||||||
//
|
|
||||||
// FileHeader header = (FileHeader) fileList.get(0);
|
|
||||||
// File srcFile = new File(videoTargetPath + "\\" + header.getFileName());
|
|
||||||
// File destFile = new File(videoTargetPath + "\\" + targetName);
|
|
||||||
// log.info("AssetID " + assetId + ": Moving " + srcFile.getAbsolutePath() + " to " + destFile.getAbsolutePath());
|
|
||||||
//
|
|
||||||
// FileUtils.moveFile(srcFile, destFile);
|
|
||||||
|
|
||||||
videosExtracted++;
|
@SuppressWarnings("rawtypes")
|
||||||
|
List fileList = zipFile.getFileHeaders();
|
||||||
|
|
||||||
|
if (fileList.size() == 1) {
|
||||||
|
log.info("Extracting " + videoFile.getAbsolutePath());
|
||||||
|
|
||||||
|
if (!dryRun) {
|
||||||
|
zipFile.extractAll(videoTargetPath);
|
||||||
|
|
||||||
|
FileHeader header = (FileHeader) fileList.get(0);
|
||||||
|
File srcFile = new File(videoTargetPath + "\\" + header.getFileName());
|
||||||
|
File destFile = new File(videoTargetPath + "\\" + targetName);
|
||||||
|
log.info("AssetID " + assetId + ": Moving " + srcFile.getAbsolutePath() + " to " + destFile.getAbsolutePath());
|
||||||
|
|
||||||
|
FileUtils.moveFile(srcFile, destFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
videosExtracted++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log.info("Copy " + videoFile.getAbsolutePath() + " as ZIP");
|
||||||
|
if (!dryRun)
|
||||||
|
FileUtils.copyFileToDirectory(videoFile, videoTargetDir);
|
||||||
|
|
||||||
|
// TODO update spreadsheet
|
||||||
|
|
||||||
|
videosZipped++;
|
||||||
|
}
|
||||||
|
|
||||||
|
video++;
|
||||||
|
|
||||||
|
} catch (ZipException e) {
|
||||||
|
log.error("Skipping AssetID " + assetId + " - could not open ZIP file " + videoFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
log.info("Copy " + videoFile.getAbsolutePath() + " as ZIP");
|
|
||||||
// FileUtils.copyFileToDirectory(videoFile, videoTargetDir);
|
|
||||||
|
|
||||||
// TODO update spreadsheet
|
|
||||||
|
|
||||||
videosZipped++;
|
|
||||||
}
|
|
||||||
|
|
||||||
video++;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wrongSize++;
|
wrongSize++;
|
||||||
log.warn("Wrong file size for " + assetId + ": " + expectedSize + " != " + fileLength + " (" + targetName + ")");
|
log.warn("Wrong file size for " + assetId + ": " + expectedSize + " != " + fileLength + " (" + targetName + ")");
|
||||||
|
zipCorrupt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -108,17 +128,20 @@ public class CropAssetCopyTool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.error("'" + filePath + "' is not a file");
|
log.error("'" + filePath + "' not found");
|
||||||
|
noFile++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Lines processed: " + lineNo);
|
log.info("Lines processed: " + lineNo);
|
||||||
|
log.info("Skipped: File not found: " + noFile);
|
||||||
log.info("Skipped: No content: " + noContent);
|
log.info("Skipped: No content: " + noContent);
|
||||||
log.info("Wrong size: " + wrongSize);
|
log.info("Wrong size: " + wrongSize);
|
||||||
|
|
||||||
log.info("Videos: " + video);
|
log.info("Videos: " + video);
|
||||||
log.info(" Extracted: " + videosExtracted);
|
log.info(" Extracted: " + videosExtracted);
|
||||||
log.info(" Zipped: " + videosZipped);
|
log.info(" Zipped: " + videosZipped);
|
||||||
|
log.info(" Corrupt: " + zipCorrupt);
|
||||||
|
|
||||||
|
|
||||||
// copy files by ID
|
// copy files by ID
|
||||||
|
|||||||
Reference in New Issue
Block a user