From 3a5dc1705da3e063fbdf7b8196af3a1c351ecd02 Mon Sep 17 00:00:00 2001 From: seab Date: Thu, 6 Jul 2023 12:34:03 -0400 Subject: [PATCH] Maintenance --- pom.xml | 16 ++++++------- src/main/java/fun/seabird/MediaSortTask.java | 24 ++++++++++++++++--- src/main/java/fun/seabird/MediaSorter.java | 4 +--- .../fun/seabird/MediaSorterApplication.java | 2 +- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index 528e9ba..0e622c3 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 fun.seabird ebird-media-sorter - 2.2.8 + 2.2.9 ebird-media-sorter @@ -49,7 +49,7 @@ com.google.guava guava - 31.1-jre + 32.1.1-jre @@ -76,21 +76,21 @@ commons-io commons-io - 2.11.0 + 2.13.0 org.openjfx javafx-base - 20 + 20.0.1 org.openjfx javafx-controls - 20 + 20.0.1 @@ -104,21 +104,21 @@ ch.qos.logback logback-core - 1.4.6 + 1.4.8 ch.qos.logback logback-classic - 1.4.6 + 1.4.8 io.projectreactor reactor-core - 3.5.5 + 3.5.7 diff --git a/src/main/java/fun/seabird/MediaSortTask.java b/src/main/java/fun/seabird/MediaSortTask.java index 7faaf40..4c453a8 100644 --- a/src/main/java/fun/seabird/MediaSortTask.java +++ b/src/main/java/fun/seabird/MediaSortTask.java @@ -104,7 +104,7 @@ private void parseCsvLine(EbirdCsvRow row) String subId = row.getSubId(); if (!checklistStatsMap.containsKey(subId)) { - LocalDateTime subBeginTime = row.getDate().atTime(row.getTime()); + LocalDateTime subBeginTime = row.dateTime(); LocalDateTime subEndTime = subBeginTime.plusMinutes(duration); checklistStatsMap.putIfAbsent(subId, new SubStats(subBeginTime,row.getSubnat1Code(),row.getSubnat2Name(),row.getLocName())); @@ -223,7 +223,7 @@ private void moveFile(Path from, Path to) throws IOException { } } - private Path createDirIfNotExists(Path path) throws IOException { + private static Path createDirIfNotExists(Path path) throws IOException { return Files.createDirectories(path); } @@ -232,6 +232,13 @@ public static String getFileExtension(String fileName) { return (dotIndex == -1) ? "" : fileName.substring(dotIndex + 1); } + /** + + Transcodes the video file to a smaller size if it exceeds the maximum ML upload size. + @param file The path to the video file to transcode. + @param parentDir The directory where the transcoded video file will be saved. + @throws IOException If an I/O error occurs during the transcoding process. + */ private void transcodeVideo(Path file, Path parentDir) throws IOException { long fileSizeInBytes = Files.size(file); long fileSizeInMB = fileSizeInBytes / (1024 * 1024); @@ -267,6 +274,17 @@ private void transcodeVideo(Path file, Path parentDir) throws IOException { } } + /** + * Checks the metadata of a file and moves it to the appropriate directory based on the metadata information. + * + * @param file The file to check and move. + * @param outputDir The output directory where the file will be moved. + * @param hrsOffset The hour offset for adjusting creation date. + * @param subIds A set to store the unique subIds encountered. + * @param sepYearDir Flag indicating whether to separate files into year directories. + * @param folderGroup The folder grouping mode. + * @throws IOException If an I/O error occurs while performing the operation. + */ private void checkMetadataAndMove(Path file, Path outputDir, Long hrsOffset, Set subIds, boolean sepYearDir, FolderGroup folderGroup) throws IOException { LocalDateTime mediaTime = null; @@ -372,7 +390,7 @@ protected Path call() throws Exception { Set subIds = new TreeSet<>(); Long hrsOffset = msc.getHrsOffset(); - AtomicInteger i = new AtomicInteger(0); + AtomicInteger i = new AtomicInteger(); List eligibleFiles = new ArrayList<>(); logger.info("Analyzing files..."); diff --git a/src/main/java/fun/seabird/MediaSorter.java b/src/main/java/fun/seabird/MediaSorter.java index 2aa68f2..1ef839d 100644 --- a/src/main/java/fun/seabird/MediaSorter.java +++ b/src/main/java/fun/seabird/MediaSorter.java @@ -1,12 +1,10 @@ package fun.seabird; -import java.io.IOException; - import javafx.application.Application; public abstract class MediaSorter { - public static void main(String[] args) throws IOException + public static void main(String[] args) { Application.launch(MediaSorterApplication.class, args); } diff --git a/src/main/java/fun/seabird/MediaSorterApplication.java b/src/main/java/fun/seabird/MediaSorterApplication.java index 1e2a96b..ce38acc 100644 --- a/src/main/java/fun/seabird/MediaSorterApplication.java +++ b/src/main/java/fun/seabird/MediaSorterApplication.java @@ -54,7 +54,7 @@ public class MediaSorterApplication extends Application * @param msc the media sorting configuration to be used for the task * @param msr the media sorting results to be updated after the task completes */ - private void runMediaSortTask(Button runBut, Button resBtn, ProgressBar pb, ScrollPane scroll, MediaSortCmd msc, MediaSortResult msr) + private static void runMediaSortTask(Button runBut, Button resBtn, ProgressBar pb, ScrollPane scroll, MediaSortCmd msc, MediaSortResult msr) { runBut.setDisable(true); resBtn.setDisable(true);