Merge pull request #2165 from tidusjar/develop

Develop
pull/2200/head v3.0.3185
Jamie 7 years ago committed by GitHub
commit c9b4b24fdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,30 @@
### **New Features**
- Added a new Job. Plex Recently Added, this is a slimmed down version of the Plex Sync job, this will just scan the recently added list and not the whole library. I'd reccomend running this very regulary and the full scan not as regular. [Jamie]
### **Fixes**
- Add web-app-capable for IOS and Android. [Thomas]
- Fixed the bug where the newsletter CRON was not appearing on the job settings page. [Jamie]
- Add base url as a startup argument #2153. [Jamie Rees]
- Fixed a bug with the RefreshMetadata where we would never get TheMovieDBId's if it was missing it. [Jamie]
## v3.0.3173 (2018-04-12)
### **Fixes**
- Removed some early disposition that seemed to be causing errors in the API. [Jamie]
## v3.0.3164 (2018-04-10)
### **New Features**
- Added the ability to send newsletter out to users that are not in Ombi. [Jamie]
- Added the ability to turn off TV or Movies from the newsletter. [Jamie]
@ -56,6 +80,12 @@
- Fixed the issue where movies were not appearing in the newsletter for users with Emby #2111. [Jamie]
- The fact that this button has another style really bothers me. [Louis Laureys]
- Fix discord current user count. [Avi]
- Fix broken images and new discord invite. [Avi]
## v3.0.3111 (2018-03-27)

@ -19,5 +19,6 @@ namespace Ombi.Api.Plex
Task<PlexContainer> GetAllEpisodes(string authToken, string host, string section, int start, int retCount);
Task<PlexFriends> GetUsers(string authToken);
Task<PlexAccount> GetAccount(string authToken);
Task<PlexMetadata> GetRecentlyAdded(string authToken, string uri, string sectionId);
}
}

@ -23,8 +23,8 @@ namespace Ombi.Api.Plex.Models
public int leafCount { get; set; }
public int viewedLeafCount { get; set; }
public int childCount { get; set; }
public long addedAt { get; set; }
public int updatedAt { get; set; }
//public long addedAt { get; set; }
//public int updatedAt { get; set; }
public Genre[] Genre { get; set; }
//public Role[] Role { get; set; }
public string primaryExtraKey { get; set; }

@ -147,6 +147,15 @@ namespace Ombi.Api.Plex
return await Api.Request<PlexFriends>(request);
}
public async Task<PlexMetadata> GetRecentlyAdded(string authToken, string uri, string sectionId)
{
var request = new Request($"library/sections/{sectionId}/recentlyAdded", uri, HttpMethod.Get);
AddHeaders(request, authToken);
AddLimitHeaders(request, 0, 50);
return await Api.Request<PlexMetadata>(request);
}
/// <summary>
/// Adds the required headers and also the authorization header
/// </summary>

@ -175,6 +175,7 @@ namespace Ombi.DependencyInjection
services.AddTransient<ISickRageSync, SickRageSync>();
services.AddTransient<IRefreshMetadata, RefreshMetadata>();
services.AddTransient<INewsletterJob, NewsletterJob>();
services.AddTransient<IPlexRecentlyAddedSync, PlexRecentlyAddedSync>();
}
}
}

@ -2,6 +2,8 @@
{
public static class OmbiRoles
{
// DONT FORGET TO ADD TO IDENTITYCONTROLLER.CREATEROLES AND THE UI!
public const string Admin = nameof(Admin);
public const string AutoApproveMovie = nameof(AutoApproveMovie);
public const string AutoApproveTv = nameof(AutoApproveTv);

@ -19,7 +19,7 @@ namespace Ombi.Schedule
IOmbiAutomaticUpdater updater, IEmbyContentSync embySync, IPlexUserImporter userImporter,
IEmbyUserImporter embyUserImporter, ISonarrSync cache, ICouchPotatoSync cpCache,
ISettingsService<JobSettings> jobsettings, ISickRageSync srSync, IRefreshMetadata refresh,
INewsletterJob newsletter)
INewsletterJob newsletter, IPlexRecentlyAddedSync recentlyAddedSync)
{
_plexContentSync = plexContentSync;
_radarrSync = radarrSync;
@ -33,6 +33,7 @@ namespace Ombi.Schedule
_srSync = srSync;
_refreshMetadata = refresh;
_newsletter = newsletter;
_plexRecentlyAddedSync = recentlyAddedSync;
}
private readonly IPlexContentSync _plexContentSync;
@ -47,6 +48,7 @@ namespace Ombi.Schedule
private readonly ISettingsService<JobSettings> _jobSettings;
private readonly IRefreshMetadata _refreshMetadata;
private readonly INewsletterJob _newsletter;
private readonly IPlexRecentlyAddedSync _plexRecentlyAddedSync;
public void Setup()
{
@ -55,7 +57,8 @@ namespace Ombi.Schedule
RecurringJob.AddOrUpdate(() => _embyContentSync.Start(), JobSettingsHelper.EmbyContent(s));
RecurringJob.AddOrUpdate(() => _sonarrSync.Start(), JobSettingsHelper.Sonarr(s));
RecurringJob.AddOrUpdate(() => _radarrSync.CacheContent(), JobSettingsHelper.Radarr(s));
RecurringJob.AddOrUpdate(() => _plexContentSync.CacheContent(), JobSettingsHelper.PlexContent(s));
RecurringJob.AddOrUpdate(() => _plexContentSync.CacheContent(false), JobSettingsHelper.PlexContent(s));
RecurringJob.AddOrUpdate(() => _plexContentSync.CacheContent(true), JobSettingsHelper.PlexRecentlyAdded(s));
RecurringJob.AddOrUpdate(() => _cpCache.Start(), JobSettingsHelper.CouchPotato(s));
RecurringJob.AddOrUpdate(() => _srSync.Start(), JobSettingsHelper.SickRageSync(s));
RecurringJob.AddOrUpdate(() => _refreshMetadata.Start(), JobSettingsHelper.RefreshMetadata(s));

@ -80,7 +80,7 @@ namespace Ombi.Schedule.Jobs.Ombi
if (!hasTheMovieDb)
{
var id = await GetTheMovieDbId(hasTvDbId, hasImdb, show.TvDbId, show.ImdbId, show.Title);
var id = await GetTheMovieDbId(hasTvDbId, hasImdb, show.TvDbId, show.ImdbId, show.Title, false);
show.TheMovieDbId = id;
}
@ -120,7 +120,7 @@ namespace Ombi.Schedule.Jobs.Ombi
if (!hasTheMovieDb)
{
var id = await GetTheMovieDbId(hasTvDbId, hasImdb, show.TvDbId, show.ImdbId, show.Title);
var id = await GetTheMovieDbId(hasTvDbId, hasImdb, show.TvDbId, show.ImdbId, show.Title, false);
show.TheMovieDbId = id;
}
@ -166,7 +166,7 @@ namespace Ombi.Schedule.Jobs.Ombi
}
if (!hasTheMovieDb)
{
var id = await GetTheMovieDbId(false, hasImdb, string.Empty, movie.ImdbId, movie.Title);
var id = await GetTheMovieDbId(false, hasImdb, string.Empty, movie.ImdbId, movie.Title, true);
movie.TheMovieDbId = id;
_plexRepo.UpdateWithoutSave(movie);
}
@ -200,7 +200,7 @@ namespace Ombi.Schedule.Jobs.Ombi
}
if (!hasTheMovieDb)
{
var id = await GetTheMovieDbId(false, hasImdb, string.Empty, movie.ImdbId, movie.Title);
var id = await GetTheMovieDbId(false, hasImdb, string.Empty, movie.ImdbId, movie.Title, true);
movie.TheMovieDbId = id;
_embyRepo.UpdateWithoutSave(movie);
}
@ -215,7 +215,7 @@ namespace Ombi.Schedule.Jobs.Ombi
await _embyRepo.SaveChangesAsync();
}
private async Task<string> GetTheMovieDbId(bool hasTvDbId, bool hasImdb, string tvdbID, string imdbId, string title)
private async Task<string> GetTheMovieDbId(bool hasTvDbId, bool hasImdb, string tvdbID, string imdbId, string title, bool movie)
{
_log.LogInformation("The Media item {0} does not have a TheMovieDbId, searching for TheMovieDbId", title);
FindResult result = null;
@ -230,13 +230,29 @@ namespace Ombi.Schedule.Jobs.Ombi
if (hasImdb && !hasResult)
{
result = await _movieApi.Find(imdbId, ExternalSource.imdb_id);
hasResult = result?.tv_results?.Length > 0;
if (movie)
{
hasResult = result?.movie_results?.Length > 0;
}
else
{
hasResult = result?.tv_results?.Length > 0;
}
_log.LogInformation("Setting Show {0} because we have ImdbId, result: {1}", title, hasResult);
}
if (hasResult)
{
return result.tv_results?[0]?.id.ToString() ?? string.Empty;
if (movie)
{
return result.movie_results?[0]?.id.ToString() ?? string.Empty;
}
else
{
return result.tv_results?[0]?.id.ToString() ?? string.Empty;
}
}
return string.Empty;
}

@ -4,6 +4,6 @@ namespace Ombi.Schedule.Jobs
{
public interface IPlexContentSync : IBaseJob
{
Task CacheContent();
Task CacheContent(bool recentlyAddedSearch = false);
}
}

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace Ombi.Schedule.Jobs.Plex
{
public interface IPlexRecentlyAddedSync : IBaseJob
{
Task Start();
}
}

@ -62,7 +62,7 @@ namespace Ombi.Schedule.Jobs.Plex
private IPlexContentRepository Repo { get; }
private IPlexEpisodeSync EpisodeSync { get; }
public async Task CacheContent()
public async Task CacheContent(bool recentlyAddedSearch = false)
{
var plexSettings = await Plex.GetSettingsAsync();
if (!plexSettings.Enable)
@ -78,7 +78,7 @@ namespace Ombi.Schedule.Jobs.Plex
Logger.LogInformation("Starting Plex Content Cacher");
try
{
await StartTheCache(plexSettings);
await StartTheCache(plexSettings, recentlyAddedSearch);
}
catch (Exception e)
{
@ -89,14 +89,14 @@ namespace Ombi.Schedule.Jobs.Plex
BackgroundJob.Enqueue(() => EpisodeSync.Start());
}
private async Task StartTheCache(PlexSettings plexSettings)
private async Task StartTheCache(PlexSettings plexSettings, bool recentlyAddedSearch)
{
foreach (var servers in plexSettings.Servers ?? new List<PlexServers>())
{
try
{
Logger.LogInformation("Starting to cache the content on server {0}", servers.Name);
await ProcessServer(servers);
await ProcessServer(servers, recentlyAddedSearch);
}
catch (Exception e)
{
@ -105,10 +105,10 @@ namespace Ombi.Schedule.Jobs.Plex
}
}
private async Task ProcessServer(PlexServers servers)
private async Task ProcessServer(PlexServers servers, bool recentlyAddedSearch)
{
Logger.LogInformation("Getting all content from server {0}", servers.Name);
var allContent = await GetAllContent(servers);
var allContent = await GetAllContent(servers, recentlyAddedSearch);
Logger.LogInformation("We found {0} items", allContent.Count);
// Let's now process this.
@ -388,8 +388,9 @@ namespace Ombi.Schedule.Jobs.Plex
/// If they have not set the settings then we will monitor them all
/// </summary>
/// <param name="plexSettings">The plex settings.</param>
/// <param name="recentlyAddedSearch"></param>
/// <returns></returns>
private async Task<List<Mediacontainer>> GetAllContent(PlexServers plexSettings)
private async Task<List<Mediacontainer>> GetAllContent(PlexServers plexSettings, bool recentlyAddedSearch)
{
var sections = await PlexApi.GetLibrarySections(plexSettings.PlexAuthToken, plexSettings.FullUri);
@ -413,10 +414,23 @@ namespace Ombi.Schedule.Jobs.Plex
}
}
}
var lib = await PlexApi.GetLibrary(plexSettings.PlexAuthToken, plexSettings.FullUri, dir.key);
if (lib != null)
if (recentlyAddedSearch)
{
libs.Add(lib.MediaContainer);
var container = await PlexApi.GetRecentlyAdded(plexSettings.PlexAuthToken, plexSettings.FullUri,
dir.key);
if (container != null)
{
libs.Add(container.MediaContainer);
}
}
else
{
var lib = await PlexApi.GetLibrary(plexSettings.PlexAuthToken, plexSettings.FullUri, dir.key);
if (lib != null)
{
libs.Add(lib.MediaContainer);
}
}
}
}

@ -0,0 +1,40 @@
using System;
using System.Threading.Tasks;
using Ombi.Api.Plex;
namespace Ombi.Schedule.Jobs.Plex
{
public class PlexRecentlyAddedSync : IPlexRecentlyAddedSync
{
public PlexRecentlyAddedSync(IPlexContentSync contentSync)
{
_sync = contentSync;
}
private readonly IPlexContentSync _sync;
public async Task Start()
{
await _sync.CacheContent(true);
}
private bool _disposed;
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
_sync?.Dispose();
}
_disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
}

@ -6,6 +6,7 @@
public string SonarrSync { get; set; }
public string RadarrSync { get; set; }
public string PlexContentSync { get; set; }
public string PlexRecentlyAddedSync { get; set; }
public string CouchPotatoSync { get; set; }
public string AutomaticUpdater { get; set; }
public string UserImporter { get; set; }

@ -21,7 +21,11 @@ namespace Ombi.Settings.Settings.Models
}
public static string PlexContent(JobSettings s)
{
return Get(s.PlexContentSync, Cron.Hourly(20));
return Get(s.PlexContentSync, Cron.HourInterval(6));
}
public static string PlexRecentlyAdded(JobSettings s)
{
return Get(s.PlexRecentlyAddedSync, Cron.Hourly(0));
}
public static string CouchPotato(JobSettings s)
{
@ -49,7 +53,6 @@ namespace Ombi.Settings.Settings.Models
return Get(s.RefreshMetadata, Cron.Daily(3));
}
private static string Get(string settings, string defaultCron)
{
return settings.HasValue() ? settings : defaultCron;

@ -17,5 +17,6 @@ namespace Ombi.Store.Entities
TheMovieDb = 4,
StoragePath = 5,
Notification = 6,
BaseUrl=7,
}
}

@ -128,6 +128,7 @@ export interface IJobSettings {
sickRageSync: string;
refreshMetadata: string;
newsletter: string;
plexRecentlyAddedSync: string;
}
export interface IIssueSettings extends ISettings {

@ -35,6 +35,10 @@ export class JobService extends ServiceHelpers {
return this.http.post<boolean>(`${this.url}plexcontentcacher/`, {headers: this.headers});
}
public runPlexRecentlyAddedCacher(): Observable<boolean> {
return this.http.post<boolean>(`${this.url}plexrecentlyadded/`, {headers: this.headers});
}
public runEmbyCacher(): Observable<boolean> {
return this.http.post<boolean>(`${this.url}embycontentcacher/`, {headers: this.headers});
}

@ -57,6 +57,12 @@
<small *ngIf="form.get('plexContentSync').hasError('required')" class="error-text">The Plex Sync is required</small>
<button type="button" class="btn btn-sm btn-primary-outline" (click)="testCron(form.get('plexContentSync')?.value)">Test</button>
</div>
<div class="form-group">
<label for="plexRecentlyAddedSync" class="control-label">Plex Recently Added Sync</label>
<input type="text" class="form-control form-control-custom" [ngClass]="{'form-error': form.get('plexRecentlyAddedSync').hasError('required')}" id="plexRecentlyAddedSync" name="plexContentSync" formControlName="plexContentSync">
<small *ngIf="form.get('plexRecentlyAddedSync').hasError('required')" class="error-text">The Plex Sync is required</small>
<button type="button" class="btn btn-sm btn-primary-outline" (click)="testCron(form.get('plexRecentlyAddedSync')?.value)">Test</button>
</div>
<div class="form-group">
<label for="embyContentSync" class="control-label">Emby Sync</label>

@ -33,6 +33,7 @@ export class JobsComponent implements OnInit {
sickRageSync: [x.sickRageSync, Validators.required],
refreshMetadata: [x.refreshMetadata, Validators.required],
newsletter: [x.newsletter, Validators.required],
plexRecentlyAddedSync: [x.plexRecentlyAddedSync, Validators.required],
});
});
}

@ -171,19 +171,26 @@
</ngb-tab>
</div>
</ngb-tabset>
<div class="col-md-1">
<div class="col-md-2">
<div class="form-group">
<div>
<button (click)="save()" type="submit" id="save" class="btn btn-primary-outline">Submit</button>
</div>
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<div>
<button (click)="runCacher()" type="button" id="save" class="btn btn-primary-outline">Manually Run Cacher</button>
</div>
<div class="col-md-3">
<div class="form-group">
<div>
<button (click)="runCacher()" type="button" id="save" class="btn btn-primary-outline">Manually Run Full Sync</button>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<div>
<button (click)="runRecentlyAddedCacher()" type="button" id="save" class="btn btn-primary-outline">Manually Run Recently Added Sync</button>
</div>
</div>
</div>
</fieldset>
</div>

@ -121,7 +121,15 @@ export class PlexComponent implements OnInit, OnDestroy {
public runCacher(): void {
this.jobService.runPlexCacher().subscribe(x => {
if(x) {
this.notificationService.success("Triggered the Plex Content Cacher");
this.notificationService.success("Triggered the Plex Full Sync");
}
});
}
public runRecentlyAddedCacher(): void {
this.jobService.runPlexRecentlyAddedCacher().subscribe(x => {
if(x) {
this.notificationService.success("Triggered the Plex Recently Added Sync");
}
});
}

@ -194,6 +194,7 @@ namespace Ombi.Controllers
await CreateRole(OmbiRoles.RequestMovie);
await CreateRole(OmbiRoles.RequestTv);
await CreateRole(OmbiRoles.Disabled);
await CreateRole(OmbiRoles.RecievesNewsletter);
}
private async Task CreateRole(string role)

@ -117,7 +117,18 @@ namespace Ombi.Controllers
[HttpPost("plexcontentcacher")]
public bool StartPlexContentCacher()
{
BackgroundJob.Enqueue(() => _plexContentSync.CacheContent());
BackgroundJob.Enqueue(() => _plexContentSync.CacheContent(false));
return true;
}
/// <summary>
/// Runs a smaller version of the content cacher
/// </summary>
/// <returns></returns>
[HttpPost("plexrecentlyadded")]
public bool StartRecentlyAdded()
{
BackgroundJob.Enqueue(() => _plexContentSync.CacheContent(true));
return true;
}

@ -473,6 +473,8 @@ namespace Ombi.Controllers
j.UserImporter = j.UserImporter.HasValue() ? j.UserImporter : JobSettingsHelper.UserImporter(j);
j.SickRageSync = j.SickRageSync.HasValue() ? j.SickRageSync : JobSettingsHelper.SickRageSync(j);
j.RefreshMetadata = j.RefreshMetadata.HasValue() ? j.RefreshMetadata : JobSettingsHelper.RefreshMetadata(j);
j.PlexRecentlyAddedSync = j.PlexRecentlyAddedSync.HasValue() ? j.PlexRecentlyAddedSync : JobSettingsHelper.PlexRecentlyAdded(j);
j.Newsletter = j.Newsletter.HasValue() ? j.Newsletter : JobSettingsHelper.Newsletter(j);
return j;
}

@ -23,11 +23,13 @@ namespace Ombi
var host = string.Empty;
var storagePath = string.Empty;
var baseUrl = string.Empty;
var result = Parser.Default.ParseArguments<Options>(args)
.WithParsed(o =>
{
host = o.Host;
storagePath = o.StoragePath;
baseUrl = o.BaseUrl;
}).WithNotParsed(err =>
{
foreach (var e in err)
@ -47,6 +49,7 @@ namespace Ombi
{
var config = ctx.ApplicationConfigurations.ToList();
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
var dbBaseUrl = config.FirstOrDefault(x => x.Type == ConfigurationTypes.BaseUrl);
if (url == null)
{
url = new ApplicationConfiguration
@ -65,6 +68,25 @@ namespace Ombi
ctx.SaveChanges();
urlValue = url.Value;
}
if (dbBaseUrl == null)
{
if (baseUrl.HasValue() && baseUrl.StartsWith("/"))
{
dbBaseUrl = new ApplicationConfiguration
{
Type = ConfigurationTypes.BaseUrl,
Value = baseUrl
};
ctx.ApplicationConfigurations.Add(dbBaseUrl);
ctx.SaveChanges();
}
}
else if(!baseUrl.Equals(dbBaseUrl.Value))
{
dbBaseUrl.Value = baseUrl;
ctx.SaveChanges();
}
}
DeleteSchedulesDb();
@ -118,5 +140,8 @@ namespace Ombi
[Option("storage", Required = false, HelpText = "Storage path, where we save the logs and database")]
public string StoragePath { get; set; }
[Option("baseurl", Required = false, HelpText = "The base URL for reverse proxy scenarios")]
public string BaseUrl { get; set; }
}
}

@ -32,6 +32,7 @@ using Ombi.Schedule;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Context;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Serilog;
using Serilog.Events;
@ -176,6 +177,22 @@ namespace Ombi
{
app.UsePathBase(settings.BaseUrl);
}
else
{
// Check if it's in the startup args
var appConfig = serviceProvider.GetService<IApplicationConfigRepository>();
var baseUrl = appConfig.Get(ConfigurationTypes.BaseUrl).Result;
if (baseUrl != null)
{
if (baseUrl.Value.HasValue())
{
settings.BaseUrl = baseUrl.Value;
ombiService.SaveSettings(settings);
app.UsePathBase(settings.BaseUrl);
}
}
}
app.UseHangfireServer(new BackgroundJobServerOptions { WorkerCount = 1, ServerTimeout = TimeSpan.FromDays(1), ShutdownTimeout = TimeSpan.FromDays(1)});
app.UseHangfireDashboard(settings.BaseUrl.HasValue() ? $"{settings.BaseUrl}/hangfire" : "/hangfire",

@ -75,6 +75,8 @@ O:::::::OOO:::::::Om::::m m::::m m::::mb:::::bbbbbb::::::bi::::::i
<meta name="msapplication-TileColor" content="#df691a">
<meta name="msapplication-config" content="~/images/favicon/browserconfig.xml">
<meta name="theme-color" content="#df691a">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

Loading…
Cancel
Save