add sat ini mappings

This commit is contained in:
Luke Pulverenti 2016-03-17 14:19:39 -04:00
parent 86a8c0805f
commit 14b9f94e0a
5 changed files with 57 additions and 0 deletions

View File

@ -478,6 +478,13 @@ namespace MediaBrowser.Api.LiveTv
public string Feature { get; set; }
}
[Route("/LiveTv/TunerHosts/Satip/IniMappings", "GET", Summary = "Gets available mappings")]
[Authenticated(AllowBeforeStartupWizard = true)]
public class GetSatIniMappings : IReturn<List<NameValuePair>>
{
}
public class LiveTvService : BaseApiService
{
private readonly ILiveTvManager _liveTvManager;
@ -500,6 +507,11 @@ namespace MediaBrowser.Api.LiveTv
return ToOptimizedResult(result);
}
public object Get(GetSatIniMappings request)
{
return ToOptimizedResult(_liveTvManager.GetSatIniMappings());
}
public async Task<object> Get(GetSchedulesDirectCountries request)
{
// https://json.schedulesdirect.org/20141201/available/countries

View File

@ -397,5 +397,11 @@ namespace MediaBrowser.Controller.LiveTv
/// <param name="recording">The recording.</param>
/// <returns>Task.</returns>
Task OnRecordingFileDeleted(ILiveTvRecording recording);
/// <summary>
/// Gets the sat ini mappings.
/// </summary>
/// <returns>List&lt;NameValuePair&gt;.</returns>
List<NameValuePair> GetSatIniMappings();
}
}

View File

@ -30,6 +30,8 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using IniParser;
using IniParser.Model;
namespace MediaBrowser.Server.Implementations.LiveTv
{
@ -2488,5 +2490,38 @@ namespace MediaBrowser.Server.Implementations.LiveTv
IsRegistered = true
});
}
public List<NameValuePair> GetSatIniMappings()
{
var names = GetType().Assembly.GetManifestResourceNames().Where(i => i.IndexOf("SatIp.ini.satellite", StringComparison.OrdinalIgnoreCase) != -1).ToList();
return names.Select(GetSatIniMappings).Where(i => i != null).DistinctBy(i => i.Value.Split('|')[0]).ToList();
}
public NameValuePair GetSatIniMappings(string resource)
{
using (var stream = GetType().Assembly.GetManifestResourceStream(resource))
{
using (var reader = new StreamReader(stream))
{
var parser = new StreamIniDataParser();
IniData data = parser.ReadData(reader);
var satType1 = data["SATTYPE"]["1"];
var satType2 = data["SATTYPE"]["2"];
if (string.IsNullOrWhiteSpace(satType2))
{
return null;
}
return new NameValuePair
{
Name = satType1 + " " + satType2,
Value = satType2 + "|" + Path.GetFileName(resource)
};
}
}
}
}
}

View File

@ -49,6 +49,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Emby.XmlTv.1.0.0.48\lib\net45\Emby.XmlTv.dll</HintPath>
</Reference>
<Reference Include="INIFileParser">
<HintPath>..\packages\ini-parser.2.2.4\lib\net20\INIFileParser.dll</HintPath>
</Reference>
<Reference Include="Interfaces.IO">
<HintPath>..\packages\Interfaces.IO.1.0.0.5\lib\portable-net45+sl4+wp71+win8+wpa81\Interfaces.IO.dll</HintPath>
</Reference>

View File

@ -2,6 +2,7 @@
<packages>
<package id="CommonIO" version="1.0.0.8" targetFramework="net45" />
<package id="Emby.XmlTv" version="1.0.0.48" targetFramework="net45" />
<package id="ini-parser" version="2.2.4" targetFramework="net45" />
<package id="Interfaces.IO" version="1.0.0.5" targetFramework="net45" />
<package id="MediaBrowser.Naming" version="1.0.0.49" targetFramework="net45" />
<package id="Mono.Nat" version="1.2.24.0" targetFramework="net45" />