1
0
mirror of https://github.com/openeggbert/youtubedl-frontend.git synced 2025-03-14 21:23:27 +01:00

Added some improvements

This commit is contained in:
Robert Vokac 2024-07-27 17:22:16 +02:00
parent adc5294e99
commit 18b5b7adf0
No known key found for this signature in database
GPG Key ID: C459E1E4B4A986BB
5 changed files with 48 additions and 8 deletions

View File

@ -9,7 +9,7 @@
----------
N: Robert Vokac
E: robertvokac@nanoboot.org
E: mail@robertvokac.com
W: https://nanoboot.org
P: 4096R/E3329055 322B D109 0AA8 C324 EA9C 72F5 693D 30BE E332 9055
D: Founder

View File

@ -2,3 +2,4 @@
ffmpeg -i "$video"mkv -preset slow -crf 18 "$video"webm
ffmpeg -i "$video"mkv -preset slow -crf 18 -vf scale="-1:480" "$video"webm

View File

@ -24,13 +24,14 @@ import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.nanoboot.youtubedlfrontend.Args.TWO_DASHES;
/**
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
* @since 0.0.0
*/
public class Main {
@ -45,9 +46,9 @@ public class Main {
if (args.length < 1) {
//System.err.println("At least one argument is expected, but the count of arguments is: " + args.length + ".");
String argsS = "/rv/blupi/archivebox --video_ 7qKUtn76q30 --always-generate-metadata 1"
+ " --always-generate-html-files 1 --videos-per-row 4 --thumbnail-links-to-youtube 0"
+ " --thumbnail-as-base64 1"
String argsS = "/rv/blupi/archivebox --video_ 7qKUtn76q30 --always-generate-metadata 0"
+ " --always-generate-html-files 0 --videos-per-row 4 --thumbnail-links-to-youtube 0"
+ " --thumbnail-as-base64 0"
+ " --channel_ UCqBpgfXap7cZOYkAC34u8Lg ";
args = argsS.split(" ");
//System.exit(1);
@ -91,6 +92,22 @@ public class Main {
System.out.println("[Warning] Snapshots without videos:");
YoutubeVideo.missingYoutubeVideos.forEach(s -> System.out.println(s));
System.out.println("Total duration: " + ((int)((((double)YoutubeVideo.totalDurationInMilliseconds) / 1000d / 60d / 60d))) + " hours");
youtubeVideos.sort(new Comparator<YoutubeVideo>() {
@Override
public int compare(YoutubeVideo o1, YoutubeVideo o2) {
return Long.valueOf(o1.getVideoDurationInMilliseconds()).compareTo(o2.getVideoDurationInMilliseconds());
}
});
youtubeVideos.forEach(y-> {System.out.println(y.getVideoDurationInMinutes() + " = minutes \t" + "https://youtube.com/watch?v=" + y.getId() + "\t" + y.getTitle());});
System.out.println("\n\n\n\n");
youtubeVideos.sort(new Comparator<YoutubeVideo>() {
@Override
public int compare(YoutubeVideo o1, YoutubeVideo o2) {
return Long.valueOf(o1.getVideoFileSizeInBytes()).compareTo(o2.getVideoFileSizeInBytes());
}
});
youtubeVideos.forEach(y-> {System.out.println(y.getVideoFileSizeInMegaBytes()+ " MB \t" + "https://youtube.com/watch?v=" + y.getId() + "\t" + y.getTitle());});
}
private static StringBuilder createChannelHtml(String wantedChannelName, List<String> channels, Args argsInstance, Map<String, String> channelUrls, List<YoutubeVideo> youtubeVideos, File archiveBoxRootDirectory, File videosDirectory, File archiveBoxArchiveDirectory) {
@ -168,7 +185,7 @@ public class Main {
throw new YoutubedlFrontendException(ex.getMessage());
}
} else {
oneChannelStringBuilder.append(thumbnailPath);
oneChannelStringBuilder.append("../" + thumbnailPath);
}
oneChannelStringBuilder.append("\" width=\"")
.append(THUMBNAIL_WIDTH)

View File

@ -326,7 +326,7 @@ public class YoutubeVideo implements Comparable<YoutubeVideo> {
}
}
}
public static long totalDurationInMilliseconds = 0l;
public static List<YoutubeVideo> loadYoutubeVideos(File archiveBoxArchiveDirectory, Args argsInstance) throws IOException, InterruptedException {
int i = 0;
List<YoutubeVideo> youtubeVideos = new ArrayList<>();
@ -363,6 +363,8 @@ public class YoutubeVideo implements Comparable<YoutubeVideo> {
System.out.println("videoFileSizeInBytes = " + youtubeVideo.getVideoFileSizeInBytes());
System.out.println("videoFileSha512HashSum = " + youtubeVideo.getVideoFileSha512HashSum());
System.out.println("videoDuration = " + youtubeVideo.getVideoDuration());
System.out.println("getVideoDurationInMilliseconds = " + youtubeVideo.getVideoDurationInMilliseconds());
totalDurationInMilliseconds = totalDurationInMilliseconds + youtubeVideo.getVideoDurationInMilliseconds();
System.out.println("channelName = " + youtubeVideo.getChannelName());
System.out.println("channelUrl = " + youtubeVideo.getChannelUrl());
System.out.println("uploadDate = " + youtubeVideo.getUploadDate());
@ -391,5 +393,25 @@ public class YoutubeVideo implements Comparable<YoutubeVideo> {
}
return youtubeVideos;
}
public long getVideoDurationInMilliseconds() {
String duration = videoDuration;
String[] array = duration.split(":");
long ms = Long.valueOf(array[0]) * 60l *60l * 1000l;
ms = ms + Long.valueOf(array[1]) * 60l * 1000l;
String[] array2 = array[2].split("\\.");
ms = ms + Long.valueOf(array2[0]) * 1000l;
ms = ms + Long.valueOf(array2[1]);
return ms;
}
long getVideoDurationInMinutes() {
double s = getVideoDurationInMilliseconds();
return (long) (s / 1000d / 60d);
}
long getVideoFileSizeInMegaBytes() {
double b = getVideoFileSizeInBytes();
return (long) (b / 1024d / 1024d);
}
}

View File

@ -19,7 +19,7 @@
package org.nanoboot.youtubedlfrontend;
/**
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @author <a href="mailto:mail@robertvokac.com">Robert Vokac</a>
* @since 0.0.0
*/
public class YoutubedlFrontendException extends RuntimeException {