mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-18 08:06:35 +00:00
Remove MediaBrowser.Text since it violates licenses and is overall hacky
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BDInfo;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Text;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.BdInfo
|
||||
{
|
||||
@@ -15,12 +14,10 @@ namespace MediaBrowser.MediaEncoding.BdInfo
|
||||
public class BdInfoExaminer : IBlurayExaminer
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ITextEncoding _textEncoding;
|
||||
|
||||
public BdInfoExaminer(IFileSystem fileSystem, ITextEncoding textEncoding)
|
||||
public BdInfoExaminer(IFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_textEncoding = textEncoding;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -35,7 +32,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo
|
||||
throw new ArgumentNullException(nameof(path));
|
||||
}
|
||||
|
||||
var bdrom = new BDROM(path, _fileSystem, _textEncoding);
|
||||
var bdrom = new BDROM(path, _fileSystem);
|
||||
|
||||
bdrom.Scan();
|
||||
|
||||
|
||||
@@ -17,4 +17,14 @@
|
||||
<ProjectReference Include="..\OpenSubtitlesHandler\OpenSubtitlesHandler.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="UTF.Unknown" Version="1.0.0-beta1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<HintPath>..\..\..\.nuget\packages\system.text.encoding.codepages\4.5.0\ref\netstandard2.0\System.Text.Encoding.CodePages.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -18,8 +18,8 @@ using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Text;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using UtfUnknown;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
{
|
||||
@@ -34,10 +34,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
private readonly IProcessFactory _processFactory;
|
||||
private readonly ITextEncoding _textEncoding;
|
||||
|
||||
public SubtitleEncoder(
|
||||
ILibraryManager libraryManager,
|
||||
public SubtitleEncoder(ILibraryManager libraryManager,
|
||||
ILogger logger,
|
||||
IApplicationPaths appPaths,
|
||||
IFileSystem fileSystem,
|
||||
@@ -45,8 +43,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
IJsonSerializer json,
|
||||
IHttpClient httpClient,
|
||||
IMediaSourceManager mediaSourceManager,
|
||||
IProcessFactory processFactory,
|
||||
ITextEncoding textEncoding)
|
||||
IProcessFactory processFactory)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_logger = logger;
|
||||
@@ -57,7 +54,6 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
_httpClient = httpClient;
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
_processFactory = processFactory;
|
||||
_textEncoding = textEncoding;
|
||||
}
|
||||
|
||||
private string SubtitleCachePath => Path.Combine(_appPaths.DataPath, "subtitles");
|
||||
@@ -196,13 +192,15 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
{
|
||||
var bytes = await GetBytes(path, protocol, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var charset = _textEncoding.GetDetectedEncodingName(bytes, bytes.Length, language, true);
|
||||
_logger.LogDebug("charset {0} detected for {1}", charset ?? "null", path);
|
||||
var charset = CharsetDetector.DetectFromBytes(bytes).Detected?.EncodingName;
|
||||
_logger.LogDebug("charset {CharSet} detected for {Path}", charset ?? "null", path);
|
||||
|
||||
if (!string.IsNullOrEmpty(charset))
|
||||
{
|
||||
// Make sure we have all the code pages we can get
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
using (var inputStream = new MemoryStream(bytes))
|
||||
using (var reader = new StreamReader(inputStream, _textEncoding.GetEncodingFromCharset(charset)))
|
||||
using (var reader = new StreamReader(inputStream, Encoding.GetEncoding(charset)))
|
||||
{
|
||||
var text = await reader.ReadToEndAsync().ConfigureAwait(false);
|
||||
|
||||
@@ -723,7 +721,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
{
|
||||
var bytes = await GetBytes(path, protocol, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var charset = _textEncoding.GetDetectedEncodingName(bytes, bytes.Length, language, true);
|
||||
var charset = CharsetDetector.DetectFromBytes(bytes).Detected?.EncodingName;
|
||||
|
||||
_logger.LogDebug("charset {0} detected for {Path}", charset ?? "null", path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user