mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-02-25 06:19:51 -06:00
added dvb_text to subtitle remover
added option to remove all subtitles form subtitle remover
This commit is contained in:
@@ -31,13 +31,11 @@ namespace DM.MovieApi.MovieDb.Certifications
|
||||
|
||||
JToken certs = obj["certifications"];
|
||||
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
var ratings = certs.ToObject<MovieRatings>();
|
||||
|
||||
Func<IEnumerable<Certification>, IReadOnlyList<Certification>> reorder =
|
||||
list => list.OrderBy( x => x.Order ).ThenBy( x => x.Rating ).ToList().AsReadOnly();
|
||||
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
ratings.Australia = reorder( ratings.Australia );
|
||||
ratings.Canada = reorder( ratings.Canada );
|
||||
ratings.France = reorder( ratings.France );
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace DM.MovieApi.MovieDb.Genres
|
||||
{
|
||||
internal class ApiGenreRequest : ApiRequestBase, IApiGenreRequest
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly List<Genre> _allGenres = new();
|
||||
|
||||
public IReadOnlyList<Genre> AllGenres
|
||||
@@ -146,7 +145,6 @@ namespace DM.MovieApi.MovieDb.Genres
|
||||
|
||||
var arr = ( JArray )obj["genres"];
|
||||
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
var genres = arr.ToObject<IReadOnlyList<Genre>>();
|
||||
|
||||
return genres;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
namespace DM.MovieApi.MovieDb.Genres
|
||||
{
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace DM.MovieApi.MovieDb.IndustryProfessions
|
||||
|
||||
var arr = ( JArray )obj["jobs"];
|
||||
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
var professions = arr.ToObject<IReadOnlyList<Profession>>();
|
||||
|
||||
return professions;
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace DM.MovieApi.MovieDb.Keywords
|
||||
|
||||
var arr = ( JArray )obj[_key];
|
||||
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
var keywords = arr.ToObject<IReadOnlyList<Keyword>>();
|
||||
|
||||
return keywords;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using DM.MovieApi.MovieDb.Genres;
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Local
|
||||
|
||||
namespace DM.MovieApi.MovieDb.TV
|
||||
{
|
||||
|
||||
39
VideoNodes/Tests/SubtitleRemoverTests.cs
Normal file
39
VideoNodes/Tests/SubtitleRemoverTests.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
#if(DEBUG)
|
||||
|
||||
namespace VideoNodes.Tests
|
||||
{
|
||||
using FileFlows.VideoNodes;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
[TestClass]
|
||||
public class SubtitleRemoverTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void SubtitleRemover_Test_01()
|
||||
{
|
||||
const string file = @"D:\videos\unprocessed\Home and Away - 2022-02-23 18 30 00 - Home And Away.ts";
|
||||
var vi = new VideoInfoHelper(@"C:\utils\ffmpeg\ffmpeg.exe", new TestLogger());
|
||||
var vii = vi.Read(file);
|
||||
|
||||
SubtitleRemover node = new();
|
||||
//node.OutputFile = file + ".sup";
|
||||
var args = new FileFlows.Plugin.NodeParameters(file, new TestLogger(), false, string.Empty);
|
||||
args.GetToolPathActual = (string tool) => @"C:\utils\ffmpeg\ffmpeg.exe";
|
||||
args.TempPath = @"D:\videos\temp";
|
||||
|
||||
new VideoFile().Execute(args);
|
||||
|
||||
int output = node.Execute(args);
|
||||
|
||||
Assert.AreEqual(1, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Binary file not shown.
@@ -154,7 +154,9 @@
|
||||
"2": "No subtitles to remove"
|
||||
},
|
||||
"Fields": {
|
||||
"SubtitlesToRemove": "Subtitles To Remove"
|
||||
"SubtitlesToRemove": "Subtitles To Remove",
|
||||
"RemoveAll": "Remove All",
|
||||
"RemoveAll-Help": "When checked, all subtitles will be removed from the file, otherwise only those selected below will be"
|
||||
}
|
||||
},
|
||||
"SubtitleExtractor": {
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
|
||||
public override string Icon => "fas fa-comment";
|
||||
|
||||
[Checklist(nameof(Options), 1)]
|
||||
|
||||
[Boolean(1)]
|
||||
public bool RemoveAll { get; set; }
|
||||
|
||||
[Checklist(nameof(Options), 2)]
|
||||
public List<string> SubtitlesToRemove { get; set; }
|
||||
|
||||
private static List<ListOption> _Options;
|
||||
@@ -32,6 +36,7 @@
|
||||
new ListOption { Value = "xsub", Label = "DivX subtitles (XSUB)" },
|
||||
new ListOption { Value = "dvbsub", Label = "DVB subtitles (codec dvb_subtitle)"},
|
||||
new ListOption { Value = "dvdsub", Label = "DVD subtitles (codec dvd_subtitle)"},
|
||||
new ListOption { Value = "dvb_teletext", Label = "DVB/Teletext Format"},
|
||||
new ListOption { Value = "text", Label = "Raw text subtitle"},
|
||||
new ListOption { Value = "subrip", Label = "SubRip subtitle"},
|
||||
new ListOption { Value = "srt", Label = "SubRip subtitle (codec subrip)"},
|
||||
@@ -61,22 +66,31 @@
|
||||
"-map", "0:a",
|
||||
};
|
||||
|
||||
var removeCodecs = SubtitlesToRemove?.Where(x => string.IsNullOrWhiteSpace(x) == false)?.Select(x => x.ToLower())?.ToList() ?? new List<string>();
|
||||
|
||||
if (removeCodecs.Count == 0)
|
||||
return 2; // nothing to remove
|
||||
|
||||
bool foundBadSubtitle = false;
|
||||
|
||||
foreach (var sub in videoInfo.SubtitleStreams)
|
||||
if (RemoveAll == false)
|
||||
{
|
||||
args.Logger?.ILog("Subtitle found: " + sub.Codec + ", " + sub.Title);
|
||||
if (removeCodecs.Contains(sub.Codec.ToLower()))
|
||||
|
||||
var removeCodecs = SubtitlesToRemove?.Where(x => string.IsNullOrWhiteSpace(x) == false)?.Select(x => x.ToLower())?.ToList() ?? new List<string>();
|
||||
|
||||
if (removeCodecs.Count == 0)
|
||||
return 2; // nothing to remove
|
||||
|
||||
|
||||
foreach (var sub in videoInfo.SubtitleStreams)
|
||||
{
|
||||
foundBadSubtitle = true;
|
||||
continue;
|
||||
args.Logger?.ILog("Subtitle found: " + sub.Codec + ", " + sub.Title);
|
||||
if (removeCodecs.Contains(sub.Codec.ToLower()))
|
||||
{
|
||||
foundBadSubtitle = true;
|
||||
continue;
|
||||
}
|
||||
ffArgs.AddRange(new[] { "-map", sub.IndexString });
|
||||
}
|
||||
ffArgs.AddRange(new[] { "-map", sub.IndexString});
|
||||
}
|
||||
else
|
||||
{
|
||||
foundBadSubtitle = videoInfo.SubtitleStreams?.Any() == true;
|
||||
}
|
||||
|
||||
if(foundBadSubtitle == false)
|
||||
|
||||
Reference in New Issue
Block a user