mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-17 03:33:46 +01:00
Tweaked plugin downloading a bit
This commit is contained in:
parent
7f8a477278
commit
fc735e9187
@@ -590,15 +590,34 @@ namespace MediaBrowser.ApiInteraction
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets weather information for the default location as set in configuration
|
||||
/// Gets the current server configuration
|
||||
/// </summary>
|
||||
public async Task<ServerConfiguration> GetServerConfigurationAsync()
|
||||
{
|
||||
string url = ApiUrl + "/ServerConfiguration";
|
||||
|
||||
using (Stream stream = await GetSerializedStreamAsync(url, ApiInteraction.SerializationFormat.Json).ConfigureAwait(false))
|
||||
// At the moment this can't be retrieved in protobuf format
|
||||
SerializationFormat format = DataSerializer.CanDeserializeJsv ? SerializationFormat.Jsv : ApiInteraction.SerializationFormat.Json;
|
||||
|
||||
using (Stream stream = await GetSerializedStreamAsync(url, format).ConfigureAwait(false))
|
||||
{
|
||||
return DeserializeFromStream<ServerConfiguration>(stream, ApiInteraction.SerializationFormat.Json);
|
||||
return DeserializeFromStream<ServerConfiguration>(stream, format);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets weather information for the default location as set in configuration
|
||||
/// </summary>
|
||||
public async Task<object> GetPluginConfigurationAsync(PluginInfo plugin, Type configurationType)
|
||||
{
|
||||
string url = ApiUrl + "/PluginConfiguration?assemblyfilename=" + plugin.AssemblyFileName;
|
||||
|
||||
// At the moment this can't be retrieved in protobuf format
|
||||
SerializationFormat format = DataSerializer.CanDeserializeJsv ? SerializationFormat.Jsv : ApiInteraction.SerializationFormat.Json;
|
||||
|
||||
using (Stream stream = await GetSerializedStreamAsync(url, format).ConfigureAwait(false))
|
||||
{
|
||||
return DeserializeFromStream(stream, format, configurationType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -685,6 +704,20 @@ namespace MediaBrowser.ApiInteraction
|
||||
return DataSerializer.DeserializeJsonFromStream<T>(stream);
|
||||
}
|
||||
|
||||
private object DeserializeFromStream(Stream stream, SerializationFormat format, Type type)
|
||||
{
|
||||
if (format == ApiInteraction.SerializationFormat.Protobuf)
|
||||
{
|
||||
return DataSerializer.DeserializeProtobufFromStream(stream, type);
|
||||
}
|
||||
if (format == ApiInteraction.SerializationFormat.Jsv)
|
||||
{
|
||||
return DataSerializer.DeserializeJsvFromStream(stream, type);
|
||||
}
|
||||
|
||||
return DataSerializer.DeserializeJsonFromStream(stream, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is just a helper around HttpClient
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MediaBrowser.ApiInteraction
|
||||
{
|
||||
@@ -11,6 +12,10 @@ namespace MediaBrowser.ApiInteraction
|
||||
T DeserializeJsvFromStream<T>(Stream stream);
|
||||
T DeserializeProtobufFromStream<T>(Stream stream);
|
||||
|
||||
object DeserializeJsonFromStream(Stream stream, Type type);
|
||||
object DeserializeJsvFromStream(Stream stream, Type type);
|
||||
object DeserializeProtobufFromStream(Stream stream, Type type);
|
||||
|
||||
bool CanDeserializeJsv { get; }
|
||||
bool CanDeserializeProtobuf { get; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user