added dvb_text to subtitle remover

added option to remove all subtitles form subtitle remover
This commit is contained in:
John Andrews
2022-02-24 20:10:12 +13:00
parent 8cb0a53cc7
commit 4de8733b06
10 changed files with 68 additions and 21 deletions

View File

@@ -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 );

View File

@@ -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;

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
// ReSharper disable UnusedMember.Global
namespace DM.MovieApi.MovieDb.Genres
{

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
{

View 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.

View File

@@ -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": {

View File

@@ -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)