Skip to content

Commit

Permalink
Merge pull request #134 from mattwright324/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mattwright324 authored Nov 2, 2024
2 parents f598720 + b34fcb4 commit a779187
Show file tree
Hide file tree
Showing 60 changed files with 241 additions and 2,409 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ YouTube creators and more.
* Cross-platform using Java 8 and JavaFX
* Include multiple channels, playlists, and videos in a single group.
* Search for comments by video, type, username, keyword, length, and date.
* Export search results to handier and more consumable CSV or JSON formats.
* Display stats about videos: publishes per week, most popular, most disliked, most commented, and disabled.
* Display stats about videos: publishes per week, most popular, most commented, and disabled.
* Display stats about comments: posts per week, most active posters, most popular posters.
* Option to save thumbnails and profiles for archival and offline viewing.
* Sign in to multiple YouTube accounts and choose which to reply with.
* View video context when selecting a comment.

## Install
Expand Down
1 change: 0 additions & 1 deletion module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
requires javafx.web;
requires org.apache.commons.text;
requires org.apache.logging.log4j;
requires org.jsoup;
requires sqlite.jdbc;
requires youtube.data.list.mod;
opens mattw.youtube.commentsuite to javafx.fxml;
Expand Down
36 changes: 13 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

<groupId>io.mattw.youtube</groupId>
<artifactId>youtube-comment-suite</artifactId>
<version>1.4.8</version>
<version>1.4.9</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<current.year>2022</current.year>
<current.year>2024</current.year>
</properties>

<build>
Expand All @@ -30,7 +30,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<version>3.4.2</version>
<executions>
<execution>
<id>default-jar</id>
Expand All @@ -55,7 +55,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<version>3.8.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
Expand All @@ -73,7 +73,7 @@
<!-- Copy additional files -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-resource-one</id>
Expand Down Expand Up @@ -101,7 +101,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<version>3.5.0</version>
</plugin>
</plugins>
</build>
Expand All @@ -112,50 +112,40 @@
<artifactId>google-api-services-youtube</artifactId>
<version>v3-rev222-1.25.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<version>3.17.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.9</version>
<version>1.12.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.3</version>
<version>33.3.1-jre</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.36.0.3</version>
<version>3.46.1.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
<version>2.24.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
<version>2.24.1</version>
</dependency>

<!-- JUnit -->
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/io/mattw/youtube/commentsuite/CommentSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import com.google.api.services.youtube.YouTube;
import com.google.common.eventbus.EventBus;
import io.mattw.youtube.commentsuite.db.CommentDatabase;
import io.mattw.youtube.commentsuite.oauth2.OAuth2Manager;
import io.mattw.youtube.commentsuite.util.IpApiProvider;
import io.mattw.youtube.commentsuite.util.Location;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
Expand All @@ -33,11 +30,9 @@ public class CommentSuite extends Application {

private static final ConfigFile<ConfigData> config = new ConfigFile<>("commentsuite.json", new ConfigData());
private static final EventBus eventBus = new EventBus();
private static final Location<IpApiProvider, IpApiProvider.Location> location = new Location<>(new IpApiProvider(), IpApiProvider.Location.class);

private static CommentDatabase database;
private static YouTube youTube;
private static OAuth2Manager oauth2Manager;
private static final Properties properties = new Properties();

public static void main(String[] args) {
Expand All @@ -57,7 +52,6 @@ public void start(final Stage stage) {
.setApplicationName("youtube-comment-suite")
.build();
database = new CommentDatabase("commentsuite.sqlite3");
oauth2Manager = new OAuth2Manager();
try (InputStream is = CommentSuite.class.getResourceAsStream("/application.properties")) {
properties.load(is);
}
Expand Down Expand Up @@ -103,14 +97,6 @@ public static EventBus getEventBus() {
return eventBus;
}

public static Location<IpApiProvider, IpApiProvider.Location> getLocation() {
return location;
}

public static OAuth2Manager getOauth2Manager() {
return oauth2Manager;
}

public static CommentDatabase getDatabase() {
return database;
}
Expand Down
61 changes: 0 additions & 61 deletions src/main/java/io/mattw/youtube/commentsuite/ConfigData.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
package io.mattw.youtube.commentsuite;

import io.mattw.youtube.commentsuite.events.AccountAddEvent;
import io.mattw.youtube.commentsuite.events.AccountDeleteEvent;
import io.mattw.youtube.commentsuite.oauth2.YouTubeAccount;
import io.mattw.youtube.commentsuite.refresh.RefreshOptions;
import io.mattw.youtube.commentsuite.util.StringMask;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import static io.mattw.youtube.commentsuite.CommentSuite.*;

public class ConfigData implements Serializable {

public static final transient String DEFAULT_API_KEY = "AIzaSyD9SzQFnmOn08ESZC-7gIhnHWVn0asfrKQ";
public static final transient String FAST_GROUP_ADD_THUMB_PLACEHOLDER = "~";

private List<YouTubeAccount> accounts = new ArrayList<>();
private boolean archiveThumbs = false;
private boolean autoLoadStats = true;
private boolean customApiKey = false;
private boolean fastGroupAdd = false;
private boolean filterDuplicatesOnCopy = true;
private boolean grabHeldForReview = false;
private boolean prefixReplies = true;
private RefreshOptions refreshOptions = new RefreshOptions();
private String youtubeApiKey = DEFAULT_API_KEY;

public List<YouTubeAccount> getAccounts() {
return accounts;
}

public void setAccounts(List<YouTubeAccount> accounts) {
this.accounts = accounts;
}

public boolean isArchiveThumbs() {
return archiveThumbs;
}
Expand Down Expand Up @@ -76,22 +58,6 @@ public void setFilterDuplicatesOnCopy(boolean filterDuplicatesOnCopy) {
this.filterDuplicatesOnCopy = filterDuplicatesOnCopy;
}

public boolean isGrabHeldForReview() {
return grabHeldForReview;
}

public void setGrabHeldForReview(boolean grabHeldForReview) {
this.grabHeldForReview = grabHeldForReview;
}

public boolean isPrefixReplies() {
return prefixReplies;
}

public void setPrefixReplies(boolean prefixReplies) {
this.prefixReplies = prefixReplies;
}

public RefreshOptions getRefreshOptions() {
return refreshOptions;
}
Expand All @@ -108,45 +74,18 @@ public void setYoutubeApiKey(String youtubeApiKey) {
this.youtubeApiKey = youtubeApiKey;
}

public void addAccount(final YouTubeAccount account) {
if (accounts.stream().noneMatch(ac -> ac.getChannelId().equals(account.getChannelId()))) {
accounts.add(account);
postEvent(new AccountAddEvent(account));
}
}

public void removeAccount(final YouTubeAccount account) {
if (accounts.removeIf(acc -> acc.getChannelId() != null && acc.getChannelId().equals(account.getChannelId()))) {
postEvent(new AccountDeleteEvent(account));
}
}

public boolean isSignedIn(final String channelId) {
return accounts.stream().anyMatch(acc -> channelId.equals(acc.getChannelId()));
}

public YouTubeAccount getAccount(final String channelId) {
return accounts.stream()
.filter(acc -> channelId.equals(acc.getChannelId()))
.findFirst()
.orElse(null);
}

public String getApiKeyOrDefault() {
return isCustomApiKey() ? getYoutubeApiKey() : DEFAULT_API_KEY;
}

@Override
public String toString() {
return "ConfigData{" +
"accounts=" + accounts +
", archiveThumbs=" + archiveThumbs +
", autoLoadStats=" + autoLoadStats +
", customApiKey=" + customApiKey +
", fastGroupAdd=" + fastGroupAdd +
", filterDuplicatesOnCopy=" + filterDuplicatesOnCopy +
", grabHeldForReview=" + grabHeldForReview +
", prefixReplies=" + prefixReplies +
", refreshOptions=" + refreshOptions +
", youtubeApiKey='" + StringMask.maskHalf(youtubeApiKey) + '\'' +
'}';
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/io/mattw/youtube/commentsuite/ImageCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import io.mattw.youtube.commentsuite.oauth2.YouTubeAccount;
import javafx.scene.image.Image;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -88,10 +87,6 @@ static Image findOrGetImage(final String id, final String imageUrl) {
return image;
}

static Image findOrGetImage(final YouTubeAccount account) {
return findOrGetImage(account.getChannelId(), account.getThumbUrl());
}

static boolean hasImageCached(final String id) {
return thumbCache.getIfPresent(id) != null;
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/io/mattw/youtube/commentsuite/ImageLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public enum ImageLoader {
GROUP("group.png"),
GROUP_ICON("groupIcon.png"),
LOADING("loading.png"),
LOCATION("location.png"),
MANAGE("manage.png"),
MINUS_CIRCLE("minus-circle.png"),
OOPS("oops.png"),
Expand All @@ -32,7 +31,6 @@ public enum ImageLoader {
SETTINGS("settings.png"),
TAGS("tag.png"),
THUMBNAIL("thumbnail.png"),
THUMBS_DOWN("thumbs-down.png"),
THUMBS_UP("thumbs-up.png"),
TIMES_CIRCLE("times-circle.png"),
TOGGLE_CONTEXT("toggleContext.png"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ public GroupStats getGroupStats(Group group) throws SQLException {
stats.setTotalVideos(rs.getLong("total_videos"));
stats.setTotalViews(rs.getLong("total_views"));
stats.setTotalLikes(rs.getLong("total_likes"));
stats.setTotalDislikes(rs.getLong("total_dislikes"));
stats.setTotalComments(rs.getLong("total_comments"));
}
}
Expand All @@ -258,7 +257,6 @@ public GroupStats getGroupStats(Group group) throws SQLException {
}
}
stats.setMostViewed(this.getMostPopularVideos(group, 10));
stats.setMostDisliked(this.getMostDislikedVideos(group, 10));
stats.setMostCommented(this.getMostCommentedVideos(group, 10));
stats.setCommentsDisabled(this.getDisabledVideos(group, 25));
stats.setWeeklyUploadHistogram(this.getWeekByWeekVideoHistogram(group));
Expand Down Expand Up @@ -339,14 +337,6 @@ private List<YouTubeVideo> getMostPopularVideos(Group group, int limit) throws S
}
}

private List<YouTubeVideo> getMostDislikedVideos(Group group, int limit) throws SQLException {
try (PreparedStatement ps = sqlite.prepareStatement(GET_GROUP_DISLIKED_VIDEOS.toString())) {
ps.setString(1, group.getGroupId());
ps.setInt(2, limit);
return videos.toList(ps);
}
}

private List<YouTubeVideo> getMostCommentedVideos(Group group, int limit) throws SQLException {
try (PreparedStatement ps = sqlite.prepareStatement(GET_GROUP_COMMENTED_VIDEOS.toString())) {
ps.setString(1, group.getGroupId());
Expand Down
Loading

0 comments on commit a779187

Please sign in to comment.