mirror of
https://github.com/openeggbert/youtubedl-frontend.git
synced 2025-03-26 09:39:23 +01:00
Formatting code
This commit is contained in:
parent
66c89e1c72
commit
712c876c71
@ -90,15 +90,18 @@ public class Main {
|
|||||||
StringBuilder oneChannelStringBuilder = createChannelHtml(null, channels, argsInstance, channelUrls, youtubeVideos, archiveBoxRootDirectory, videosDirectory, archiveBoxArchiveDirectory);
|
StringBuilder oneChannelStringBuilder = createChannelHtml(null, channels, argsInstance, channelUrls, youtubeVideos, archiveBoxRootDirectory, videosDirectory, archiveBoxArchiveDirectory);
|
||||||
Utils.writeTextToFile(oneChannelStringBuilder.toString(), videosHtmlFile);
|
Utils.writeTextToFile(oneChannelStringBuilder.toString(), videosHtmlFile);
|
||||||
|
|
||||||
|
|
||||||
System.out.println("[Warning] Snapshots without videos:");
|
System.out.println("[Warning] Snapshots without videos:");
|
||||||
YoutubeVideo.missingYoutubeVideos.forEach(s -> System.out.println(s));
|
YoutubeVideo.missingYoutubeVideos.forEach(s -> System.out.println(s));
|
||||||
System.out.println("Total duration: " + ((int)((((double)YoutubeVideo.totalDurationInMilliseconds) / 1000d / 60d / 60d))) + " hours");
|
System.out.println("Total duration: " + ((int) ((((double) YoutubeVideo.totalDurationInMilliseconds) / 1000d / 60d / 60d))) + " hours");
|
||||||
youtubeVideos.stream().sorted((YoutubeVideo o1, YoutubeVideo o2) -> Long.valueOf(o1.getVideoDurationInMilliseconds()).compareTo(o2.getVideoDurationInMilliseconds()))
|
youtubeVideos.stream().sorted((YoutubeVideo o1, YoutubeVideo o2) -> Long.valueOf(o1.getVideoDurationInMilliseconds()).compareTo(o2.getVideoDurationInMilliseconds()))
|
||||||
.forEach(y-> {System.out.println(y.getVideoDurationInMinutes() + " = minutes \t" + "https://youtube.com/watch?v=" + y.getId() + "\t" + y.getTitle());});
|
.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");
|
System.out.println("\n\n\n\n");
|
||||||
youtubeVideos.stream().sorted((YoutubeVideo o1, YoutubeVideo o2) -> Long.valueOf(o1.getVideoFileSizeInBytes()).compareTo(o2.getVideoFileSizeInBytes()))
|
youtubeVideos.stream().sorted((YoutubeVideo o1, YoutubeVideo o2) -> Long.valueOf(o1.getVideoFileSizeInBytes()).compareTo(o2.getVideoFileSizeInBytes()))
|
||||||
.forEach(y-> {System.out.println(y.getVideoFileSizeInMegaBytes()+ " MB \t" + "https://youtube.com/watch?v=" + y.getId() + "\t" + y.getTitle());});
|
.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) {
|
private static StringBuilder createChannelHtml(String wantedChannelName, List<String> channels, Args argsInstance, Map<String, String> channelUrls, List<YoutubeVideo> youtubeVideos, File archiveBoxRootDirectory, File videosDirectory, File archiveBoxArchiveDirectory) {
|
||||||
@ -135,7 +138,7 @@ public class Main {
|
|||||||
oneChannelStringBuilder.append("<a target=\"_blank\" href =\"channels/").append(channelUrls.get(channel).split("/channel/")[1]).append(".html").append("\">").append("Videos").append("</a>");
|
oneChannelStringBuilder.append("<a target=\"_blank\" href =\"channels/").append(channelUrls.get(channel).split("/channel/")[1]).append(".html").append("\">").append("Videos").append("</a>");
|
||||||
oneChannelStringBuilder.append(" ( <a href =\"").append(channelUrls.get(channel)).append("\">").append(channelUrls.get(channel)).append("</a> )");
|
oneChannelStringBuilder.append(" ( <a href =\"").append(channelUrls.get(channel)).append("\">").append(channelUrls.get(channel)).append("</a> )");
|
||||||
|
|
||||||
if(wantedChannelName != null) {
|
if (wantedChannelName != null) {
|
||||||
oneChannelStringBuilder.append("<div class=\"videos\">");
|
oneChannelStringBuilder.append("<div class=\"videos\">");
|
||||||
iii = 0;
|
iii = 0;
|
||||||
internalStaticVariableVideoNumberPerRow = 0;
|
internalStaticVariableVideoNumberPerRow = 0;
|
||||||
|
@ -51,6 +51,7 @@ public class Utils {
|
|||||||
|
|
||||||
public static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
public static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||||
public static final NumberFormat TWO_DECIMAL_POINTS_FORMATTER = new DecimalFormat("#0.00");
|
public static final NumberFormat TWO_DECIMAL_POINTS_FORMATTER = new DecimalFormat("#0.00");
|
||||||
|
|
||||||
private Utils() {
|
private Utils() {
|
||||||
//Not meant to be instantiated.
|
//Not meant to be instantiated.
|
||||||
}
|
}
|
||||||
|
@ -328,6 +328,7 @@ public class YoutubeVideo implements Comparable<YoutubeVideo> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static long totalDurationInMilliseconds = 0l;
|
public static long totalDurationInMilliseconds = 0l;
|
||||||
|
|
||||||
public static List<YoutubeVideo> loadYoutubeVideos(File archiveBoxArchiveDirectory, Args argsInstance) throws IOException, InterruptedException {
|
public static List<YoutubeVideo> loadYoutubeVideos(File archiveBoxArchiveDirectory, Args argsInstance) throws IOException, InterruptedException {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
List<YoutubeVideo> youtubeVideos = new ArrayList<>();
|
List<YoutubeVideo> youtubeVideos = new ArrayList<>();
|
||||||
@ -394,10 +395,11 @@ public class YoutubeVideo implements Comparable<YoutubeVideo> {
|
|||||||
}
|
}
|
||||||
return youtubeVideos;
|
return youtubeVideos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getVideoDurationInMilliseconds() {
|
public long getVideoDurationInMilliseconds() {
|
||||||
String duration = videoDuration;
|
String duration = videoDuration;
|
||||||
String[] array = duration.split(":");
|
String[] array = duration.split(":");
|
||||||
long ms = Long.valueOf(array[0]) * 60l *60l * 1000l;
|
long ms = Long.valueOf(array[0]) * 60l * 60l * 1000l;
|
||||||
ms = ms + Long.valueOf(array[1]) * 60l * 1000l;
|
ms = ms + Long.valueOf(array[1]) * 60l * 1000l;
|
||||||
String[] array2 = array[2].split("\\.");
|
String[] array2 = array[2].split("\\.");
|
||||||
ms = ms + Long.valueOf(array2[0]) * 1000l;
|
ms = ms + Long.valueOf(array2[0]) * 1000l;
|
||||||
|
@ -108,8 +108,7 @@ public class YoutubeVideoHtml {
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
videoHtml.append("<button ").append(backEnabled ? "" : "disabled").append(" style=\"").append(backEnabled ? "" : "visibility:hidden;").append("font-size:200%;\" onclick=\"window.location ='").append("./").append(youtubeVideo.getPreviousVideoId()).append(".html'\">");
|
videoHtml.append("<button ").append(backEnabled ? "" : "disabled").append(" style=\"").append(backEnabled ? "" : "visibility:hidden;").append("font-size:200%;\" onclick=\"window.location ='").append("./").append(youtubeVideo.getPreviousVideoId()).append(".html'\">");
|
||||||
|
|
||||||
|
|
||||||
videoHtml.append("Back");
|
videoHtml.append("Back");
|
||||||
videoHtml.append("</button>");
|
videoHtml.append("</button>");
|
||||||
@ -161,22 +160,23 @@ videoHtml.append("<button ").append(backEnabled ? "" : "disabled").append(" styl
|
|||||||
videoHtml.append("<h2>Comments</h2>");
|
videoHtml.append("<h2>Comments</h2>");
|
||||||
youtubeVideo.getComments().forEach(co -> {
|
youtubeVideo.getComments().forEach(co -> {
|
||||||
|
|
||||||
videoHtml.append("<div style=\"margin-left:")
|
videoHtml.append("<div style=\"margin-left:")
|
||||||
.append(co.dotCount() * 50)
|
.append(co.dotCount() * 50)
|
||||||
.append("px;\">");
|
.append("px;\">");
|
||||||
videoHtml.append("<h3>").append(co.getAuthor()).append("</h3>");
|
videoHtml.append("<h3>").append(co.getAuthor()).append("</h3>");
|
||||||
|
|
||||||
videoHtml.append("<span style=\"color:grey;font-size:80%;\">")
|
videoHtml.append("<span style=\"color:grey;font-size:80%;\">")
|
||||||
.append(Utils.DATE_FORMAT.format(new Date(co.getTimestamp() * 1000))).append("</span><br>\n");
|
.append(Utils.DATE_FORMAT.format(new Date(co.getTimestamp() * 1000))).append("</span><br>\n");
|
||||||
videoHtml.append("<span style=\"color:grey;font-size:80%;\">").append(co.getId()).append(" ")
|
videoHtml.append("<span style=\"color:grey;font-size:80%;\">").append(co.getId()).append(" ")
|
||||||
.append(co.getParentId()).append("</span><br>\n");
|
.append(co.getParentId()).append("</span><br>\n");
|
||||||
videoHtml.append("<pre style=\"white-space: pre-wrap;border:1px solid black;max-width:600px;padding:10px;min-height:50px;\">").append(co.getText()).append("</pre>");
|
videoHtml.append("<pre style=\"white-space: pre-wrap;border:1px solid black;max-width:600px;padding:10px;min-height:50px;\">").append(co.getText()).append("</pre>");
|
||||||
videoHtml.append("</div>");
|
videoHtml.append("</div>");
|
||||||
});
|
});
|
||||||
videoHtml.append("</body></html>");
|
videoHtml.append("</body></html>");
|
||||||
singleVideo = videoHtml.toString();
|
singleVideo = videoHtml.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.singleVideo;
|
return this.singleVideo;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user