CropAssetCopyTool: extract all videos
This commit is contained in:
@@ -6,7 +6,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.io.FileExistsException;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -57,6 +56,9 @@ public class CropAssetCopyTool {
|
|||||||
if (dryRun)
|
if (dryRun)
|
||||||
log.info("This is a dry run. No files are copied.");
|
log.info("This is a dry run. No files are copied.");
|
||||||
|
|
||||||
|
if (skipLines > 0)
|
||||||
|
log.info("Skipping first " + skipLines + " lines");
|
||||||
|
|
||||||
|
|
||||||
readToolboxExport();
|
readToolboxExport();
|
||||||
|
|
||||||
@@ -107,8 +109,7 @@ public class CropAssetCopyTool {
|
|||||||
try {
|
try {
|
||||||
zipFile = new ZipFile(videoFile.getAbsolutePath());
|
zipFile = new ZipFile(videoFile.getAbsolutePath());
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
List<FileHeader> fileList = (List<FileHeader>) zipFile.getFileHeaders();
|
||||||
List fileList = zipFile.getFileHeaders();
|
|
||||||
|
|
||||||
if (fileList.size() == 1) {
|
if (fileList.size() == 1) {
|
||||||
log.debug("Extracting " + videoFile.getAbsolutePath());
|
log.debug("Extracting " + videoFile.getAbsolutePath());
|
||||||
@@ -127,26 +128,21 @@ public class CropAssetCopyTool {
|
|||||||
videosExtracted++;
|
videosExtracted++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// XXX instead of copying the ZIP, extract only the video and link to the releases
|
for (FileHeader header : fileList) {
|
||||||
|
if (header.getFileName().indexOf('/') < 0) {
|
||||||
log.info("Copy " + videoFile.getAbsolutePath() + " as ZIP");
|
if (!dryRun)
|
||||||
if (!dryRun) {
|
zipFile.extractFile(header, videoTargetPath);
|
||||||
File targetFile = FileUtils.getFile(videoTargetDir, videoFile.getName());
|
videosExtracted++;
|
||||||
if (targetFile.exists())
|
break;
|
||||||
throw new FileExistsException(targetFile);
|
}
|
||||||
|
|
||||||
FileUtils.copyFileToDirectory(videoFile, videoTargetDir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
line[1] = videoFile.getName();
|
|
||||||
videosZipped++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
video++;
|
video++;
|
||||||
|
|
||||||
} catch (ZipException e) {
|
} catch (ZipException e) {
|
||||||
zipCorrupt++;
|
zipCorrupt++;
|
||||||
log.error("Skipping AssetID " + assetId + " - could not open ZIP file " + videoFile.getAbsolutePath());
|
log.error("Skipping line " + lineNo + ", AssetID " + assetId + " - could not open ZIP file " + videoFile.getAbsolutePath());
|
||||||
linesForDeletion.add(line);
|
linesForDeletion.add(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,17 +177,17 @@ public class CropAssetCopyTool {
|
|||||||
|
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
try {
|
try {
|
||||||
FileUtils.copyFile(file, targetFile);
|
FileUtils.copyFile(file, targetFile, false);
|
||||||
}
|
}
|
||||||
catch (IOException ioe) {
|
catch (IOException ioe) {
|
||||||
log.error("IOException: '" + ioe.getMessage() + "'");
|
log.error("Line " + lineNo + ", AssetID " + assetId + " - IOException: '" + ioe.getMessage() + "'");
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.error("'" + filePath + "' not found");
|
log.error("Line " + lineNo + ", AssetID " + assetId + " - '" + filePath + "' not found");
|
||||||
noFile++;
|
noFile++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,7 +240,6 @@ public class CropAssetCopyTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Layout layout = new PatternLayout("%d{ISO8601} - %p %m%n"); // "%d{ISO8601} - %p %m%n"
|
Layout layout = new PatternLayout("%d{ISO8601} - %p %m%n"); // "%d{ISO8601} - %p %m%n"
|
||||||
BasicConfigurator.configure(new ConsoleAppender(layout));
|
BasicConfigurator.configure(new ConsoleAppender(layout));
|
||||||
|
|||||||
Reference in New Issue
Block a user