From ed57ca76172f5984eee2d08de841fa7b7bb21b29 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Fri, 29 Jan 2021 15:39:38 +0200 Subject: [PATCH] Removed useless code. --- src/main/java/eu/svjatoslav/meviz/Main.java | 1 - .../eu/svjatoslav/meviz/grabmemcard/Main.java | 125 ------------------ 2 files changed, 126 deletions(-) delete mode 100755 src/main/java/eu/svjatoslav/meviz/grabmemcard/Main.java diff --git a/src/main/java/eu/svjatoslav/meviz/Main.java b/src/main/java/eu/svjatoslav/meviz/Main.java index 028de67..1201b10 100755 --- a/src/main/java/eu/svjatoslav/meviz/Main.java +++ b/src/main/java/eu/svjatoslav/meviz/Main.java @@ -31,7 +31,6 @@ class Main { modules.add(new Encoder()); modules.add(new eu.svjatoslav.meviz.htmlindexer.Main()); modules.add(new eu.svjatoslav.meviz.renamer.Main()); - modules.add(new eu.svjatoslav.meviz.grabmemcard.Main()); modules.add(new eu.svjatoslav.meviz.bomremove.Main()); modules.add(new eu.svjatoslav.meviz.replace.Main()); } diff --git a/src/main/java/eu/svjatoslav/meviz/grabmemcard/Main.java b/src/main/java/eu/svjatoslav/meviz/grabmemcard/Main.java deleted file mode 100755 index aa8c42b..0000000 --- a/src/main/java/eu/svjatoslav/meviz/grabmemcard/Main.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Meviz - Various tools collection to work with multimedia. - * Copyright (C) 2012 -- 2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 3 of the GNU Lesser General Public License - * or later as published by the Free Software Foundation. -*/ - -package eu.svjatoslav.meviz.grabmemcard; - -import eu.svjatoslav.commons.file.CommonPathResolver; -import eu.svjatoslav.commons.file.FilePathParser; -import eu.svjatoslav.meviz.Module; -import eu.svjatoslav.meviz.encoder.BitrateParameter; -import eu.svjatoslav.meviz.encoder.EncodingOptions; -import eu.svjatoslav.meviz.encoder.EncodingPlan; -import eu.svjatoslav.meviz.encoder.EncodingTask; -import eu.svjatoslav.meviz.encoder.converters.AbstractConverter; -import eu.svjatoslav.meviz.encoder.converters.FFMpegVideo; - -import java.io.File; -import java.io.IOException; -import java.util.Date; -import java.util.GregorianCalendar; - -public class Main implements Module { - - @Override - public String getDescription() { - return "Convenience helper to retrieve contents of inserted memory card."; - } - - private File[] getDiskVideos(final File file) { - final String videosPath = file.getAbsolutePath() + "/AVCHD/BDMV/STREAM/"; - final File videosDirectory = new File(videosPath); - - if (!videosDirectory.exists()) - return new File[0]; - - return videosDirectory.listFiles(); - } - - private String getDoubleDigit(final int value) { - String valueString = Integer.toString(value); - if (valueString.length() == 1) - valueString = "0" + valueString; - return valueString; - } - - private EncodingOptions getEncodingOptions() { - final EncodingOptions options = new EncodingOptions(); - options.setVideoBitrate(BitrateParameter.Bitrate.COPY); - options.setAudioBitrate(BitrateParameter.Bitrate.COPY); - return options; - } - - @Override - public String getModuleCommand() { - return "grabmemcard"; - } - - @SuppressWarnings("deprecation") - private File getTargetDirectory() { - final Date now = new Date(); - final GregorianCalendar calendar = new GregorianCalendar(); - - String directoryName = (calendar.get(GregorianCalendar.YEAR) + "." + getDoubleDigit(calendar.get(GregorianCalendar.MONTH) + 1) - + "." + getDoubleDigit(calendar.get(GregorianCalendar.DAY_OF_MONTH)) + " ") + - getDoubleDigit(now.getHours()) + ":" + getDoubleDigit(now.getMinutes()) + ":" - + getDoubleDigit(now.getSeconds()); - - final String targetDirectoryPath = CommonPathResolver.getDesktopDirectory().getAbsolutePath() + "/" - + directoryName + "/"; - - System.out.println("Target directory path: " + targetDirectoryPath); - - return new File(targetDirectoryPath); - } - - private File getTargetFile(final File targetDirectory, final File sourceFile) { - // compute target file path - final StringBuilder targetFilePath = new StringBuilder(); - targetFilePath.append(targetDirectory.getAbsolutePath()); - targetFilePath.append("/"); - targetFilePath.append(FilePathParser.getFileNameWithoutExtension(sourceFile)); - targetFilePath.append(".mp4"); - return new File(targetFilePath.toString()); - } - - @Override - public void run(final String[] args) throws IOException { - - final File targetDirectory = getTargetDirectory(); - targetDirectory.mkdirs(); - - final AbstractConverter converter = new FFMpegVideo(); - final EncodingPlan encodingPlan = new EncodingPlan(); - - final String userName = System.getProperty("user.name"); - - final File file = new File("/media/" + userName + "/"); - - for (final File insertedDisk : file.listFiles()) { - final File[] diskVideos = getDiskVideos(insertedDisk); - - for (final File sourceFile : diskVideos) { - - final File targetFile = getTargetFile(targetDirectory, sourceFile); - - final EncodingTask encodingTask = new EncodingTask(sourceFile, targetFile, converter, "mp4"); - encodingTask.setUseTerminal(true); - encodingPlan.scheduleTask(encodingTask); - } - } - - encodingPlan.execute(getEncodingOptions()); - } - - @Override - public void showCommandlineHelp() { - System.out.println("memory card grabber has no commandline options"); - } - -} -- 2.20.1