CropAssetCopyTool: extract all videos
This commit is contained in:
@@ -41,8 +41,6 @@ public class CropAssetCopyTool {
|
|||||||
|
|
||||||
private static File targetDir = new File("D:\\UploadAssets");
|
private static File targetDir = new File("D:\\UploadAssets");
|
||||||
private static String videoTargetPath = "D:\\UploadVideos";
|
private static String videoTargetPath = "D:\\UploadVideos";
|
||||||
private static File videoTargetDir = new File(videoTargetPath);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private CsvParserSettings parserSettings = new CsvParserSettings();
|
private CsvParserSettings parserSettings = new CsvParserSettings();
|
||||||
@@ -67,8 +65,6 @@ public class CropAssetCopyTool {
|
|||||||
int noContent = 0;
|
int noContent = 0;
|
||||||
int wrongSize = 0;
|
int wrongSize = 0;
|
||||||
int video = 0;
|
int video = 0;
|
||||||
int videosExtracted = 0;
|
|
||||||
int videosZipped = 0;
|
|
||||||
int zipCorrupt = 0;
|
int zipCorrupt = 0;
|
||||||
|
|
||||||
for (String[] line : inputRows) {
|
for (String[] line : inputRows) {
|
||||||
@@ -109,35 +105,33 @@ public class CropAssetCopyTool {
|
|||||||
try {
|
try {
|
||||||
zipFile = new ZipFile(videoFile.getAbsolutePath());
|
zipFile = new ZipFile(videoFile.getAbsolutePath());
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
List<FileHeader> fileList = (List<FileHeader>) zipFile.getFileHeaders();
|
List<FileHeader> fileList = (List<FileHeader>) zipFile.getFileHeaders();
|
||||||
|
|
||||||
|
FileHeader header = null;
|
||||||
|
|
||||||
if (fileList.size() == 1) {
|
if (fileList.size() == 1) {
|
||||||
log.debug("Extracting " + videoFile.getAbsolutePath());
|
header = fileList.get(0);
|
||||||
|
|
||||||
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 {
|
else {
|
||||||
for (FileHeader header : fileList) {
|
for (FileHeader hdr : fileList) {
|
||||||
if (header.getFileName().indexOf('/') < 0) {
|
if (hdr.getFileName().indexOf('/') < 0) {
|
||||||
if (!dryRun)
|
header = hdr;
|
||||||
zipFile.extractFile(header, videoTargetPath);
|
|
||||||
videosExtracted++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.debug("Extracting " + videoFile.getAbsolutePath());
|
||||||
|
if (!dryRun) {
|
||||||
|
zipFile.extractFile(header, videoTargetPath);
|
||||||
|
File srcFile = new File(videoTargetPath + "\\" + header.getFileName());
|
||||||
|
File destFile = new File(videoTargetPath + "\\" + targetName);
|
||||||
|
log.info("Line " + lineNo + ", AssetID " + assetId + ": Moving " + srcFile.getAbsolutePath() + " to " + destFile.getAbsolutePath());
|
||||||
|
|
||||||
|
FileUtils.moveFile(srcFile, destFile);
|
||||||
|
}
|
||||||
|
|
||||||
video++;
|
video++;
|
||||||
|
|
||||||
} catch (ZipException e) {
|
} catch (ZipException e) {
|
||||||
@@ -169,7 +163,7 @@ public class CropAssetCopyTool {
|
|||||||
targetFile = new File(targetDir + "\\" + newName);
|
targetFile = new File(targetDir + "\\" + newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("AssetID " + assetId + ": Target file '" + targetName + "' already exists. Copy file as '" + targetFile.getName() + "'");
|
log.info("Line " + lineNo + ", AssetID " + assetId + ": Target file '" + targetName + "' already exists. Copy file as '" + targetFile.getName() + "'");
|
||||||
line[1] = targetFile.getName();
|
line[1] = targetFile.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,8 +198,6 @@ public class CropAssetCopyTool {
|
|||||||
log.info("Wrong size: " + wrongSize);
|
log.info("Wrong size: " + wrongSize);
|
||||||
|
|
||||||
log.info("Videos: " + video);
|
log.info("Videos: " + video);
|
||||||
log.info(" Extracted: " + videosExtracted);
|
|
||||||
log.info(" Zipped: " + videosZipped);
|
|
||||||
log.info(" Corrupt: " + zipCorrupt);
|
log.info(" Corrupt: " + zipCorrupt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user