commit
bc746b4d05
@ -0,0 +1,23 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Jellyfin.Server.Implementations")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Jellyfin Project")]
|
||||
[assembly: AssemblyProduct("Jellyfin Server")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
[assembly: InternalsVisibleTo("Jellyfin.Server.Implementations.Tests")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
@ -0,0 +1,51 @@
|
||||
#nullable enable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MediaBrowser.Common.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Class BaseExtensions.
|
||||
/// </summary>
|
||||
public static class StreamExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads all lines in the <see cref="Stream" />.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream" /> to read from.</param>
|
||||
/// <returns>All lines in the stream.</returns>
|
||||
public static string[] ReadAllLines(this Stream stream)
|
||||
=> ReadAllLines(stream, Encoding.UTF8);
|
||||
|
||||
/// <summary>
|
||||
/// Reads all lines in the <see cref="Stream" />.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream" /> to read from.</param>
|
||||
/// <param name="encoding">The character encoding to use.</param>
|
||||
/// <returns>All lines in the stream.</returns>
|
||||
public static string[] ReadAllLines(this Stream stream, Encoding encoding)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(stream, encoding))
|
||||
{
|
||||
return ReadAllLines(reader).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads all lines in the <see cref="StreamReader" />.
|
||||
/// </summary>
|
||||
/// <param name="reader">The <see cref="StreamReader" /> to read from.</param>
|
||||
/// <returns>All lines in the stream.</returns>
|
||||
public static IEnumerable<string> ReadAllLines(this StreamReader reader)
|
||||
{
|
||||
string? line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
yield return line;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Common.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Extensions methods to simplify string operations.
|
||||
/// </summary>
|
||||
public static class StringExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the part on the left of the <c>needle</c>.
|
||||
/// </summary>
|
||||
/// <param name="haystack">The string to seek.</param>
|
||||
/// <param name="needle">The needle to find.</param>
|
||||
/// <returns>The part left of the <paramref name="needle" />.</returns>
|
||||
public static ReadOnlySpan<char> LeftPart(this ReadOnlySpan<char> haystack, char needle)
|
||||
{
|
||||
var pos = haystack.IndexOf(needle);
|
||||
return pos == -1 ? haystack : haystack[..pos];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the part on the left of the <c>needle</c>.
|
||||
/// </summary>
|
||||
/// <param name="haystack">The string to seek.</param>
|
||||
/// <param name="needle">The needle to find.</param>
|
||||
/// <param name="stringComparison">One of the enumeration values that specifies the rules for the search.</param>
|
||||
/// <returns>The part left of the <c>needle</c>.</returns>
|
||||
public static ReadOnlySpan<char> LeftPart(this ReadOnlySpan<char> haystack, ReadOnlySpan<char> needle, StringComparison stringComparison = default)
|
||||
{
|
||||
var pos = haystack.IndexOf(needle, stringComparison);
|
||||
return pos == -1 ? haystack : haystack[..pos];
|
||||
}
|
||||
}
|
||||
}
|
@ -1,130 +1,21 @@
|
||||
#pragma warning disable CS1591
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
{
|
||||
public class AssParser : ISubtitleParser
|
||||
/// <summary>
|
||||
/// Advanced SubStation Alpha subtitle parser.
|
||||
/// </summary>
|
||||
public class AssParser : SubtitleEditParser<AdvancedSubStationAlpha>
|
||||
{
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
|
||||
/// <inheritdoc />
|
||||
public SubtitleTrackInfo Parse(Stream stream, CancellationToken cancellationToken)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AssParser"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public AssParser(ILogger logger) : base(logger)
|
||||
{
|
||||
var trackInfo = new SubtitleTrackInfo();
|
||||
var trackEvents = new List<SubtitleTrackEvent>();
|
||||
var eventIndex = 1;
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
string line;
|
||||
while (!string.Equals(reader.ReadLine(), "[Events]", StringComparison.Ordinal))
|
||||
{
|
||||
}
|
||||
|
||||
var headers = ParseFieldHeaders(reader.ReadLine());
|
||||
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line[0] == '[')
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var subEvent = new SubtitleTrackEvent { Id = eventIndex.ToString(_usCulture) };
|
||||
eventIndex++;
|
||||
const string Dialogue = "Dialogue: ";
|
||||
var sections = line.Substring(Dialogue.Length).Split(',');
|
||||
|
||||
subEvent.StartPositionTicks = GetTicks(sections[headers["Start"]]);
|
||||
subEvent.EndPositionTicks = GetTicks(sections[headers["End"]]);
|
||||
|
||||
subEvent.Text = string.Join(',', sections[headers["Text"]..]);
|
||||
RemoteNativeFormatting(subEvent);
|
||||
|
||||
subEvent.Text = subEvent.Text.Replace("\\n", ParserValues.NewLine, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
subEvent.Text = Regex.Replace(subEvent.Text, @"\{(\\[\w]+\(?([\w0-9]+,?)+\)?)+\}", string.Empty, RegexOptions.IgnoreCase);
|
||||
|
||||
trackEvents.Add(subEvent);
|
||||
}
|
||||
}
|
||||
|
||||
trackInfo.TrackEvents = trackEvents;
|
||||
return trackInfo;
|
||||
}
|
||||
|
||||
private long GetTicks(ReadOnlySpan<char> time)
|
||||
{
|
||||
return TimeSpan.TryParseExact(time, @"h\:mm\:ss\.ff", _usCulture, out var span)
|
||||
? span.Ticks : 0;
|
||||
}
|
||||
|
||||
internal static Dictionary<string, int> ParseFieldHeaders(string line)
|
||||
{
|
||||
const string Format = "Format: ";
|
||||
var fields = line.Substring(Format.Length).Split(',').Select(x => x.Trim()).ToList();
|
||||
|
||||
return new Dictionary<string, int>
|
||||
{
|
||||
{ "Start", fields.IndexOf("Start") },
|
||||
{ "End", fields.IndexOf("End") },
|
||||
{ "Text", fields.IndexOf("Text") }
|
||||
};
|
||||
}
|
||||
|
||||
private void RemoteNativeFormatting(SubtitleTrackEvent p)
|
||||
{
|
||||
int indexOfBegin = p.Text.IndexOf('{', StringComparison.Ordinal);
|
||||
string pre = string.Empty;
|
||||
while (indexOfBegin >= 0 && p.Text.IndexOf('}', StringComparison.Ordinal) > indexOfBegin)
|
||||
{
|
||||
string s = p.Text.Substring(indexOfBegin);
|
||||
if (s.StartsWith("{\\an1}", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an2}", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an3}", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an4}", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an5}", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an6}", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an7}", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an8}", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an9}", StringComparison.Ordinal))
|
||||
{
|
||||
pre = s.Substring(0, 6);
|
||||
}
|
||||
else if (s.StartsWith("{\\an1\\", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an2\\", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an3\\", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an4\\", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an5\\", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an6\\", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an7\\", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an8\\", StringComparison.Ordinal) ||
|
||||
s.StartsWith("{\\an9\\", StringComparison.Ordinal))
|
||||
{
|
||||
pre = s.Substring(0, 5) + "}";
|
||||
}
|
||||
|
||||
int indexOfEnd = p.Text.IndexOf('}', StringComparison.Ordinal);
|
||||
p.Text = p.Text.Remove(indexOfBegin, (indexOfEnd - indexOfBegin) + 1);
|
||||
|
||||
indexOfBegin = p.Text.IndexOf('{', StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
p.Text = pre + p.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,102 +1,21 @@
|
||||
#pragma warning disable CS1591
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
{
|
||||
public class SrtParser : ISubtitleParser
|
||||
/// <summary>
|
||||
/// SubRip subtitle parser.
|
||||
/// </summary>
|
||||
public class SrtParser : SubtitleEditParser<SubRip>
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
|
||||
public SrtParser(ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public SubtitleTrackInfo Parse(Stream stream, CancellationToken cancellationToken)
|
||||
{
|
||||
var trackInfo = new SubtitleTrackInfo();
|
||||
var trackEvents = new List<SubtitleTrackEvent>();
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var subEvent = new SubtitleTrackEvent { Id = line };
|
||||
line = reader.ReadLine();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var time = Regex.Split(line, @"[\t ]*-->[\t ]*");
|
||||
|
||||
if (time.Length < 2)
|
||||
{
|
||||
// This occurs when subtitle text has an empty line as part of the text.
|
||||
// Need to adjust the break statement below to resolve this.
|
||||
_logger.LogWarning("Unrecognized line in srt: {0}", line);
|
||||
continue;
|
||||
}
|
||||
|
||||
subEvent.StartPositionTicks = GetTicks(time[0]);
|
||||
var endTime = time[1].AsSpan();
|
||||
var idx = endTime.IndexOf(' ');
|
||||
if (idx > 0)
|
||||
{
|
||||
endTime = endTime.Slice(0, idx);
|
||||
}
|
||||
|
||||
subEvent.EndPositionTicks = GetTicks(endTime);
|
||||
var multiline = new List<string>();
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
if (line.Length == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
multiline.Add(line);
|
||||
}
|
||||
|
||||
subEvent.Text = string.Join(ParserValues.NewLine, multiline);
|
||||
subEvent.Text = subEvent.Text.Replace(@"\N", ParserValues.NewLine, StringComparison.OrdinalIgnoreCase);
|
||||
subEvent.Text = Regex.Replace(subEvent.Text, @"\{(?:\\[0-9]?[\w.-]+(?:\([^\)]*\)|&H?[0-9A-Fa-f]+&|))+\}", string.Empty, RegexOptions.IgnoreCase);
|
||||
subEvent.Text = Regex.Replace(subEvent.Text, "<", "<", RegexOptions.IgnoreCase);
|
||||
subEvent.Text = Regex.Replace(subEvent.Text, ">", ">", RegexOptions.IgnoreCase);
|
||||
subEvent.Text = Regex.Replace(subEvent.Text, "<(\\/?(font|b|u|i|s))((\\s+(\\w|\\w[\\w\\-]*\\w)(\\s*=\\s*(?:\\\".*?\\\"|'.*?'|[^'\\\">\\s]+))?)+\\s*|\\s*)(\\/?)>", "<$1$3$7>", RegexOptions.IgnoreCase);
|
||||
trackEvents.Add(subEvent);
|
||||
}
|
||||
}
|
||||
|
||||
trackInfo.TrackEvents = trackEvents;
|
||||
return trackInfo;
|
||||
}
|
||||
|
||||
private long GetTicks(ReadOnlySpan<char> time)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SrtParser"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public SrtParser(ILogger logger) : base(logger)
|
||||
{
|
||||
return TimeSpan.TryParseExact(time, @"hh\:mm\:ss\.fff", _usCulture, out var span)
|
||||
? span.Ticks
|
||||
: (TimeSpan.TryParseExact(time, @"hh\:mm\:ss\,fff", _usCulture, out span)
|
||||
? span.Ticks : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,477 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
#nullable enable
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
{
|
||||
/// <summary>
|
||||
/// <see href="https://github.com/SubtitleEdit/subtitleedit/blob/a299dc4407a31796364cc6ad83f0d3786194ba22/src/Logic/SubtitleFormats/SubStationAlpha.cs">Credit</see>.
|
||||
/// SubStation Alpha subtitle parser.
|
||||
/// </summary>
|
||||
public class SsaParser : ISubtitleParser
|
||||
public class SsaParser : SubtitleEditParser<SubStationAlpha>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public SubtitleTrackInfo Parse(Stream stream, CancellationToken cancellationToken)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SsaParser"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public SsaParser(ILogger logger) : base(logger)
|
||||
{
|
||||
var trackInfo = new SubtitleTrackInfo();
|
||||
var trackEvents = new List<SubtitleTrackEvent>();
|
||||
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
bool eventsStarted = false;
|
||||
|
||||
string[] format = "Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text".Split(',');
|
||||
int indexLayer = 0;
|
||||
int indexStart = 1;
|
||||
int indexEnd = 2;
|
||||
int indexStyle = 3;
|
||||
int indexName = 4;
|
||||
int indexEffect = 8;
|
||||
int indexText = 9;
|
||||
int lineNumber = 0;
|
||||
|
||||
var header = new StringBuilder();
|
||||
|
||||
string line;
|
||||
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
lineNumber++;
|
||||
if (!eventsStarted)
|
||||
{
|
||||
header.AppendLine(line);
|
||||
}
|
||||
|
||||
if (string.Equals(line.Trim(), "[events]", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
eventsStarted = true;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(line) && line.Trim().StartsWith(';'))
|
||||
{
|
||||
// skip comment lines
|
||||
}
|
||||
else if (eventsStarted && line.Trim().Length > 0)
|
||||
{
|
||||
string s = line.Trim().ToLowerInvariant();
|
||||
if (s.StartsWith("format:", StringComparison.Ordinal))
|
||||
{
|
||||
if (line.Length > 10)
|
||||
{
|
||||
format = line.ToLowerInvariant().Substring(8).Split(',');
|
||||
for (int i = 0; i < format.Length; i++)
|
||||
{
|
||||
if (string.Equals(format[i].Trim(), "layer", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
indexLayer = i;
|
||||
}
|
||||
else if (string.Equals(format[i].Trim(), "start", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
indexStart = i;
|
||||
}
|
||||
else if (string.Equals(format[i].Trim(), "end", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
indexEnd = i;
|
||||
}
|
||||
else if (string.Equals(format[i].Trim(), "text", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
indexText = i;
|
||||
}
|
||||
else if (string.Equals(format[i].Trim(), "effect", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
indexEffect = i;
|
||||
}
|
||||
else if (string.Equals(format[i].Trim(), "style", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
indexStyle = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(s))
|
||||
{
|
||||
string text = string.Empty;
|
||||
string start = string.Empty;
|
||||
string end = string.Empty;
|
||||
string style = string.Empty;
|
||||
string layer = string.Empty;
|
||||
string effect = string.Empty;
|
||||
string name = string.Empty;
|
||||
|
||||
string[] splittedLine;
|
||||
|
||||
if (s.StartsWith("dialogue:", StringComparison.Ordinal))
|
||||
{
|
||||
splittedLine = line.Substring(10).Split(',');
|
||||
}
|
||||
else
|
||||
{
|
||||
splittedLine = line.Split(',');
|
||||
}
|
||||
|
||||
for (int i = 0; i < splittedLine.Length; i++)
|
||||
{
|
||||
if (i == indexStart)
|
||||
{
|
||||
start = splittedLine[i].Trim();
|
||||
}
|
||||
else if (i == indexEnd)
|
||||
{
|
||||
end = splittedLine[i].Trim();
|
||||
}
|
||||
else if (i == indexLayer)
|
||||
{
|
||||
layer = splittedLine[i];
|
||||
}
|
||||
else if (i == indexEffect)
|
||||
{
|
||||
effect = splittedLine[i];
|
||||
}
|
||||
else if (i == indexText)
|
||||
{
|
||||
text = splittedLine[i];
|
||||
}
|
||||
else if (i == indexStyle)
|
||||
{
|
||||
style = splittedLine[i];
|
||||
}
|
||||
else if (i == indexName)
|
||||
{
|
||||
name = splittedLine[i];
|
||||
}
|
||||
else if (i > indexText)
|
||||
{
|
||||
text += "," + splittedLine[i];
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
trackEvents.Add(
|
||||
new SubtitleTrackEvent
|
||||
{
|
||||
StartPositionTicks = GetTimeCodeFromString(start),
|
||||
EndPositionTicks = GetTimeCodeFromString(end),
|
||||
Text = GetFormattedText(text)
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (header.Length > 0)
|
||||
// subtitle.Header = header.ToString();
|
||||
|
||||
// subtitle.Renumber(1);
|
||||
}
|
||||
|
||||
trackInfo.TrackEvents = trackEvents.ToArray();
|
||||
return trackInfo;
|
||||
}
|
||||
|
||||
private static long GetTimeCodeFromString(string time)
|
||||
{
|
||||
// h:mm:ss.cc
|
||||
string[] timeCode = time.Split(':', '.');
|
||||
return new TimeSpan(
|
||||
0,
|
||||
int.Parse(timeCode[0], CultureInfo.InvariantCulture),
|
||||
int.Parse(timeCode[1], CultureInfo.InvariantCulture),
|
||||
int.Parse(timeCode[2], CultureInfo.InvariantCulture),
|
||||
int.Parse(timeCode[3], CultureInfo.InvariantCulture) * 10).Ticks;
|
||||
}
|
||||
|
||||
private static string GetFormattedText(string text)
|
||||
{
|
||||
text = text.Replace("\\n", ParserValues.NewLine, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
for (int i = 0; i < 10; i++) // just look ten times...
|
||||
{
|
||||
if (text.Contains(@"{\fn", StringComparison.Ordinal))
|
||||
{
|
||||
int start = text.IndexOf(@"{\fn", StringComparison.Ordinal);
|
||||
int end = text.IndexOf('}', start);
|
||||
if (end > 0 && !text.Substring(start).StartsWith("{\\fn}", StringComparison.Ordinal))
|
||||
{
|
||||
string fontName = text.Substring(start + 4, end - (start + 4));
|
||||
string extraTags = string.Empty;
|
||||
CheckAndAddSubTags(ref fontName, ref extraTags, out bool italic);
|
||||
text = text.Remove(start, end - start + 1);
|
||||
if (italic)
|
||||
{
|
||||
text = text.Insert(start, "<font face=\"" + fontName + "\"" + extraTags + "><i>");
|
||||
}
|
||||
else
|
||||
{
|
||||
text = text.Insert(start, "<font face=\"" + fontName + "\"" + extraTags + ">");
|
||||
}
|
||||
|
||||
int indexOfEndTag = text.IndexOf("{\\fn}", start, StringComparison.Ordinal);
|
||||
if (indexOfEndTag > 0)
|
||||
{
|
||||
text = text.Remove(indexOfEndTag, "{\\fn}".Length).Insert(indexOfEndTag, "</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
text += "</font>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (text.Contains(@"{\fs", StringComparison.Ordinal))
|
||||
{
|
||||
int start = text.IndexOf(@"{\fs", StringComparison.Ordinal);
|
||||
int end = text.IndexOf('}', start);
|
||||
if (end > 0 && !text.Substring(start).StartsWith("{\\fs}", StringComparison.Ordinal))
|
||||
{
|
||||
string fontSize = text.Substring(start + 4, end - (start + 4));
|
||||
string extraTags = string.Empty;
|
||||
CheckAndAddSubTags(ref fontSize, ref extraTags, out bool italic);
|
||||
if (IsInteger(fontSize))
|
||||
{
|
||||
text = text.Remove(start, end - start + 1);
|
||||
if (italic)
|
||||
{
|
||||
text = text.Insert(start, "<font size=\"" + fontSize + "\"" + extraTags + "><i>");
|
||||
}
|
||||
else
|
||||
{
|
||||
text = text.Insert(start, "<font size=\"" + fontSize + "\"" + extraTags + ">");
|
||||
}
|
||||
|
||||
int indexOfEndTag = text.IndexOf("{\\fs}", start, StringComparison.Ordinal);
|
||||
if (indexOfEndTag > 0)
|
||||
{
|
||||
text = text.Remove(indexOfEndTag, "{\\fs}".Length).Insert(indexOfEndTag, "</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
text += "</font>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (text.Contains(@"{\c", StringComparison.Ordinal))
|
||||
{
|
||||
int start = text.IndexOf(@"{\c", StringComparison.Ordinal);
|
||||
int end = text.IndexOf('}', start);
|
||||
if (end > 0 && !text.Substring(start).StartsWith("{\\c}", StringComparison.Ordinal))
|
||||
{
|
||||
string color = text.Substring(start + 4, end - (start + 4));
|
||||
string extraTags = string.Empty;
|
||||
CheckAndAddSubTags(ref color, ref extraTags, out bool italic);
|
||||
|
||||
color = color.Replace("&", string.Empty, StringComparison.Ordinal).TrimStart('H');
|
||||
color = color.PadLeft(6, '0');
|
||||
|
||||
// switch to rrggbb from bbggrr
|
||||
color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2);
|
||||
color = color.ToLowerInvariant();
|
||||
|
||||
text = text.Remove(start, end - start + 1);
|
||||
if (italic)
|
||||
{
|
||||
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + "><i>");
|
||||
}
|
||||
else
|
||||
{
|
||||
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + ">");
|
||||
}
|
||||
|
||||
int indexOfEndTag = text.IndexOf("{\\c}", start, StringComparison.Ordinal);
|
||||
if (indexOfEndTag > 0)
|
||||
{
|
||||
text = text.Remove(indexOfEndTag, "{\\c}".Length).Insert(indexOfEndTag, "</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
text += "</font>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (text.Contains(@"{\1c", StringComparison.Ordinal)) // "1" specifices primary color
|
||||
{
|
||||
int start = text.IndexOf(@"{\1c", StringComparison.Ordinal);
|
||||
int end = text.IndexOf('}', start);
|
||||
if (end > 0 && !text.Substring(start).StartsWith("{\\1c}", StringComparison.Ordinal))
|
||||
{
|
||||
string color = text.Substring(start + 5, end - (start + 5));
|
||||
string extraTags = string.Empty;
|
||||
CheckAndAddSubTags(ref color, ref extraTags, out bool italic);
|
||||
|
||||
color = color.Replace("&", string.Empty, StringComparison.Ordinal).TrimStart('H');
|
||||
color = color.PadLeft(6, '0');
|
||||
|
||||
// switch to rrggbb from bbggrr
|
||||
color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2);
|
||||
color = color.ToLowerInvariant();
|
||||
|
||||
text = text.Remove(start, end - start + 1);
|
||||
if (italic)
|
||||
{
|
||||
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + "><i>");
|
||||
}
|
||||
else
|
||||
{
|
||||
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + ">");
|
||||
}
|
||||
|
||||
int indexOfEndTag = text.IndexOf("{\\1c}", start, StringComparison.Ordinal);
|
||||
if (indexOfEndTag > 0)
|
||||
{
|
||||
text = text.Remove(indexOfEndTag, "{\\1c}".Length).Insert(indexOfEndTag, "</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
text += "</font>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
text = text.Replace(@"{\i1}", "<i>", StringComparison.Ordinal);
|
||||
text = text.Replace(@"{\i0}", "</i>", StringComparison.Ordinal);
|
||||
text = text.Replace(@"{\i}", "</i>", StringComparison.Ordinal);
|
||||
if (CountTagInText(text, "<i>") > CountTagInText(text, "</i>"))
|
||||
{
|
||||
text += "</i>";
|
||||
}
|
||||
|
||||
text = text.Replace(@"{\u1}", "<u>", StringComparison.Ordinal);
|
||||
text = text.Replace(@"{\u0}", "</u>", StringComparison.Ordinal);
|
||||
text = text.Replace(@"{\u}", "</u>", StringComparison.Ordinal);
|
||||
if (CountTagInText(text, "<u>") > CountTagInText(text, "</u>"))
|
||||
{
|
||||
text += "</u>";
|
||||
}
|
||||
|
||||
text = text.Replace(@"{\b1}", "<b>", StringComparison.Ordinal);
|
||||
text = text.Replace(@"{\b0}", "</b>", StringComparison.Ordinal);
|
||||
text = text.Replace(@"{\b}", "</b>", StringComparison.Ordinal);
|
||||
if (CountTagInText(text, "<b>") > CountTagInText(text, "</b>"))
|
||||
{
|
||||
text += "</b>";
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
private static bool IsInteger(string s)
|
||||
=> int.TryParse(s, out _);
|
||||
|
||||
private static int CountTagInText(string text, string tag)
|
||||
{
|
||||
int count = 0;
|
||||
int index = text.IndexOf(tag, StringComparison.Ordinal);
|
||||
while (index >= 0)
|
||||
{
|
||||
count++;
|
||||
if (index == text.Length)
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
index = text.IndexOf(tag, index + 1, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private static void CheckAndAddSubTags(ref string tagName, ref string extraTags, out bool italic)
|
||||
{
|
||||
italic = false;
|
||||
int indexOfSPlit = tagName.IndexOf('\\', StringComparison.Ordinal);
|
||||
if (indexOfSPlit > 0)
|
||||
{
|
||||
string rest = tagName.Substring(indexOfSPlit).TrimStart('\\');
|
||||
tagName = tagName.Remove(indexOfSPlit);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
if (rest.StartsWith("fs", StringComparison.Ordinal) && rest.Length > 2)
|
||||
{
|
||||
indexOfSPlit = rest.IndexOf('\\', StringComparison.Ordinal);
|
||||
string fontSize = rest;
|
||||
if (indexOfSPlit > 0)
|
||||
{
|
||||
fontSize = rest.Substring(0, indexOfSPlit);
|
||||
rest = rest.Substring(indexOfSPlit).TrimStart('\\');
|
||||
}
|
||||
else
|
||||
{
|
||||
rest = string.Empty;
|
||||
}
|
||||
|
||||
extraTags += " size=\"" + fontSize.Substring(2) + "\"";
|
||||
}
|
||||
else if (rest.StartsWith("fn", StringComparison.Ordinal) && rest.Length > 2)
|
||||
{
|
||||
indexOfSPlit = rest.IndexOf('\\', StringComparison.Ordinal);
|
||||
string fontName = rest;
|
||||
if (indexOfSPlit > 0)
|
||||
{
|
||||
fontName = rest.Substring(0, indexOfSPlit);
|
||||
rest = rest.Substring(indexOfSPlit).TrimStart('\\');
|
||||
}
|
||||
else
|
||||
{
|
||||
rest = string.Empty;
|
||||
}
|
||||
|
||||
extraTags += " face=\"" + fontName.Substring(2) + "\"";
|
||||
}
|
||||
else if (rest.StartsWith("c", StringComparison.Ordinal) && rest.Length > 2)
|
||||
{
|
||||
indexOfSPlit = rest.IndexOf('\\', StringComparison.Ordinal);
|
||||
string fontColor = rest;
|
||||
if (indexOfSPlit > 0)
|
||||
{
|
||||
fontColor = rest.Substring(0, indexOfSPlit);
|
||||
rest = rest.Substring(indexOfSPlit).TrimStart('\\');
|
||||
}
|
||||
else
|
||||
{
|
||||
rest = string.Empty;
|
||||
}
|
||||
|
||||
string color = fontColor.Substring(2);
|
||||
color = color.Replace("&", string.Empty, StringComparison.Ordinal).TrimStart('H');
|
||||
color = color.PadLeft(6, '0');
|
||||
// switch to rrggbb from bbggrr
|
||||
color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2);
|
||||
color = color.ToLowerInvariant();
|
||||
|
||||
extraTags += " color=\"" + color + "\"";
|
||||
}
|
||||
else if (rest.StartsWith("i1", StringComparison.Ordinal) && rest.Length > 1)
|
||||
{
|
||||
indexOfSPlit = rest.IndexOf('\\', StringComparison.Ordinal);
|
||||
italic = true;
|
||||
if (indexOfSPlit > 0)
|
||||
{
|
||||
rest = rest.Substring(indexOfSPlit).TrimStart('\\');
|
||||
}
|
||||
else
|
||||
{
|
||||
rest = string.Empty;
|
||||
}
|
||||
}
|
||||
else if (rest.Length > 0 && rest.Contains('\\', StringComparison.Ordinal))
|
||||
{
|
||||
indexOfSPlit = rest.IndexOf('\\', StringComparison.Ordinal);
|
||||
rest = rest.Substring(indexOfSPlit).TrimStart('\\');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
#nullable enable
|
||||
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Nikse.SubtitleEdit.Core;
|
||||
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||
using SubtitleFormat = Nikse.SubtitleEdit.Core.SubtitleFormats.SubtitleFormat;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
{
|
||||
/// <summary>
|
||||
/// SubStation Alpha subtitle parser.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The <see cref="SubtitleFormat" />.</typeparam>
|
||||
public abstract class SubtitleEditParser<T> : ISubtitleParser
|
||||
where T : SubtitleFormat, new()
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SubtitleEditParser{T}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
protected SubtitleEditParser(ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public SubtitleTrackInfo Parse(Stream stream, CancellationToken cancellationToken)
|
||||
{
|
||||
var subtitle = new Subtitle();
|
||||
var subRip = new T();
|
||||
var lines = stream.ReadAllLines().ToList();
|
||||
subRip.LoadSubtitle(subtitle, lines, "untitled");
|
||||
if (subRip.ErrorCount > 0)
|
||||
{
|
||||
_logger.LogError("{ErrorCount} errors encountered while parsing subtitle.");
|
||||
}
|
||||
|
||||
var trackInfo = new SubtitleTrackInfo();
|
||||
int len = subtitle.Paragraphs.Count;
|
||||
var trackEvents = new SubtitleTrackEvent[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
var p = subtitle.Paragraphs[i];
|
||||
trackEvents[i] = new SubtitleTrackEvent(p.Number.ToString(CultureInfo.InvariantCulture), p.Text)
|
||||
{
|
||||
StartPositionTicks = p.StartTime.TimeSpan.Ticks,
|
||||
EndPositionTicks = p.EndTime.TimeSpan.Ticks
|
||||
};
|
||||
}
|
||||
|
||||
trackInfo.TrackEvents = trackEvents;
|
||||
return trackInfo;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
#nullable disable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
namespace MediaBrowser.Model.Configuration
|
||||
{
|
||||
public class MediaPathInfo
|
||||
{
|
||||
public string Path { get; set; }
|
||||
|
||||
public string NetworkPath { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,365 @@
|
||||
#nullable disable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Model.Configuration
|
||||
{
|
||||
public class TypeOptions
|
||||
{
|
||||
public static readonly ImageOption DefaultInstance = new ImageOption();
|
||||
|
||||
public static readonly Dictionary<string, ImageOption[]> DefaultImageOptions = new Dictionary<string, ImageOption[]>
|
||||
{
|
||||
{
|
||||
"Movie", new[]
|
||||
{
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
MinWidth = 1280,
|
||||
Type = ImageType.Backdrop
|
||||
},
|
||||
|
||||
// Don't download this by default as it's rarely used.
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Art
|
||||
},
|
||||
|
||||
// Don't download this by default as it's rarely used.
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Disc
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Primary
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Banner
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Thumb
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Logo
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"MusicVideo", new[]
|
||||
{
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
MinWidth = 1280,
|
||||
Type = ImageType.Backdrop
|
||||
},
|
||||
|
||||
// Don't download this by default as it's rarely used.
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Art
|
||||
},
|
||||
|
||||
// Don't download this by default as it's rarely used.
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Disc
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Primary
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Banner
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Thumb
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Logo
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Series", new[]
|
||||
{
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
MinWidth = 1280,
|
||||
Type = ImageType.Backdrop
|
||||
},
|
||||
|
||||
// Don't download this by default as it's rarely used.
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Art
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Primary
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Banner
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Thumb
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Logo
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"MusicAlbum", new[]
|
||||
{
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
MinWidth = 1280,
|
||||
Type = ImageType.Backdrop
|
||||
},
|
||||
|
||||
// Don't download this by default as it's rarely used.
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Disc
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"MusicArtist", new[]
|
||||
{
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
MinWidth = 1280,
|
||||
Type = ImageType.Backdrop
|
||||
},
|
||||
|
||||
// Don't download this by default
|
||||
// They do look great, but most artists won't have them, which means a banner view isn't really possible
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Banner
|
||||
},
|
||||
|
||||
// Don't download this by default
|
||||
// Generally not used
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Art
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Logo
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"BoxSet", new[]
|
||||
{
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
MinWidth = 1280,
|
||||
Type = ImageType.Backdrop
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Primary
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Thumb
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Logo
|
||||
},
|
||||
|
||||
// Don't download this by default as it's rarely used.
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Art
|
||||
},
|
||||
|
||||
// Don't download this by default as it's rarely used.
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Disc
|
||||
},
|
||||
|
||||
// Don't download this by default as it's rarely used.
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Banner
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Season", new[]
|
||||
{
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
MinWidth = 1280,
|
||||
Type = ImageType.Backdrop
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Primary
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Banner
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
Type = ImageType.Thumb
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Episode", new[]
|
||||
{
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 0,
|
||||
MinWidth = 1280,
|
||||
Type = ImageType.Backdrop
|
||||
},
|
||||
|
||||
new ImageOption
|
||||
{
|
||||
Limit = 1,
|
||||
Type = ImageType.Primary
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public TypeOptions()
|
||||
{
|
||||
MetadataFetchers = Array.Empty<string>();
|
||||
MetadataFetcherOrder = Array.Empty<string>();
|
||||
ImageFetchers = Array.Empty<string>();
|
||||
ImageFetcherOrder = Array.Empty<string>();
|
||||
ImageOptions = Array.Empty<ImageOption>();
|
||||
}
|
||||
|
||||
public string Type { get; set; }
|
||||
|
||||
public string[] MetadataFetchers { get; set; }
|
||||
|
||||
public string[] MetadataFetcherOrder { get; set; }
|
||||
|
||||
public string[] ImageFetchers { get; set; }
|
||||
|
||||
public string[] ImageFetcherOrder { get; set; }
|
||||
|
||||
public ImageOption[] ImageOptions { get; set; }
|
||||
|
||||
public ImageOption GetImageOptions(ImageType type)
|
||||
{
|
||||
foreach (var i in ImageOptions)
|
||||
{
|
||||
if (i.Type == type)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
if (DefaultImageOptions.TryGetValue(Type, out ImageOption[] options))
|
||||
{
|
||||
foreach (var i in options)
|
||||
{
|
||||
if (i.Type == type)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DefaultInstance;
|
||||
}
|
||||
|
||||
public int GetLimit(ImageType type)
|
||||
{
|
||||
return GetImageOptions(type).Limit;
|
||||
}
|
||||
|
||||
public int GetMinWidth(ImageType type)
|
||||
{
|
||||
return GetImageOptions(type).MinWidth;
|
||||
}
|
||||
|
||||
public bool IsEnabled(ImageType type)
|
||||
{
|
||||
return GetLimit(type) > 0;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,14 @@
|
||||
#nullable disable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Dto
|
||||
{
|
||||
public class NameGuidPair
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
#nullable disable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Entities
|
||||
{
|
||||
public class PackageReviewInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the package id (database key) for this review.
|
||||
/// </summary>
|
||||
public int id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the rating value.
|
||||
/// </summary>
|
||||
public int rating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether or not this review recommends this item.
|
||||
/// </summary>
|
||||
public bool recommend { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a short description of the review.
|
||||
/// </summary>
|
||||
public string title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the full review.
|
||||
/// </summary>
|
||||
public string review { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time of review.
|
||||
/// </summary>
|
||||
public DateTime timestamp { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
namespace MediaBrowser.Model.Entities
|
||||
{
|
||||
public static class SpecialFolder
|
||||
{
|
||||
public const string TvShowSeries = "TvShowSeries";
|
||||
public const string TvGenres = "TvGenres";
|
||||
public const string TvGenre = "TvGenre";
|
||||
public const string TvLatest = "TvLatest";
|
||||
public const string TvNextUp = "TvNextUp";
|
||||
public const string TvResume = "TvResume";
|
||||
public const string TvFavoriteSeries = "TvFavoriteSeries";
|
||||
public const string TvFavoriteEpisodes = "TvFavoriteEpisodes";
|
||||
|
||||
public const string MovieLatest = "MovieLatest";
|
||||
public const string MovieResume = "MovieResume";
|
||||
public const string MovieMovies = "MovieMovies";
|
||||
public const string MovieCollections = "MovieCollections";
|
||||
public const string MovieFavorites = "MovieFavorites";
|
||||
public const string MovieGenres = "MovieGenres";
|
||||
public const string MovieGenre = "MovieGenre";
|
||||
|
||||
public const string MusicArtists = "MusicArtists";
|
||||
public const string MusicAlbumArtists = "MusicAlbumArtists";
|
||||
public const string MusicAlbums = "MusicAlbums";
|
||||
public const string MusicGenres = "MusicGenres";
|
||||
public const string MusicLatest = "MusicLatest";
|
||||
public const string MusicPlaylists = "MusicPlaylists";
|
||||
public const string MusicSongs = "MusicSongs";
|
||||
public const string MusicFavorites = "MusicFavorites";
|
||||
public const string MusicFavoriteArtists = "MusicFavoriteArtists";
|
||||
public const string MusicFavoriteAlbums = "MusicFavoriteAlbums";
|
||||
public const string MusicFavoriteSongs = "MusicFavoriteSongs";
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue