mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
add loopback handler
This commit is contained in:
parent
adeb944c61
commit
2d7c82d0dd
@ -70,12 +70,13 @@ namespace MediaBrowser.Api
|
||||
Cultures = _localizationManager.GetCultures().ToList()
|
||||
};
|
||||
|
||||
if (!item.IsVirtualItem && !(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder) && !(item is LiveTvChannel) && !(item is IItemByName))
|
||||
if (!item.IsVirtualItem && !(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder) && !(item is LiveTvChannel) && !(item is IItemByName) &&
|
||||
item.SourceType == SourceType.Library)
|
||||
{
|
||||
var inheritedContentType = _libraryManager.GetInheritedContentType(item);
|
||||
var configuredContentType = _libraryManager.GetConfiguredContentType(item);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(inheritedContentType) || string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || !string.IsNullOrWhiteSpace(configuredContentType))
|
||||
if (string.IsNullOrWhiteSpace(inheritedContentType) || !string.IsNullOrWhiteSpace(configuredContentType))
|
||||
{
|
||||
info.ContentTypeOptions = GetContentTypeOptions(true);
|
||||
info.ContentType = configuredContentType;
|
||||
|
@ -89,5 +89,7 @@ namespace MediaBrowser.Controller
|
||||
string GetLocalApiUrl(IPAddress ipAddress);
|
||||
|
||||
void LaunchUrl(string url);
|
||||
|
||||
void EnableLoopback(string appName);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,6 @@
|
||||
<Compile Include="Parsers\MovieXmlParser.cs" />
|
||||
<Compile Include="Parsers\MusicVideoXmlParser.cs" />
|
||||
<Compile Include="Parsers\PlaylistXmlParser.cs" />
|
||||
<Compile Include="Parsers\SeasonXmlParser.cs" />
|
||||
<Compile Include="Parsers\SeriesXmlParser.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Providers\BoxSetXmlProvider.cs" />
|
||||
@ -75,7 +74,6 @@
|
||||
<Compile Include="Providers\MusicVideoXmlProvider.cs" />
|
||||
<Compile Include="Providers\PersonXmlProvider.cs" />
|
||||
<Compile Include="Providers\PlaylistXmlProvider.cs" />
|
||||
<Compile Include="Providers\SeasonXmlProvider.cs" />
|
||||
<Compile Include="Providers\SeriesXmlProvider.cs" />
|
||||
<Compile Include="Providers\VideoXmlProvider.cs" />
|
||||
<Compile Include="Savers\BoxSetXmlSaver.cs" />
|
||||
|
@ -1,48 +0,0 @@
|
||||
using System.Xml;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.LocalMetadata.Parsers
|
||||
{
|
||||
public class SeasonXmlParser : BaseItemXmlParser<Season>
|
||||
{
|
||||
public SeasonXmlParser(ILogger logger, IProviderManager providerManager)
|
||||
: base(logger, providerManager)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="result">The result.</param>
|
||||
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<Season> result)
|
||||
{
|
||||
var item = result.Item;
|
||||
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "SeasonNumber":
|
||||
{
|
||||
var number = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(number))
|
||||
{
|
||||
int num;
|
||||
|
||||
if (int.TryParse(number, out num))
|
||||
{
|
||||
item.IndexNumber = num;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
base.FetchDataFromXmlNode(reader, result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using CommonIO;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.LocalMetadata.Parsers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.LocalMetadata.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Class SeriesProviderFromXml
|
||||
/// </summary>
|
||||
public class SeasonXmlProvider : BaseXmlProvider<Season>, IHasOrder
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProviderManager _providerManager;
|
||||
|
||||
public SeasonXmlProvider(IFileSystem fileSystem, ILogger logger, IProviderManager providerManager)
|
||||
: base(fileSystem)
|
||||
{
|
||||
_logger = logger;
|
||||
_providerManager = providerManager;
|
||||
}
|
||||
|
||||
protected override void Fetch(MetadataResult<Season> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
new SeasonXmlParser(_logger, _providerManager).Fetch(result, path, cancellationToken);
|
||||
}
|
||||
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
{
|
||||
return directoryService.GetFile(Path.Combine(info.Path, "season.xml"));
|
||||
}
|
||||
|
||||
public int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
// After Xbmc
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -818,14 +818,17 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
|
||||
public string GetSubtitleFileCharacterSetFromLanguage(string language)
|
||||
{
|
||||
// https://developer.xamarin.com/api/type/System.Text.Encoding/
|
||||
|
||||
switch (language.ToLower())
|
||||
{
|
||||
case "hun":
|
||||
return "windows-1252";
|
||||
case "pol":
|
||||
case "cze":
|
||||
case "ces":
|
||||
case "slo":
|
||||
case "slk":
|
||||
case "hun":
|
||||
case "slv":
|
||||
case "srp":
|
||||
case "hrv":
|
||||
|
@ -53,15 +53,15 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
protected override Series Resolve(ItemResolveArgs args)
|
||||
{
|
||||
if (args.IsDirectory)
|
||||
{
|
||||
var collectionType = args.GetCollectionType();
|
||||
if (string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (args.HasParent<Series>())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = args.GetCollectionType();
|
||||
if (string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var configuredContentType = _libraryManager.GetConfiguredContentType(args.Path);
|
||||
if (!string.Equals(configuredContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@ -76,11 +76,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(collectionType))
|
||||
{
|
||||
if (args.HasParent<Series>())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (args.Parent.IsRoot)
|
||||
{
|
||||
return null;
|
||||
|
@ -30,7 +30,7 @@ namespace MediaBrowser.Server.Implementations.Udp
|
||||
|
||||
private bool _isDisposed;
|
||||
|
||||
private readonly List<Tuple<string, byte[], Action<string, Encoding>>> _responders = new List<Tuple<string, byte[], Action<string, Encoding>>>();
|
||||
private readonly List<Tuple<string, bool, Func<string, string, Encoding, Task>>> _responders = new List<Tuple<string, bool, Func<string, string, Encoding, Task>>>();
|
||||
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly IJsonSerializer _json;
|
||||
@ -49,42 +49,35 @@ namespace MediaBrowser.Server.Implementations.Udp
|
||||
_appHost = appHost;
|
||||
_json = json;
|
||||
|
||||
AddMessageResponder("who is EmbyServer?", RespondToV2Message);
|
||||
AddMessageResponder("who is MediaBrowserServer_v2?", RespondToV2Message);
|
||||
AddMessageResponder("who is EmbyServer?", true, RespondToV2Message);
|
||||
AddMessageResponder("who is MediaBrowserServer_v2?", false, RespondToV2Message);
|
||||
}
|
||||
|
||||
private void AddMessageResponder(string message, Action<string, Encoding> responder)
|
||||
private void AddMessageResponder(string message, bool isSubstring, Func<string, string, Encoding, Task> responder)
|
||||
{
|
||||
var expectedMessageBytes = Encoding.UTF8.GetBytes(message);
|
||||
|
||||
_responders.Add(new Tuple<string, byte[], Action<string, Encoding>>(message, expectedMessageBytes, responder));
|
||||
_responders.Add(new Tuple<string, bool, Func<string, string, Encoding, Task>>(message, isSubstring, responder));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:MessageReceived" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="UdpMessageReceivedEventArgs"/> instance containing the event data.</param>
|
||||
private void OnMessageReceived(UdpMessageReceivedEventArgs e)
|
||||
private async void OnMessageReceived(UdpMessageReceivedEventArgs e)
|
||||
{
|
||||
var responder = _responders.FirstOrDefault(i => i.Item2.SequenceEqual(e.Bytes));
|
||||
var encoding = Encoding.UTF8;
|
||||
var responder = GetResponder(e.Bytes, encoding);
|
||||
|
||||
if (responder == null)
|
||||
{
|
||||
var text = Encoding.Unicode.GetString(e.Bytes);
|
||||
responder = _responders.FirstOrDefault(i => string.Equals(i.Item1, text, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (responder != null)
|
||||
{
|
||||
encoding = Encoding.Unicode;
|
||||
}
|
||||
responder = GetResponder(e.Bytes, encoding);
|
||||
}
|
||||
|
||||
if (responder != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
responder.Item3(e.RemoteEndPoint, encoding);
|
||||
await responder.Item2.Item3(responder.Item1, e.RemoteEndPoint, encoding).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -93,8 +86,34 @@ namespace MediaBrowser.Server.Implementations.Udp
|
||||
}
|
||||
}
|
||||
|
||||
private async void RespondToV2Message(string endpoint, Encoding encoding)
|
||||
private Tuple<string, Tuple<string, bool, Func<string, string, Encoding, Task>>> GetResponder(byte[] bytes, Encoding encoding)
|
||||
{
|
||||
var text = encoding.GetString(bytes);
|
||||
var responder = _responders.FirstOrDefault(i =>
|
||||
{
|
||||
if (i.Item2)
|
||||
{
|
||||
return text.IndexOf(i.Item1, StringComparison.OrdinalIgnoreCase) != -1;
|
||||
}
|
||||
return string.Equals(i.Item1, text, StringComparison.OrdinalIgnoreCase);
|
||||
});
|
||||
|
||||
if (responder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Tuple<string, Tuple<string, bool, Func<string, string, Encoding, Task>>>(text, responder);
|
||||
}
|
||||
|
||||
private async Task RespondToV2Message(string messageText, string endpoint, Encoding encoding)
|
||||
{
|
||||
var parts = messageText.Split('|');
|
||||
|
||||
if (parts.Length > 1)
|
||||
{
|
||||
_appHost.EnableLoopback(parts[1]);
|
||||
}
|
||||
|
||||
var localUrl = await _appHost.GetLocalApiUrl().ConfigureAwait(false);
|
||||
|
||||
if (!string.IsNullOrEmpty(localUrl))
|
||||
@ -106,7 +125,7 @@ namespace MediaBrowser.Server.Implementations.Udp
|
||||
Name = _appHost.FriendlyName
|
||||
};
|
||||
|
||||
await SendAsync(encoding.GetBytes(_json.SerializeToString(response)), endpoint);
|
||||
await SendAsync(encoding.GetBytes(_json.SerializeToString(response)), endpoint).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -278,6 +278,11 @@ namespace MediaBrowser.Server.Mono.Native
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public void EnableLoopback(string appName)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class NullPowerManagement : IPowerManagement
|
||||
|
@ -1392,5 +1392,10 @@ namespace MediaBrowser.Server.Startup.Common
|
||||
{
|
||||
NativeApp.LaunchUrl(url);
|
||||
}
|
||||
|
||||
public void EnableLoopback(string appName)
|
||||
{
|
||||
NativeApp.EnableLoopback(appName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,5 +107,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||
void LaunchUrl(string url);
|
||||
|
||||
IDbConnector GetDbConnector();
|
||||
|
||||
void EnableLoopback(string appName);
|
||||
}
|
||||
}
|
||||
|
@ -292,15 +292,6 @@ namespace MediaBrowser.ServerApplication
|
||||
ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
LoopUtil.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logManager.GetLogger("LoopUtil").ErrorException("Error in LoopUtil", ex);
|
||||
}
|
||||
|
||||
var task = _appHost.Init(initProgress);
|
||||
Task.WaitAll(task);
|
||||
|
||||
|
@ -192,12 +192,12 @@ namespace MediaBrowser.ServerApplication.Native
|
||||
return hasChanges;
|
||||
}
|
||||
|
||||
public static void Run()
|
||||
public static void Run(string appName)
|
||||
{
|
||||
var util = new LoopUtil();
|
||||
util.LoadApps();
|
||||
|
||||
var hasChanges = util.CreateExcemptions("Emby");
|
||||
var hasChanges = util.CreateExcemptions(appName);
|
||||
|
||||
if (hasChanges)
|
||||
{
|
||||
|
@ -203,5 +203,10 @@ namespace MediaBrowser.ServerApplication.Native
|
||||
{
|
||||
((Process)sender).Dispose();
|
||||
}
|
||||
|
||||
public void EnableLoopback(string appName)
|
||||
{
|
||||
LoopUtil.Run(appName);
|
||||
}
|
||||
}
|
||||
}
|
@ -65,6 +65,9 @@ EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing", "Emby.Drawing\Emby.Drawing.csproj", "{08FFF49B-F175-4807-A2B5-73B0EBD9F716}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
|
@ -2,7 +2,7 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common.Internal</id>
|
||||
<version>3.0.656</version>
|
||||
<version>3.0.657</version>
|
||||
<title>MediaBrowser.Common.Internal</title>
|
||||
<authors>Luke</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
@ -12,7 +12,7 @@
|
||||
<description>Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption.</description>
|
||||
<copyright>Copyright © Emby 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.656" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.657" />
|
||||
<dependency id="NLog" version="4.3.6" />
|
||||
<dependency id="SimpleInjector" version="3.2.0" />
|
||||
</dependencies>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common</id>
|
||||
<version>3.0.656</version>
|
||||
<version>3.0.657</version>
|
||||
<title>MediaBrowser.Common</title>
|
||||
<authors>Emby Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Server.Core</id>
|
||||
<version>3.0.656</version>
|
||||
<version>3.0.657</version>
|
||||
<title>Media Browser.Server.Core</title>
|
||||
<authors>Emby Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
@ -12,7 +12,7 @@
|
||||
<description>Contains core components required to build plugins for Emby Server.</description>
|
||||
<copyright>Copyright © Emby 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.656" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.657" />
|
||||
<dependency id="Interfaces.IO" version="1.0.0.5" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
|
Loading…
Reference in New Issue
Block a user