Some work around the Auto Updater and other small changes #1460 #865

pull/1488/head
Jamie.Rees 7 years ago
parent 5c72d585f4
commit 863df6e1cc

@ -8,4 +8,5 @@ param([String]$env='local')
$appSettingsPath = $env:APPVEYOR_BUILD_FOLDER + '\src\Ombi\appsettings.json'
$appSettings = Get-Content $appSettingsPath -raw
$appSettings = $appSettings.Replace("{{VERSIONNUMBER}}",$env:APPVEYOR_BUILD_VERSION);
$appSettings = $appSettings.Replace("{{BRANCH}}",$env:APPVEYOR_REPO_BRANCH);
Set-Content -Path $appSettingsPath -Value $appSettings

@ -34,15 +34,15 @@ after_build:
- dotnet publish "../Ombi.Updater" -c Release -r centos.7-x64
# Copy over the updater files so we can include them in the .zip
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\win10-x64\publish\Ombi.Updater.dll" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\win10-x64\publish\Ombi.Updater.dll"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\win10-x64\publish\Ombi.Updater.dll" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\win10-x64\publish\Ombi.Updater.exe"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\win10-x64\publish\Ombi.Updater.exe" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\win10-x64\publish\Ombi.Updater.exe"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\osx.10.12-x64\publish\Ombi.Updater.dll" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\osx.10.12-x64\publish\Ombi.Updater.dll"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\osx.10.12-x64\publish\Ombi.Updater.dll" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\osx.10.12-x64\publish\Ombi.Updater.exe"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\osx.10.12-x64\publish\Ombi.Updater" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\osx.10.12-x64\publish\Ombi.Updater"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\ubuntu.16.10-x64\publish\Ombi.Updater.dll" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\ubuntu.16.10-x64\publish\Ombi.Updater.dll"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\ubuntu.16.10-x64\publish\Ombi.Updater.dll" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\ubuntu.16.10-x64\publish\Ombi.Updater.exe"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\ubuntu.16.10-x64\publish\Ombi.Updater" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\ubuntu.16.10-x64\publish\Ombi.Updater"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\debian.8-x64\publish\Ombi.Updater.dll" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\debian.8-x64\publish\Ombi.Updater.dll"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\debian.8-x64\publish\Ombi.Updater.dll" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\debian.8-x64\publish\Ombi.Updater.exe"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\debian.8-x64\publish\Ombi.Updater" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\debian.8-x64\publish\Ombi.Updater"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\centos.7-x64\publish\Ombi.Updater.dll" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\centos.7-x64\publish\Ombi.Updater.dll"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\centos.7-x64\publish\Ombi.Updater.dll" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\centos.7-x64\publish\Ombi.Updater.exe"
- copy "%APPVEYOR_BUILD_FOLDER%\src\Ombi.Updater\bin\release\netcoreapp1.1\centos.7-x64\publish\Ombi.Updater" "%APPVEYOR_BUILD_FOLDER%\src\Ombi\bin\Release\netcoreapp1.1\centos.7-x64\publish\Ombi.Updater"
#Copy the swagger files

@ -0,0 +1,10 @@
using System.Threading.Tasks;
using Ombi.Api.Service.Models;
namespace Ombi.Api.Service
{
public interface IOmbiService
{
Task<Updates> GetUpdates(string branch);
}
}

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Ombi.Api.Service.Models
{
public class Updates
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("updateVersionString")]
public string UpdateVersionString { get; set; }
[JsonProperty("updateVersion")]
public int UpdateVersion { get; set; }
[JsonProperty("updateDate")]
public DateTime UpdateDate { get; set; }
[JsonProperty("changeLogs")]
public List<Changelog> ChangeLogs { get; set; }
[JsonProperty("downloads")]
public List<Download> Downloads { get; set; }
}
public class Changelog
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("descripion")]
public string Descripion { get; set; }
[JsonProperty("updateId")]
public int UpdateId { get; set; }
}
public class Download
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("updateId")]
public int UpdateId { get; set; }
}
}

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
<AssemblyName>Ombi.Api.Service</AssemblyName>
<RootNamespace>Ombi.Api.Service</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options" Version="1.1.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Ombi.Api.Service.Models;
using Ombi.Helpers;
namespace Ombi.Api.Service
{
public class OmbiService : IOmbiService
{
public OmbiService(IOptions<ApplicationSettings> settings, IApi api, ILogger<OmbiService> log)
{
Settings = settings.Value;
Api = api;
Logger = log;
}
private ApplicationSettings Settings { get; }
private ILogger<OmbiService> Logger { get; }
private IApi Api { get; }
public async Task<Updates> GetUpdates(string branch)
{
var request = new Request($"api/update/{branch}", Settings.OmbiService, HttpMethod.Get);
request.ContentHeaders.Add(new KeyValuePair<string, string>("Content-Type", "application/json"));
return await Api.Request<Updates>(request);
}
}
}

@ -45,7 +45,7 @@ namespace Ombi.Core.Engine
public async Task<RequestEngineResult> RequestMovie(SearchMovieViewModel model)
{
var movieInfo = await MovieApi.GetMovieInformation(model.Id);
if (movieInfo == null)
if (movieInfo == null || movieInfo.Id == 0)
{
return new RequestEngineResult
{

@ -28,7 +28,9 @@ using Ombi.Store.Repository;
using Ombi.Notifications.Agents;
using Ombi.Schedule.Jobs.Radarr;
using Ombi.Api;
using Ombi.Api.Service;
using Ombi.Core.Rule.Interfaces;
using Ombi.Schedule.Ombi;
using Ombi.Store.Repository.Requests;
namespace Ombi.DependencyInjection
@ -68,6 +70,7 @@ namespace Ombi.DependencyInjection
services.AddTransient<ITraktApi, TraktApi>();
services.AddTransient<IRadarrApi, RadarrApi>();
services.AddTransient<IDiscordApi, DiscordApi>();
services.AddTransient<IOmbiService, OmbiService>();
}
public static void RegisterStore(this IServiceCollection services)
@ -103,6 +106,7 @@ namespace Ombi.DependencyInjection
services.AddTransient<IPlexContentCacher, PlexContentCacher>();
services.AddTransient<IJobSetup, JobSetup>();
services.AddTransient<IRadarrCacher, RadarrCacher>();
services.AddTransient<IOmbiAutomaticUpdater, OmbiAutomaticUpdater>();
}
public static void RegisterIdentity(this IServiceCollection services)

@ -15,6 +15,7 @@
<ProjectReference Include="..\Ombi.Api.Emby\Ombi.Api.Emby.csproj" />
<ProjectReference Include="..\Ombi.Api.Plex\Ombi.Api.Plex.csproj" />
<ProjectReference Include="..\Ombi.Api.Radarr\Ombi.Api.Radarr.csproj" />
<ProjectReference Include="..\Ombi.Api.Service\Ombi.Api.Service.csproj" />
<ProjectReference Include="..\Ombi.Api.Sonarr\Ombi.Api.Sonarr.csproj" />
<ProjectReference Include="..\Ombi.Api.Trakt\Ombi.Api.Trakt.csproj" />
<ProjectReference Include="..\Ombi.Api.TvMaze\Ombi.Api.TvMaze.csproj" />

@ -0,0 +1,10 @@
namespace Ombi.Helpers
{
public class ApplicationSettings
{
public string Branch { get; set; }
public string Version { get; set; }
public string OmbiService { get; set; }
public string FriendlyVersion { get; set; }
}
}

@ -18,5 +18,8 @@ namespace Ombi.Helpers
public static EventId TvSender => new EventId(5000);
public static EventId SonarrSender => new EventId(5001);
public static EventId Updater => new EventId(6000);
}
}

@ -9,6 +9,10 @@ namespace Ombi.Helpers
{
public static bool Contains(this string paragraph, string word, CompareOptions opts)
{
if (string.IsNullOrEmpty(paragraph))
{
return false;
}
return CultureInfo.CurrentUICulture.CompareInfo.IndexOf(paragraph, word, CompareOptions.IgnoreCase) >= 0;
}

@ -1,24 +1,27 @@
using Hangfire;
using Ombi.Schedule.Jobs;
using Ombi.Schedule.Jobs.Radarr;
using Ombi.Schedule.Ombi;
namespace Ombi.Schedule
{
public class JobSetup : IJobSetup
{
public JobSetup(IPlexContentCacher cacher, IRadarrCacher radarrCacher)
public JobSetup(IPlexContentCacher cacher, IRadarrCacher radarrCacher, IOmbiAutomaticUpdater updater)
{
Cacher = cacher;
RadarrCacher = radarrCacher;
Updater = updater;
}
private IPlexContentCacher Cacher { get; }
private IRadarrCacher RadarrCacher { get; }
private IOmbiAutomaticUpdater Updater { get; }
public void Setup()
{
RecurringJob.AddOrUpdate(() => Cacher.CacheContent(), Cron.Hourly);
RecurringJob.AddOrUpdate(() => RadarrCacher.CacheContent(), Cron.Hourly);
RecurringJob.AddOrUpdate(() => Updater.Update(), Cron.Minutely);
}
}
}

@ -0,0 +1,132 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Ombi.Api.Service;
using Ombi.Api.Service.Models;
using Ombi.Helpers;
namespace Ombi.Schedule.Ombi
{
public class OmbiAutomaticUpdater : IOmbiAutomaticUpdater
{
public OmbiAutomaticUpdater(ILogger<OmbiAutomaticUpdater> log, IOmbiService service, IOptions<ApplicationSettings> settings)
{
Logger = log;
OmbiService = service;
Settings = settings.Value;
}
private ILogger<OmbiAutomaticUpdater> Logger { get; }
private IOmbiService OmbiService { get; }
private ApplicationSettings Settings { get; }
public async Task Update()
{
// IF AutoUpdateEnabled =>
// ELSE Return;
var currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var currentBranch = Settings.Branch;
#if DEBUG
if (currentBranch == "{{BRANCH}}")
{
currentBranch = "DotNetCore";
}
#endif
var updates = await OmbiService.GetUpdates(currentBranch);
var serverVersion = updates.UpdateVersionString.Substring(1, 6);
if (serverVersion != Settings.FriendlyVersion)
{
// Let's download the correct zip
var desc = RuntimeInformation.OSDescription;
var proce = RuntimeInformation.ProcessArchitecture;
Logger.LogInformation(LoggingEvents.Updater, "OS Information: {0} {1}", desc, proce);
Download download;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Logger.LogInformation(LoggingEvents.Updater, "We are Windows");
download = updates.Downloads.FirstOrDefault(x => x.Name.Contains("windows", CompareOptions.IgnoreCase));
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Logger.LogInformation(LoggingEvents.Updater, "We are OSX");
download = updates.Downloads.FirstOrDefault(x => x.Name.Contains("osx", CompareOptions.IgnoreCase));
}
else
{
// Linux
if (desc.Contains("ubuntu", CompareOptions.IgnoreCase))
{
// Ubuntu
Logger.LogInformation(LoggingEvents.Updater, "We are ubuntu");
download = updates.Downloads.FirstOrDefault(x => x.Name.Contains("ubuntu", CompareOptions.IgnoreCase));
}
else if (desc.Contains("debian", CompareOptions.IgnoreCase))
{
// Debian
Logger.LogInformation(LoggingEvents.Updater, "We are debian");
download = updates.Downloads.FirstOrDefault(x => x.Name.Contains("debian", CompareOptions.IgnoreCase));
}
else if (desc.Contains("centos", CompareOptions.IgnoreCase))
{
// Centos
Logger.LogInformation(LoggingEvents.Updater, "We are centos");
download = updates.Downloads.FirstOrDefault(x => x.Name.Contains("centos",
CompareOptions.IgnoreCase));
}
else
{
return;
}
}
// Download it
await DownloadAsync(download.Url, Path.Combine(currentLocation, "Ombi.zip"));
// There must be an update
//var start = new ProcessStartInfo
//{
// UseShellExecute = false,
// CreateNoWindow = true,
// FileName = "Ombi.Updater.exe",
// Arguments = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
//};
//using (var proc = new Process { StartInfo = start })
//{
// proc.Start();
//}
}
else
{
// No updates
return;
}
}
public static async Task DownloadAsync(string requestUri, string filename)
{
using (var client = new HttpClient())
using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri))
using (Stream contentStream = await (await client.SendAsync(request)).Content.ReadAsStreamAsync(),
stream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None, 3145728, true))
{
await contentStream.CopyToAsync(stream);
}
}
}
}

@ -10,12 +10,14 @@
<PackageReference Include="Hangfire.MemoryStorage.Core" Version="1.4.0" />
<PackageReference Include="Hangfire.RecurringJobExtensions" Version="1.1.6" />
<PackageReference Include="Serilog" Version="2.4.0" />
<PackageReference Include="System.Diagnostics.Process" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Api.Emby\Ombi.Api.Emby.csproj" />
<ProjectReference Include="..\Ombi.Api.Plex\Ombi.Api.Plex.csproj" />
<ProjectReference Include="..\Ombi.Api.Radarr\Ombi.Api.Radarr.csproj" />
<ProjectReference Include="..\Ombi.Api.Service\Ombi.Api.Service.csproj" />
<ProjectReference Include="..\Ombi.Settings\Ombi.Settings.csproj" />
</ItemGroup>

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace Ombi.Schedule.Ombi
{
public interface IOmbiAutomaticUpdater
{
Task Update();
}
}

@ -13,7 +13,6 @@ namespace Ombi.Updater
{
// Kill Ombi Process
var p = new ProcessProvider();
p.Kill(options.OmbiProcessId);

@ -9,7 +9,7 @@ namespace Ombi.Updater
static void Main(string[] args)
{
Console.WriteLine("=======================================");
Console.WriteLine(" Starting the Ombi Updater");
Console.WriteLine(" Starting the Ombi Updater" );
Console.WriteLine("=======================================");

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.14
VisualStudioVersion = 15.0.26430.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi", "Ombi\Ombi.csproj", "{C987AA67-AFE1-468F-ACD3-EAD5A48E1F6A}"
EndProject
@ -65,7 +65,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Updater", "Ombi.Update
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Update", "Update", "{D11FE57E-1E57-491D-A1D4-01AEF4BE5CB6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Notifications.Tests", "Ombi.Notifications.Tests\Ombi.Notifications.Tests.csproj", "{2C7836E7-B120-40A6-B641-DDAA02FBAE23}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Notifications.Tests", "Ombi.Notifications.Tests\Ombi.Notifications.Tests.csproj", "{2C7836E7-B120-40A6-B641-DDAA02FBAE23}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Api.Service", "Ombi.Api.Service\Ombi.Api.Service.csproj", "{A0892896-F5BD-47E2-823E-DFCE82514EEC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -161,6 +163,10 @@ Global
{2C7836E7-B120-40A6-B641-DDAA02FBAE23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C7836E7-B120-40A6-B641-DDAA02FBAE23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C7836E7-B120-40A6-B641-DDAA02FBAE23}.Release|Any CPU.Build.0 = Release|Any CPU
{A0892896-F5BD-47E2-823E-DFCE82514EEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0892896-F5BD-47E2-823E-DFCE82514EEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0892896-F5BD-47E2-823E-DFCE82514EEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0892896-F5BD-47E2-823E-DFCE82514EEC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -182,5 +188,6 @@ Global
{5AF2B6D2-5CC6-49FE-928A-BA27AF52B194} = {9293CA11-360A-4C20-A674-B9E794431BF5}
{6294A82D-4915-4FC3-B301-8F985716F34C} = {D11FE57E-1E57-491D-A1D4-01AEF4BE5CB6}
{2C7836E7-B120-40A6-B641-DDAA02FBAE23} = {6F42AB98-9196-44C4-B888-D5E409F415A1}
{A0892896-F5BD-47E2-823E-DFCE82514EEC} = {9293CA11-360A-4C20-A674-B9E794431BF5}
EndGlobalSection
EndGlobal

@ -93,7 +93,7 @@ export class TvSearchComponent implements OnInit, OnDestroy {
anticipatedShows() {
this.clearResults();
this.searchService.anticiplatedTv()
this.searchService.anticipatedTv()
.takeUntil(this.subscriptions)
.subscribe(x => {
this.tvResults = x;

@ -48,7 +48,7 @@ export class SearchService extends ServiceAuthHelpers {
mostWatchedTv(): Observable<ISearchTvResult[]> {
return this.http.get(`${this.url}/Tv/mostwatched`).map(this.extractData);
}
anticiplatedTv(): Observable<ISearchTvResult[]> {
anticipatedTv(): Observable<ISearchTvResult[]> {
return this.http.get(`${this.url}/Tv/anticipated`).map(this.extractData);
}
trendingTv(): Observable<ISearchTvResult[]> {

@ -1,7 +0,0 @@
namespace Ombi.Config
{
public class ApplicationSettings
{
public string Version { get; set; }
}
}

@ -138,7 +138,7 @@ namespace Ombi.Controllers
/// </summary>
/// <remarks>We use Trakt.tv as the Provider</remarks>
/// <returns></returns>
[HttpGet("tv/anticiplated")]
[HttpGet("tv/anticipated")]
public async Task<IEnumerable<SearchTvShowViewModel>> AnticiplatedTv()
{
return await TvEngine.Anticipated();

@ -25,6 +25,7 @@ using Microsoft.IdentityModel.Tokens;
using Ombi.Config;
using Ombi.Core.IdentityResolver;
using Ombi.DependencyInjection;
using Ombi.Helpers;
using Ombi.Mapping;
using Ombi.Schedule;
using Ombi.Store.Context;

@ -6,7 +6,10 @@
}
},
"ApplicationSettings": {
"Verison": "{{VERSIONNUMBER}}"
"Verison": "{{VERSIONNUMBER}}",
"OmbiService": "https://ombiservice.azurewebsites.net/",
"Branch": "{{BRANCH}}",
"FriendlyVersion": "v3.0.0"
},
"UserSettings": {
"WebsiteUrl": "http://localhost:52038",

Loading…
Cancel
Save