Initial Push

This commit is contained in:
Qstick
2020-10-18 04:18:35 -04:00
parent 09ed2ab889
commit e1020f4107
1845 changed files with 1516 additions and 113975 deletions

View File

@@ -0,0 +1,46 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Update;
using Prowlarr.Http;
namespace Prowlarr.Api.V1.Update
{
public class UpdateModule : ProwlarrRestModule<UpdateResource>
{
private readonly IRecentUpdateProvider _recentUpdateProvider;
public UpdateModule(IRecentUpdateProvider recentUpdateProvider)
{
_recentUpdateProvider = recentUpdateProvider;
GetResourceAll = GetRecentUpdates;
}
private List<UpdateResource> GetRecentUpdates()
{
var resources = _recentUpdateProvider.GetRecentUpdatePackages()
.OrderByDescending(u => u.Version)
.ToResource();
if (resources.Any())
{
var first = resources.First();
first.Latest = true;
if (first.Version > BuildInfo.Version)
{
first.Installable = true;
}
var installed = resources.SingleOrDefault(r => r.Version == BuildInfo.Version);
if (installed != null)
{
installed.Installed = true;
}
}
return resources;
}
}
}

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using NzbDrone.Core.Update;
using Prowlarr.Http.REST;
namespace Prowlarr.Api.V1.Update
{
public class UpdateResource : RestResource
{
[JsonConverter(typeof(Newtonsoft.Json.Converters.VersionConverter))]
public Version Version { get; set; }
public string Branch { get; set; }
public DateTime ReleaseDate { get; set; }
public string FileName { get; set; }
public string Url { get; set; }
public bool Installed { get; set; }
public bool Installable { get; set; }
public bool Latest { get; set; }
public UpdateChanges Changes { get; set; }
public string Hash { get; set; }
}
public static class UpdateResourceMapper
{
public static UpdateResource ToResource(this UpdatePackage model)
{
if (model == null)
{
return null;
}
return new UpdateResource
{
Version = model.Version,
Branch = model.Branch,
ReleaseDate = model.ReleaseDate,
FileName = model.FileName,
Url = model.Url,
//Installed
//Installable
//Latest
Changes = model.Changes,
Hash = model.Hash,
};
}
public static List<UpdateResource> ToResource(this IEnumerable<UpdatePackage> models)
{
return models.Select(ToResource).ToList();
}
}
}