mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 10:05:58 +01:00
2
.github/FUNDING.yml
vendored
Normal file
2
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
github: [RatzzFatzz]
|
||||||
|
custom: "https://paypal.me/ratzmichael"
|
||||||
35
.github/workflows/release.yml
vendored
Normal file
35
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# This workflow will run every time a new release is created.
|
||||||
|
|
||||||
|
name: Build and release
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: action/setup-java@v2
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: 11
|
||||||
|
|
||||||
|
- name: Setup workspace
|
||||||
|
run: mkdir artifacts
|
||||||
|
|
||||||
|
- name: Build with Maven
|
||||||
|
run: |
|
||||||
|
mvn clean package --file pom.xml
|
||||||
|
cp MKVAudioSubtitleChanger/target/M*.jar artifacts/
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: skx/github-action-publish-binaries@master
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
args: 'artifacts/M*'
|
||||||
|
|
||||||
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>MKVAudioSubtileChanger</groupId>
|
<groupId>MKVAudioSubtileChanger</groupId>
|
||||||
<artifactId>MKVAudioSubtitleChanger</artifactId>
|
<artifactId>MKVAudioSubtitleChanger</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.1</version>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean package</defaultGoal>
|
<defaultGoal>clean package</defaultGoal>
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class Config {
|
|||||||
private boolean isWindows;
|
private boolean isWindows;
|
||||||
|
|
||||||
private final Set<String> forcedKeywords = new HashSet<>(Arrays.asList("forced", "signs"));
|
private final Set<String> forcedKeywords = new HashSet<>(Arrays.asList("forced", "signs"));
|
||||||
|
private final Set<String> commentaryKeywords = new HashSet<>(Arrays.asList("commentary", "director"));
|
||||||
private final Set<String> excludedDirectories = new HashSet<>();
|
private final Set<String> excludedDirectories = new HashSet<>();
|
||||||
|
|
||||||
private List<AttributeConfig> attributeConfig;
|
private List<AttributeConfig> attributeConfig;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl;
|
|||||||
|
|
||||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.config.Config;
|
import at.pcgamingfreaks.mkvaudiosubtitlechanger.config.Config;
|
||||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.*;
|
import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.*;
|
||||||
|
import at.pcgamingfreaks.mkvaudiosubtitlechanger.util.SetUtils;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -73,17 +74,23 @@ public class MkvFileProcessor implements FileProcessor {
|
|||||||
public FileInfoDto filterAttributes(List<FileAttribute> attributes) {
|
public FileInfoDto filterAttributes(List<FileAttribute> attributes) {
|
||||||
FileInfoDto info = new FileInfoDto();
|
FileInfoDto info = new FileInfoDto();
|
||||||
List<FileAttribute> nonForcedTracks = attributes.stream()
|
List<FileAttribute> nonForcedTracks = attributes.stream()
|
||||||
.filter(elem -> !StringUtils.containsAnyIgnoreCase(elem.getTrackName(), forcedKeywords))
|
.filter(elem -> !StringUtils.containsAnyIgnoreCase(elem.getTrackName(),
|
||||||
|
Config.getInstance().getForcedKeywords().toArray(new CharSequence[0])))
|
||||||
|
.filter(elem -> !elem.isForcedTrack())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<FileAttribute> nonCommentaryTracks = attributes.stream()
|
||||||
|
.filter(elem -> !StringUtils.containsAnyIgnoreCase(elem.getTrackName(),
|
||||||
|
Config.getInstance().getCommentaryKeywords().toArray(new CharSequence[0])))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
detectDefaultTracks(attributes, info, nonForcedTracks);
|
detectDefaultTracks(info, attributes, nonForcedTracks);
|
||||||
detectDesiredTracks(info, nonForcedTracks);
|
detectDesiredTracks(info, nonForcedTracks, nonCommentaryTracks);
|
||||||
log.debug(info);
|
log.debug(info);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void detectDefaultTracks(List<FileAttribute> attributes, FileInfoDto info, List<FileAttribute> nonForcedTracks) {
|
private void detectDefaultTracks(FileInfoDto info, List<FileAttribute> attributes, List<FileAttribute> nonForcedTracks) {
|
||||||
Set<FileAttribute> detectedForcedSubtitleLanes = new HashSet<>();
|
Set<FileAttribute> detectedForcedSubtitleLanes = new HashSet<>();
|
||||||
for (FileAttribute attribute : attributes) {
|
for (FileAttribute attribute : attributes) {
|
||||||
if (attribute.isDefaultTrack() && AUDIO.equals(attribute.getType()))
|
if (attribute.isDefaultTrack() && AUDIO.equals(attribute.getType()))
|
||||||
@@ -101,11 +108,11 @@ public class MkvFileProcessor implements FileProcessor {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void detectDesiredTracks(FileInfoDto info, List<FileAttribute> nonForcedTracks) {
|
private void detectDesiredTracks(FileInfoDto info, List<FileAttribute> nonForcedTracks, List<FileAttribute> nonCommentaryTracks) {
|
||||||
for (AttributeConfig config : Config.getInstance().getAttributeConfig()) {
|
for (AttributeConfig config : Config.getInstance().getAttributeConfig()) {
|
||||||
FileAttribute desiredAudio = null;
|
FileAttribute desiredAudio = null;
|
||||||
FileAttribute desiredSubtitle = null;
|
FileAttribute desiredSubtitle = null;
|
||||||
for (FileAttribute attribute : nonForcedTracks) {
|
for (FileAttribute attribute : SetUtils.retainOf(nonForcedTracks, nonCommentaryTracks)) {
|
||||||
if (attribute.getLanguage().equals(config.getAudioLanguage())
|
if (attribute.getLanguage().equals(config.getAudioLanguage())
|
||||||
&& AUDIO.equals(attribute.getType())) desiredAudio = attribute;
|
&& AUDIO.equals(attribute.getType())) desiredAudio = attribute;
|
||||||
if (attribute.getLanguage().equals(config.getSubtitleLanguage())
|
if (attribute.getLanguage().equals(config.getSubtitleLanguage())
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package at.pcgamingfreaks.mkvaudiosubtitlechanger.util;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class SetUtils {
|
||||||
|
public static <T> Set<T> retainOf(List<T> list1, List<T> list2) {
|
||||||
|
Set<T> set = new HashSet<>(list1);
|
||||||
|
set.retainAll(list2);
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user