mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-15 09:42:56 -07:00
commit
6eab8c09cc
26 changed files with 737 additions and 168 deletions
|
@ -9,6 +9,7 @@ namespace Ombi.Api.Interfaces
|
|||
EmbyItemContainer<EmbyMovieItem> GetAllMovies(string apiKey, string userId, Uri baseUri);
|
||||
EmbyItemContainer<EmbySeriesItem> GetAllShows(string apiKey, string userId, Uri baseUri);
|
||||
EmbyItemContainer<EmbyEpisodeItem> GetAllEpisodes(string apiKey, string userId, Uri baseUri);
|
||||
EmbyItemContainer<EmbyMovieInformation> GetCollection(string mediaId, string apiKey, string userId, Uri baseUrl);
|
||||
List<EmbyUser> GetUsers(Uri baseUri, string apiKey);
|
||||
EmbyItemContainer<EmbyLibrary> ViewLibrary(string apiKey, string userId, Uri baseUri);
|
||||
EmbyInformation GetInformation(string mediaId, EmbyMediaType type, string apiKey, string userId, Uri baseUri);
|
||||
|
|
|
@ -100,9 +100,9 @@ namespace Ombi.Api
|
|||
|
||||
var obj = RetryHandler.Execute<CouchPotatoStatus>(() => Api.Execute<CouchPotatoStatus>(request, url),
|
||||
(exception, timespan) => Log.Error(exception, "Exception when calling GetStatus for CP, Retrying {0}", timespan), new TimeSpan[] {
|
||||
TimeSpan.FromSeconds (1),
|
||||
TimeSpan.FromSeconds(2),
|
||||
TimeSpan.FromSeconds(5),
|
||||
TimeSpan.FromSeconds(10)});
|
||||
TimeSpan.FromSeconds(3)});
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
@ -140,9 +140,9 @@ namespace Ombi.Api
|
|||
{
|
||||
var obj = RetryHandler.Execute(() => Api.Execute<CouchPotatoMovies>(request, baseUrl),
|
||||
(exception, timespan) => Log.Error(exception, "Exception when calling GetMovies for CP, Retrying {0}", timespan), new[] {
|
||||
TimeSpan.FromSeconds (1),
|
||||
TimeSpan.FromSeconds(5),
|
||||
TimeSpan.FromSeconds(10),
|
||||
TimeSpan.FromSeconds(30)
|
||||
TimeSpan.FromSeconds(5)
|
||||
});
|
||||
|
||||
return obj;
|
||||
|
|
|
@ -103,6 +103,27 @@ namespace Ombi.Api
|
|||
return GetAll<EmbyEpisodeItem>("Episode", apiKey, userId, baseUri);
|
||||
}
|
||||
|
||||
public EmbyItemContainer<EmbyMovieInformation> GetCollection(string mediaId, string apiKey, string userId, Uri baseUrl)
|
||||
{
|
||||
var request = new RestRequest
|
||||
{
|
||||
Resource = "emby/users/{userId}/items?parentId={mediaId}",
|
||||
Method = Method.GET
|
||||
};
|
||||
|
||||
request.AddUrlSegment("userId", userId);
|
||||
request.AddUrlSegment("mediaId", mediaId);
|
||||
|
||||
AddHeaders(request, apiKey);
|
||||
|
||||
|
||||
var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling GetCollections for Emby, Retrying {0}", timespan), new[] {
|
||||
TimeSpan.FromSeconds (1),
|
||||
TimeSpan.FromSeconds(5)
|
||||
});
|
||||
return policy.Execute(() => Api.ExecuteJson<EmbyItemContainer<EmbyMovieInformation>>(request, baseUrl));
|
||||
}
|
||||
|
||||
public EmbyInformation GetInformation(string mediaId, EmbyMediaType type, string apiKey, string userId, Uri baseUri)
|
||||
{
|
||||
var request = new RestRequest
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
using System.Data;
|
||||
using NLog;
|
||||
using Ombi.Core.SettingModels;
|
||||
using Ombi.Store;
|
||||
|
||||
namespace Ombi.Core.Migration.Migrations
|
||||
{
|
||||
|
@ -52,8 +53,15 @@ namespace Ombi.Core.Migration.Migrations
|
|||
public void Start(IDbConnection con)
|
||||
{
|
||||
UpdatePlexSettings();
|
||||
//UpdateCustomSettings(); Turned off the migration for now until the search has been improved on.
|
||||
//UpdateSchema(con, Version);
|
||||
UpdateCustomSettings();
|
||||
AddNewColumns(con);
|
||||
UpdateSchema(con, Version);
|
||||
}
|
||||
|
||||
private void AddNewColumns(IDbConnection con)
|
||||
{
|
||||
con.AlterTable("EmbyContent", "ADD", "AddedAt", true, "VARCHAR(50)");
|
||||
con.AlterTable("EmbyEpisodes", "ADD", "AddedAt", true, "VARCHAR(50)");
|
||||
}
|
||||
|
||||
private void UpdatePlexSettings()
|
||||
|
@ -68,7 +76,7 @@ namespace Ombi.Core.Migration.Migrations
|
|||
{
|
||||
|
||||
var settings = Customization.GetSettings();
|
||||
settings.NewSearch = true; // Use the new search
|
||||
settings.EnableIssues = true;
|
||||
|
||||
Customization.SaveSettings(settings);
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="http://i.imgur.com/ROTp8mn.png" text-align="center" />
|
||||
<img src="http://i.imgur.com/qQsN78U.png" width="400px" text-align="center" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -54,6 +54,7 @@ namespace Ombi.Core.SettingModels
|
|||
public int DefaultLang { get; set; }
|
||||
|
||||
public bool NewSearch { get; set; }
|
||||
public bool EnableIssues { get; set; }
|
||||
|
||||
}
|
||||
}
|
|
@ -6,6 +6,6 @@ namespace Ombi.Services.Jobs
|
|||
{
|
||||
void Execute(IJobExecutionContext context);
|
||||
void RecentlyAddedAdminTest();
|
||||
void Start();
|
||||
void StartNewsLetter();
|
||||
}
|
||||
}
|
|
@ -107,36 +107,24 @@ namespace Ombi.Services.Jobs
|
|||
var movies = GetMovies();
|
||||
|
||||
foreach (var m in movies)
|
||||
{
|
||||
if (m.Type.Equals("boxset", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
var info = EmbyApi.GetCollection(m.Id, embySettings.ApiKey,
|
||||
embySettings.AdministratorId, embySettings.FullUri);
|
||||
foreach (var item in info.Items)
|
||||
{
|
||||
var movieInfo = EmbyApi.GetInformation(item.Id, EmbyMediaType.Movie, embySettings.ApiKey,
|
||||
embySettings.AdministratorId, embySettings.FullUri).MovieInformation;
|
||||
ProcessMovies(movieInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var movieInfo = EmbyApi.GetInformation(m.Id, EmbyMediaType.Movie, embySettings.ApiKey,
|
||||
embySettings.AdministratorId, embySettings.FullUri).MovieInformation;
|
||||
|
||||
if (string.IsNullOrEmpty(movieInfo.ProviderIds.Imdb))
|
||||
{
|
||||
Log.Error("Provider Id on movie {0} is null", movieInfo.Name);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if it exists
|
||||
var item = EmbyContent.Custom(connection =>
|
||||
{
|
||||
connection.Open();
|
||||
var media = connection.QueryFirstOrDefault<EmbyContent>("select * from EmbyContent where ProviderId = @ProviderId and type = @type", new { ProviderId = movieInfo.ProviderIds.Imdb, type = 0 });
|
||||
connection.Dispose();
|
||||
return media;
|
||||
});
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
// Doesn't exist, insert it
|
||||
EmbyContent.Insert(new EmbyContent
|
||||
{
|
||||
ProviderId = movieInfo.ProviderIds.Imdb,
|
||||
PremierDate = movieInfo.PremiereDate,
|
||||
Title = movieInfo.Name,
|
||||
Type = Store.Models.Plex.EmbyMediaType.Movie,
|
||||
EmbyId = m.Id
|
||||
});
|
||||
ProcessMovies(movieInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,7 +158,8 @@ namespace Ombi.Services.Jobs
|
|||
PremierDate = tvInfo.PremiereDate,
|
||||
Title = tvInfo.Name,
|
||||
Type = Store.Models.Plex.EmbyMediaType.Series,
|
||||
EmbyId = t.Id
|
||||
EmbyId = t.Id,
|
||||
AddedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -249,5 +238,36 @@ namespace Ombi.Services.Jobs
|
|||
Job.SetRunning(false, JobNames.EmbyCacher);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessMovies(EmbyMovieInformation movieInfo)
|
||||
{
|
||||
if (string.IsNullOrEmpty(movieInfo.ProviderIds.Imdb))
|
||||
{
|
||||
Log.Error("Provider Id on movie {0} is null", movieInfo.Name);
|
||||
return;
|
||||
}
|
||||
// Check if it exists
|
||||
var item = EmbyContent.Custom(connection =>
|
||||
{
|
||||
connection.Open();
|
||||
var media = connection.QueryFirstOrDefault<EmbyContent>("select * from EmbyContent where ProviderId = @ProviderId and type = @type", new { ProviderId = movieInfo.ProviderIds.Imdb, type = 0 });
|
||||
connection.Dispose();
|
||||
return media;
|
||||
});
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
// Doesn't exist, insert it
|
||||
EmbyContent.Insert(new EmbyContent
|
||||
{
|
||||
ProviderId = movieInfo.ProviderIds.Imdb,
|
||||
PremierDate = movieInfo.PremiereDate,
|
||||
Title = movieInfo.Name,
|
||||
Type = Store.Models.Plex.EmbyMediaType.Movie,
|
||||
EmbyId = movieInfo.Id,
|
||||
AddedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dapper;
|
||||
using NLog;
|
||||
using Ombi.Api.Interfaces;
|
||||
using Ombi.Api.Models.Emby;
|
||||
|
@ -65,7 +66,8 @@ namespace Ombi.Services.Jobs
|
|||
|
||||
private const string TableName = "EmbyEpisodes";
|
||||
|
||||
|
||||
// Note, once an episode exists, we store it and it always exists.
|
||||
// We might want to look at checking if something has been removed from the server in the future.
|
||||
public void CacheEpisodes(EmbySettings settings)
|
||||
{
|
||||
var allEpisodes = EmbyApi.GetAllEpisodes(settings.ApiKey, settings.AdministratorId, settings.FullUri);
|
||||
|
@ -78,6 +80,22 @@ namespace Ombi.Services.Jobs
|
|||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check it this episode exists
|
||||
var item = Repo.Custom(connection =>
|
||||
{
|
||||
connection.Open();
|
||||
var media =
|
||||
connection.QueryFirstOrDefault<EmbyEpisodes>(
|
||||
"select * from EmbyEpisodes where ProviderId = @ProviderId",
|
||||
new {ProviderId = epInfo.EpisodeInformation?.ProviderIds?.Tvdb});
|
||||
connection.Dispose();
|
||||
return media;
|
||||
});
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
// add it
|
||||
model.Add(new EmbyEpisodes
|
||||
{
|
||||
EmbyId = ep.Id,
|
||||
|
@ -86,12 +104,11 @@ namespace Ombi.Services.Jobs
|
|||
EpisodeTitle = ep.Name,
|
||||
ParentId = ep.SeriesId,
|
||||
ShowTitle = ep.SeriesName,
|
||||
ProviderId = epInfo.EpisodeInformation.ProviderIds.Tvdb
|
||||
ProviderId = epInfo.EpisodeInformation.ProviderIds.Tvdb,
|
||||
AddedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
|
||||
// Delete all of the current items
|
||||
Repo.DeleteAll(TableName);
|
||||
}
|
||||
|
||||
// Insert the new items
|
||||
var result = Repo.BatchInsert(model, TableName, typeof(EmbyEpisodes).GetPropertyNames());
|
||||
|
|
|
@ -0,0 +1,343 @@
|
|||
#region Copyright
|
||||
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: RecentlyAddedModel.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using Ombi.Api;
|
||||
using Ombi.Api.Interfaces;
|
||||
using Ombi.Api.Models.Emby;
|
||||
using Ombi.Core;
|
||||
using Ombi.Core.SettingModels;
|
||||
using Ombi.Services.Jobs.Templates;
|
||||
using Ombi.Store.Models;
|
||||
using Ombi.Store.Models.Emby;
|
||||
using Ombi.Store.Repository;
|
||||
using EmbyMediaType = Ombi.Store.Models.Plex.EmbyMediaType;
|
||||
|
||||
namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||
{
|
||||
public class EmbyAddedNewsletter : HtmlTemplateGenerator, IEmbyAddedNewsletter
|
||||
{
|
||||
public EmbyAddedNewsletter(IEmbyApi api, ISettingsService<EmbySettings> embySettings,
|
||||
ISettingsService<EmailNotificationSettings> email,
|
||||
ISettingsService<NewletterSettings> newsletter, IRepository<RecentlyAddedLog> log,
|
||||
IRepository<EmbyContent> embyContent, IRepository<EmbyEpisodes> episodes)
|
||||
{
|
||||
Api = api;
|
||||
EmbySettings = embySettings;
|
||||
EmailSettings = email;
|
||||
NewsletterSettings = newsletter;
|
||||
Content = embyContent;
|
||||
MovieApi = new TheMovieDbApi();
|
||||
TvApi = new TvMazeApi();
|
||||
Episodes = episodes;
|
||||
RecentlyAddedLog = log;
|
||||
}
|
||||
|
||||
private IEmbyApi Api { get; }
|
||||
private TheMovieDbApi MovieApi { get; }
|
||||
private TvMazeApi TvApi { get; }
|
||||
private ISettingsService<EmbySettings> EmbySettings { get; }
|
||||
private ISettingsService<EmailNotificationSettings> EmailSettings { get; }
|
||||
private ISettingsService<NewletterSettings> NewsletterSettings { get; }
|
||||
private IRepository<EmbyContent> Content { get; }
|
||||
private IRepository<EmbyEpisodes> Episodes { get; }
|
||||
private IRepository<RecentlyAddedLog> RecentlyAddedLog { get; }
|
||||
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public string GetNewsletterHtml(bool test)
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetHtml(test);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private class EmbyRecentlyAddedModel
|
||||
{
|
||||
public EmbyInformation EmbyInformation { get; set; }
|
||||
public EmbyContent EmbyContent { get; set; }
|
||||
public List<EmbyEpisodeInformation> EpisodeInformation { get; set; }
|
||||
}
|
||||
|
||||
private string GetHtml(bool test)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var embySettings = EmbySettings.GetSettings();
|
||||
|
||||
var embyContent = Content.GetAll().ToList();
|
||||
|
||||
var series = embyContent.Where(x => x.Type == EmbyMediaType.Series).ToList();
|
||||
var episodes = Episodes.GetAll().ToList();
|
||||
var movie = embyContent.Where(x => x.Type == EmbyMediaType.Movie).ToList();
|
||||
|
||||
var recentlyAdded = RecentlyAddedLog.GetAll().ToList();
|
||||
|
||||
var firstRun = !recentlyAdded.Any();
|
||||
|
||||
var filteredMovies = movie.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList();
|
||||
var filteredEp = episodes.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList();
|
||||
|
||||
|
||||
var info = new List<EmbyRecentlyAddedModel>();
|
||||
foreach (var m in filteredMovies)
|
||||
{
|
||||
|
||||
var i = Api.GetInformation(m.EmbyId, Ombi.Api.Models.Emby.EmbyMediaType.Movie,
|
||||
embySettings.ApiKey, embySettings.AdministratorId, embySettings.FullUri);
|
||||
info.Add(new EmbyRecentlyAddedModel
|
||||
{
|
||||
EmbyInformation = i,
|
||||
EmbyContent = m
|
||||
});
|
||||
}
|
||||
GenerateMovieHtml(info, sb);
|
||||
|
||||
info.Clear();
|
||||
foreach (var t in series)
|
||||
{
|
||||
var i = Api.GetInformation(t.EmbyId, Ombi.Api.Models.Emby.EmbyMediaType.Series,
|
||||
embySettings.ApiKey, embySettings.AdministratorId, embySettings.FullUri);
|
||||
var ep = filteredEp.Where(x => x.ParentId == t.EmbyId);
|
||||
|
||||
if (ep.Any())
|
||||
{
|
||||
var episodeList = new List<EmbyEpisodeInformation>();
|
||||
foreach (var embyEpisodese in ep)
|
||||
{
|
||||
var epInfo = Api.GetInformation(embyEpisodese.EmbyId, Ombi.Api.Models.Emby.EmbyMediaType.Episode,
|
||||
embySettings.ApiKey, embySettings.AdministratorId, embySettings.FullUri);
|
||||
episodeList.Add(epInfo.EpisodeInformation);
|
||||
}
|
||||
info.Add(new EmbyRecentlyAddedModel
|
||||
{
|
||||
EmbyContent = t,
|
||||
EmbyInformation = i,
|
||||
EpisodeInformation = episodeList
|
||||
});
|
||||
}
|
||||
}
|
||||
GenerateTvHtml(info, sb);
|
||||
|
||||
var template = new RecentlyAddedTemplate();
|
||||
var html = template.LoadTemplate(sb.ToString());
|
||||
Log.Debug("Loaded the template");
|
||||
|
||||
if (!test || firstRun)
|
||||
{
|
||||
foreach (var a in filteredMovies)
|
||||
{
|
||||
RecentlyAddedLog.Insert(new RecentlyAddedLog
|
||||
{
|
||||
ProviderId = a.ProviderId,
|
||||
AddedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
foreach (var a in filteredEp)
|
||||
{
|
||||
RecentlyAddedLog.Insert(new RecentlyAddedLog
|
||||
{
|
||||
ProviderId = a.ProviderId,
|
||||
AddedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var escapedHtml = new string(html.Where(c => !char.IsControl(c)).ToArray());
|
||||
Log.Debug(escapedHtml);
|
||||
return escapedHtml;
|
||||
}
|
||||
|
||||
private void GenerateMovieHtml(IEnumerable<EmbyRecentlyAddedModel> movies, StringBuilder sb)
|
||||
{
|
||||
if (!movies.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var orderedMovies = movies.OrderByDescending(x => x.EmbyContent.AddedAt).Select(x => x.EmbyInformation.MovieInformation).ToList();
|
||||
sb.Append("<h1>New Movies:</h1><br /><br />");
|
||||
sb.Append(
|
||||
"<table border=\"0\" cellpadding=\"0\" align=\"center\" cellspacing=\"0\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;\" width=\"100%\">");
|
||||
foreach (var movie in orderedMovies)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var imdbId = movie.ProviderIds.Imdb;
|
||||
var info = MovieApi.GetMovieInformation(imdbId).Result;
|
||||
if (info == null)
|
||||
{
|
||||
throw new Exception($"Movie with Imdb id {imdbId} returned null from the MovieApi");
|
||||
}
|
||||
AddImageInsideTable(sb, $"https://image.tmdb.org/t/p/w500{info.BackdropPath}");
|
||||
|
||||
sb.Append("<tr>");
|
||||
sb.Append(
|
||||
"<td align=\"center\" style=\"font-family: sans-serif; font-size: 14px; vertical-align: top;\" valign=\"top\">");
|
||||
|
||||
Href(sb, $"https://www.imdb.com/title/{info.ImdbId}/");
|
||||
Header(sb, 3, $"{info.Title} {info.ReleaseDate?.ToString("yyyy") ?? string.Empty}");
|
||||
EndTag(sb, "a");
|
||||
|
||||
if (info.Genres.Any())
|
||||
{
|
||||
AddParagraph(sb,
|
||||
$"Genre: {string.Join(", ", info.Genres.Select(x => x.Name.ToString()).ToArray())}");
|
||||
}
|
||||
|
||||
AddParagraph(sb, info.Overview);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
Log.Error("Error for movie with IMDB Id = {0}", movie.ProviderIds.Imdb);
|
||||
}
|
||||
finally
|
||||
{
|
||||
EndLoopHtml(sb);
|
||||
}
|
||||
|
||||
}
|
||||
sb.Append("</table><br /><br />");
|
||||
}
|
||||
|
||||
private class TvModel
|
||||
{
|
||||
public EmbySeriesInformation Series { get; set; }
|
||||
public List<EmbyEpisodeInformation> Episodes { get; set; }
|
||||
}
|
||||
private void GenerateTvHtml(List<EmbyRecentlyAddedModel> tv, StringBuilder sb)
|
||||
{
|
||||
if (!tv.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var orderedTv = tv.OrderByDescending(x => x.EmbyContent.AddedAt).ToList();
|
||||
|
||||
// TV
|
||||
sb.Append("<h1>New Episodes:</h1><br /><br />");
|
||||
sb.Append(
|
||||
"<table border=\"0\" cellpadding=\"0\" align=\"center\" cellspacing=\"0\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;\" width=\"100%\">");
|
||||
foreach (var t in orderedTv)
|
||||
{
|
||||
var seriesItem = t.EmbyInformation.SeriesInformation;
|
||||
var relatedEpisodes = t.EpisodeInformation;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var info = TvApi.ShowLookupByTheTvDbId(int.Parse(seriesItem.ProviderIds.Tvdb));
|
||||
|
||||
var banner = info.image?.original;
|
||||
if (!string.IsNullOrEmpty(banner))
|
||||
{
|
||||
banner = banner.Replace("http", "https"); // Always use the Https banners
|
||||
}
|
||||
AddImageInsideTable(sb, banner);
|
||||
|
||||
sb.Append("<tr>");
|
||||
sb.Append(
|
||||
"<td align=\"center\" style=\"font-family: sans-serif; font-size: 14px; vertical-align: top;\" valign=\"top\">");
|
||||
|
||||
var title = $"{seriesItem.Name} {seriesItem.PremiereDate.Year}";
|
||||
|
||||
Href(sb, $"https://www.imdb.com/title/{info.externals.imdb}/");
|
||||
Header(sb, 3, title);
|
||||
EndTag(sb, "a");
|
||||
|
||||
var results = relatedEpisodes.GroupBy(p => p.ParentIndexNumber,
|
||||
(key, g) => new
|
||||
{
|
||||
ParentIndexNumber = key,
|
||||
IndexNumber = g.ToList()
|
||||
}
|
||||
);
|
||||
// Group the episodes
|
||||
foreach (var embyEpisodeInformation in results.OrderBy(x => x.ParentIndexNumber))
|
||||
{
|
||||
var epSb = new StringBuilder();
|
||||
for (var i = 0; i < embyEpisodeInformation.IndexNumber.Count; i++)
|
||||
{
|
||||
var ep = embyEpisodeInformation.IndexNumber[i];
|
||||
if (i < embyEpisodeInformation.IndexNumber.Count)
|
||||
{
|
||||
epSb.Append($"{ep.IndexNumber},");
|
||||
}
|
||||
else
|
||||
{
|
||||
epSb.Append(ep);
|
||||
}
|
||||
}
|
||||
AddParagraph(sb, $"Season: {embyEpisodeInformation.ParentIndexNumber}, Episode: {epSb}");
|
||||
}
|
||||
|
||||
if (info.genres.Any())
|
||||
{
|
||||
AddParagraph(sb, $"Genre: {string.Join(", ", info.genres.Select(x => x.ToString()).ToArray())}");
|
||||
}
|
||||
|
||||
AddParagraph(sb, string.IsNullOrEmpty(seriesItem.Overview) ? info.summary : seriesItem.Overview);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
EndLoopHtml(sb);
|
||||
}
|
||||
}
|
||||
sb.Append("</table><br /><br />");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void EndLoopHtml(StringBuilder sb)
|
||||
{
|
||||
//NOTE: BR have to be in TD's as per html spec or it will be put outside of the table...
|
||||
//Source: http://stackoverflow.com/questions/6588638/phantom-br-tag-rendered-by-browsers-prior-to-table-tag
|
||||
sb.Append("<hr />");
|
||||
sb.Append("<br />");
|
||||
sb.Append("<br />");
|
||||
sb.Append("</td>");
|
||||
sb.Append("</tr>");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||
{
|
||||
public interface IEmbyAddedNewsletter
|
||||
{
|
||||
string GetNewsletterHtml(bool test);
|
||||
}
|
||||
}
|
|
@ -46,14 +46,15 @@ using Ombi.Services.Interfaces;
|
|||
using Ombi.Services.Jobs.Templates;
|
||||
using Quartz;
|
||||
|
||||
namespace Ombi.Services.Jobs
|
||||
namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||
{
|
||||
public class RecentlyAdded : HtmlTemplateGenerator, IJob, IRecentlyAdded, IMassEmail
|
||||
public class RecentlyAddedNewsletter : HtmlTemplateGenerator, IJob, IRecentlyAdded, IMassEmail
|
||||
{
|
||||
public RecentlyAdded(IPlexApi api, ISettingsService<PlexSettings> plexSettings,
|
||||
public RecentlyAddedNewsletter(IPlexApi api, ISettingsService<PlexSettings> plexSettings,
|
||||
ISettingsService<EmailNotificationSettings> email, IJobRecord rec,
|
||||
ISettingsService<NewletterSettings> newsletter,
|
||||
IPlexReadOnlyDatabase db, IUserHelper userHelper)
|
||||
IPlexReadOnlyDatabase db, IUserHelper userHelper, IEmbyAddedNewsletter embyNews,
|
||||
ISettingsService<EmbySettings> embyS)
|
||||
{
|
||||
JobRecord = rec;
|
||||
Api = api;
|
||||
|
@ -62,23 +63,25 @@ namespace Ombi.Services.Jobs
|
|||
NewsletterSettings = newsletter;
|
||||
PlexDb = db;
|
||||
UserHelper = userHelper;
|
||||
EmbyNewsletter = embyNews;
|
||||
EmbySettings = embyS;
|
||||
}
|
||||
|
||||
private IPlexApi Api { get; }
|
||||
private TvMazeApi TvApi = new TvMazeApi();
|
||||
private readonly TheMovieDbApi _movieApi = new TheMovieDbApi();
|
||||
private const int MetadataTypeTv = 4;
|
||||
private const int MetadataTypeMovie = 1;
|
||||
private ISettingsService<PlexSettings> PlexSettings { get; }
|
||||
private ISettingsService<EmbySettings> EmbySettings { get; }
|
||||
private ISettingsService<EmailNotificationSettings> EmailSettings { get; }
|
||||
private ISettingsService<NewletterSettings> NewsletterSettings { get; }
|
||||
private IJobRecord JobRecord { get; }
|
||||
private IPlexReadOnlyDatabase PlexDb { get; }
|
||||
private IUserHelper UserHelper { get; }
|
||||
private IEmbyAddedNewsletter EmbyNewsletter { get; }
|
||||
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public void Start()
|
||||
public void StartNewsLetter()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -88,7 +91,7 @@ namespace Ombi.Services.Jobs
|
|||
return;
|
||||
}
|
||||
JobRecord.SetRunning(true, JobNames.RecentlyAddedEmail);
|
||||
Start(settings);
|
||||
StartNewsLetter(settings);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -102,35 +105,44 @@ namespace Ombi.Services.Jobs
|
|||
}
|
||||
public void Execute(IJobExecutionContext context)
|
||||
{
|
||||
Start();
|
||||
StartNewsLetter();
|
||||
}
|
||||
|
||||
public void RecentlyAddedAdminTest()
|
||||
{
|
||||
Log.Debug("Starting Recently Added Newsletter Test");
|
||||
var settings = NewsletterSettings.GetSettings();
|
||||
Start(settings, true);
|
||||
StartNewsLetter(settings, true);
|
||||
}
|
||||
|
||||
public void MassEmailAdminTest(string html, string subject)
|
||||
{
|
||||
Log.Debug("Starting Mass Email Test");
|
||||
var settings = NewsletterSettings.GetSettings();
|
||||
var plexSettings = PlexSettings.GetSettings();
|
||||
var template = new MassEmailTemplate();
|
||||
var body = template.LoadTemplate(html);
|
||||
Send(settings, body, plexSettings, true, subject);
|
||||
SendMassEmail(body, subject, true);
|
||||
}
|
||||
|
||||
public void SendMassEmail(string html, string subject)
|
||||
{
|
||||
Log.Debug("Starting Mass Email Test");
|
||||
var settings = NewsletterSettings.GetSettings();
|
||||
var plexSettings = PlexSettings.GetSettings();
|
||||
var template = new MassEmailTemplate();
|
||||
var body = template.LoadTemplate(html);
|
||||
Send(settings, body, plexSettings, false, subject);
|
||||
SendMassEmail(body, subject, false);
|
||||
}
|
||||
|
||||
private void Start(NewletterSettings newletterSettings, bool testEmail = false)
|
||||
private void StartNewsLetter(NewletterSettings newletterSettings, bool testEmail = false)
|
||||
{
|
||||
var embySettings = EmbySettings.GetSettings();
|
||||
if (embySettings.Enable)
|
||||
{
|
||||
var html = EmbyNewsletter.GetNewsletterHtml(testEmail);
|
||||
|
||||
var escapedHtml = new string(html.Where(c => !char.IsControl(c)).ToArray());
|
||||
Log.Debug(escapedHtml);
|
||||
SendNewsletter(newletterSettings, escapedHtml, testEmail);
|
||||
}
|
||||
else
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var plexSettings = PlexSettings.GetSettings();
|
||||
|
@ -218,11 +230,10 @@ namespace Ombi.Services.Jobs
|
|||
html = template.LoadTemplate(sb.ToString());
|
||||
Log.Debug("Loaded the template");
|
||||
}
|
||||
|
||||
|
||||
string escapedHtml = new string(html.Where(c => !char.IsControl(c)).ToArray());
|
||||
Log.Debug(escapedHtml);
|
||||
Send(newletterSettings, escapedHtml, plexSettings, testEmail);
|
||||
SendNewsletter(newletterSettings, escapedHtml, testEmail);
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateMovieHtml(List<RecentlyAddedChild> movies, PlexSettings plexSettings, StringBuilder sb)
|
||||
|
@ -457,9 +468,49 @@ namespace Ombi.Services.Jobs
|
|||
sb.Append("</table><br /><br />");
|
||||
}
|
||||
|
||||
private void Send(NewletterSettings newletterSettings, string html, PlexSettings plexSettings, bool testEmail = false, string subject = "New Content on Plex!")
|
||||
|
||||
private void SendMassEmail(string html, string subject, bool testEmail)
|
||||
{
|
||||
Log.Debug("Entering Send");
|
||||
var settings = EmailSettings.GetSettings();
|
||||
|
||||
if (!settings.Enabled || string.IsNullOrEmpty(settings.EmailHost))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var body = new BodyBuilder { HtmlBody = html, TextBody = "This email is only available on devices that support HTML." };
|
||||
|
||||
var message = new MimeMessage
|
||||
{
|
||||
Body = body.ToMessageBody(),
|
||||
Subject = subject
|
||||
};
|
||||
Log.Debug("Created Plain/HTML MIME body");
|
||||
|
||||
if (!testEmail)
|
||||
{
|
||||
var users = UserHelper.GetUsers(); // Get all users
|
||||
if (users != null)
|
||||
{
|
||||
foreach (var user in users)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(user.EmailAddress))
|
||||
{
|
||||
message.Bcc.Add(new MailboxAddress(user.Username, user.EmailAddress)); // BCC everyone
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
message.Bcc.Add(new MailboxAddress(settings.EmailUsername, settings.RecipientEmail)); // Include the admin
|
||||
|
||||
message.From.Add(new MailboxAddress(settings.EmailUsername, settings.EmailSender));
|
||||
SendMail(settings, message);
|
||||
}
|
||||
|
||||
// TODO Emby
|
||||
private void SendNewsletter(NewletterSettings newletterSettings, string html, bool testEmail = false, string subject = "New Content on Plex!")
|
||||
{
|
||||
Log.Debug("Entering SendNewsletter");
|
||||
var settings = EmailSettings.GetSettings();
|
||||
|
||||
if (!settings.Enabled || string.IsNullOrEmpty(settings.EmailHost))
|
||||
|
@ -506,6 +557,11 @@ namespace Ombi.Services.Jobs
|
|||
message.Bcc.Add(new MailboxAddress(settings.EmailUsername, settings.RecipientEmail)); // Include the admin
|
||||
|
||||
message.From.Add(new MailboxAddress(settings.EmailUsername, settings.EmailSender));
|
||||
SendMail(settings, message);
|
||||
}
|
||||
|
||||
private void SendMail(EmailNotificationSettings settings, MimeMessage message)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var client = new SmtpClient())
|
|
@ -144,7 +144,7 @@
|
|||
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="http://i.imgur.com/ROTp8mn.png" text-align="center" />
|
||||
<img src="http://i.imgur.com/qQsN78U.png" width="400px" text-align="center" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="http://i.imgur.com/ROTp8mn.png" text-align="center" />
|
||||
<img src="http://i.imgur.com/qQsN78U.png" width="400px" text-align="center" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -108,6 +108,8 @@
|
|||
<Compile Include="Jobs\EmbyEpisodeCacher.cs" />
|
||||
<Compile Include="Jobs\EmbyUserChecker.cs" />
|
||||
<Compile Include="Jobs\RadarrCacher.cs" />
|
||||
<Compile Include="Jobs\RecentlyAddedNewsletter\EmbyRecentlyAddedNewsletter.cs" />
|
||||
<Compile Include="Jobs\RecentlyAddedNewsletter\IEmbyAddedNewsletter.cs" />
|
||||
<Compile Include="Jobs\Templates\MassEmailTemplate.cs" />
|
||||
<Compile Include="Jobs\WatcherCacher.cs" />
|
||||
<Compile Include="Jobs\HtmlTemplateGenerator.cs" />
|
||||
|
@ -117,7 +119,7 @@
|
|||
<Compile Include="Jobs\JobNames.cs" />
|
||||
<Compile Include="Jobs\PlexContentCacher.cs" />
|
||||
<Compile Include="Jobs\PlexEpisodeCacher.cs" />
|
||||
<Compile Include="Jobs\RecentlyAdded.cs" />
|
||||
<Compile Include="Jobs\RecentlyAddedNewsletter\RecentlyAddedNewsletter.cs" />
|
||||
<Compile Include="Jobs\StoreBackup.cs" />
|
||||
<Compile Include="Jobs\PlexUserChecker.cs" />
|
||||
<Compile Include="Jobs\StoreCleanup.cs" />
|
||||
|
|
|
@ -39,5 +39,6 @@ namespace Ombi.Store.Models.Emby
|
|||
public DateTime PremierDate { get; set; }
|
||||
public string ProviderId { get; set; }
|
||||
public EmbyMediaType Type { get; set; }
|
||||
public DateTime AddedAt { get; set; }
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@
|
|||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using Dapper.Contrib.Extensions;
|
||||
|
||||
namespace Ombi.Store.Models.Emby
|
||||
|
@ -39,5 +40,6 @@ namespace Ombi.Store.Models.Emby
|
|||
public int SeasonNumber { get; set; }
|
||||
public string ParentId { get; set; }
|
||||
public string ProviderId { get; set; }
|
||||
public DateTime AddedAt { get; set; }
|
||||
}
|
||||
}
|
40
Ombi.Store/Models/RecenetlyAddedLog.cs
Normal file
40
Ombi.Store/Models/RecenetlyAddedLog.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: LogEntity.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using Dapper.Contrib.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ombi.Store.Models
|
||||
{
|
||||
[Table("RecentlyAddedLog")]
|
||||
public class RecentlyAddedLog : Entity
|
||||
{
|
||||
public string ProviderId { get; set; }
|
||||
public DateTime AddedAt { get; set; }
|
||||
}
|
||||
}
|
|
@ -68,6 +68,7 @@
|
|||
<Compile Include="Models\Emby\EmbyContent.cs" />
|
||||
<Compile Include="Models\Emby\EmbyEpisodes.cs" />
|
||||
<Compile Include="Models\IssueBlobs.cs" />
|
||||
<Compile Include="Models\RecenetlyAddedLog.cs" />
|
||||
<Compile Include="Models\Plex\PlexEpisodes.cs" />
|
||||
<Compile Include="Models\Emby\EmbyUsers.cs" />
|
||||
<Compile Include="Models\Plex\PlexUsers.cs" />
|
||||
|
|
|
@ -187,7 +187,8 @@ CREATE TABLE IF NOT EXISTS EmbyEpisodes
|
|||
SeasonNumber INTEGER NOT NULL,
|
||||
EpisodeNumber INTEGER NOT NULL,
|
||||
ParentId VARCHAR(100) NOT NULL,
|
||||
ProviderId VARCHAR(100) NOT NULL
|
||||
ProviderId VARCHAR(100) NOT NULL,
|
||||
AddedAt VARCHAR(100) NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS EmbyEpisodes_Id ON EmbyEpisodes (Id);
|
||||
|
||||
|
@ -198,9 +199,21 @@ CREATE TABLE IF NOT EXISTS EmbyContent
|
|||
PremierDate VARCHAR(100) NOT NULL,
|
||||
EmbyId VARCHAR(100) NOT NULL,
|
||||
ProviderId VARCHAR(100) NOT NULL,
|
||||
Type INTEGER NOT NULL
|
||||
Type INTEGER NOT NULL,
|
||||
AddedAt VARCHAR(100) NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS EmbyEpisodes_Id ON EmbyEpisodes (Id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS RecentlyAddedLog
|
||||
(
|
||||
Id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
ProviderId VARCHAR(100) NOT NULL,
|
||||
AddedAt VARCHAR(100) NOT NULL
|
||||
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS RecentlyAddedLog_Id ON RecentlyAddedLog (Id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS RecentlyAddedLog_ProviderId ON RecentlyAddedLog (ProviderId);
|
||||
|
||||
|
||||
COMMIT;
|
|
@ -314,6 +314,7 @@ namespace Ombi.UI.Helpers
|
|||
{
|
||||
url = $"/{content}{url}";
|
||||
}
|
||||
|
||||
var returnString = context.Request.Path == url ?
|
||||
$"<li class=\"active\"><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title}</a></li>"
|
||||
: $"<li><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title}</a></li>";
|
||||
|
@ -328,7 +329,14 @@ namespace Ombi.UI.Helpers
|
|||
{
|
||||
url = $"/{content}{url}";
|
||||
}
|
||||
|
||||
if (url.Contains("issues"))
|
||||
{
|
||||
var custom = GetCustomizationSettings();
|
||||
if (!custom.EnableIssues)
|
||||
{
|
||||
return helper.Raw(string.Empty);
|
||||
}
|
||||
}
|
||||
var returnString = context.Request.Path == url
|
||||
? $"<li class=\"active\"><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title} {extraHtml}</a></li>"
|
||||
: $"<li><a href=\"{url}\"><i class=\"fa fa-{fontIcon}\"></i> {title} {extraHtml}</a></li>";
|
||||
|
|
|
@ -35,6 +35,7 @@ using Ombi.Core;
|
|||
using Ombi.Core.SettingModels;
|
||||
using Ombi.Services.Interfaces;
|
||||
using Ombi.Services.Jobs;
|
||||
using Ombi.Services.Jobs.RecentlyAddedNewsletter;
|
||||
using Ombi.UI.Helpers;
|
||||
using Quartz;
|
||||
using Quartz.Impl;
|
||||
|
@ -70,7 +71,7 @@ namespace Ombi.UI.Jobs
|
|||
JobBuilder.Create<StoreBackup>().WithIdentity("StoreBackup", "Database").Build(),
|
||||
JobBuilder.Create<StoreCleanup>().WithIdentity("StoreCleanup", "Database").Build(),
|
||||
JobBuilder.Create<UserRequestLimitResetter>().WithIdentity("UserRequestLimiter", "Request").Build(),
|
||||
JobBuilder.Create<RecentlyAdded>().WithIdentity("RecentlyAddedModel", "Email").Build(),
|
||||
JobBuilder.Create<RecentlyAddedNewsletter>().WithIdentity("RecentlyAddedModel", "Email").Build(),
|
||||
JobBuilder.Create<FaultQueueHandler>().WithIdentity("FaultQueueHandler", "Fault").Build(),
|
||||
JobBuilder.Create<RadarrCacher>().WithIdentity("RadarrCacher", "Cache").Build(),
|
||||
|
||||
|
@ -304,8 +305,8 @@ namespace Ombi.UI.Jobs
|
|||
var embyEpisode =
|
||||
TriggerBuilder.Create()
|
||||
.WithIdentity("EmbyEpisodeCacher", "Emby")
|
||||
.StartNow()
|
||||
//.StartAt(DateBuilder.FutureDate(10, IntervalUnit.Minute))
|
||||
//.StartNow()
|
||||
.StartAt(DateBuilder.FutureDate(10, IntervalUnit.Minute))
|
||||
.WithSimpleSchedule(x => x.WithIntervalInHours(s.EmbyEpisodeCacher).RepeatForever())
|
||||
.Build();
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ using Nancy.Validation;
|
|||
using NLog;
|
||||
using Ombi.Api;
|
||||
using Ombi.Api.Interfaces;
|
||||
using Ombi.Api.Models.Movie;
|
||||
using Ombi.Core;
|
||||
using Ombi.Core.Models;
|
||||
using Ombi.Core.SettingModels;
|
||||
|
@ -823,6 +824,10 @@ namespace Ombi.UI.Modules.Admin
|
|||
{
|
||||
return Response.AsJson(valid.SendJsonError());
|
||||
}
|
||||
if (!settings.Enabled)
|
||||
{
|
||||
return Response.AsJson(new CouchPotatoProfiles{list = new List<ProfileList>()});
|
||||
}
|
||||
var profiles = CpApi.GetProfiles(settings.FullUri, settings.ApiKey);
|
||||
|
||||
// set the cache
|
||||
|
@ -1141,6 +1146,8 @@ namespace Ombi.UI.Modules.Admin
|
|||
var emby = await EmbySettings.GetSettingsAsync();
|
||||
var plex = await PlexService.GetSettingsAsync();
|
||||
|
||||
|
||||
|
||||
var dict = new Dictionary<string, DateTime>();
|
||||
|
||||
|
||||
|
@ -1152,9 +1159,26 @@ namespace Ombi.UI.Modules.Admin
|
|||
// We already have the key... Somehow, we should have never got this record.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (j.Name.Contains("Plex"))
|
||||
{
|
||||
if (plex.Enable)
|
||||
{
|
||||
dict.Add(j.Name, j.LastRun);
|
||||
}
|
||||
}
|
||||
else if (j.Name.Contains("Emby"))
|
||||
{
|
||||
if (emby.Enable)
|
||||
{
|
||||
dict.Add(j.Name, j.LastRun);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dict.Add(j.Name, j.LastRun);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace Ombi.UI.Modules.Admin
|
|||
}
|
||||
if (key.Equals(JobNames.RecentlyAddedEmail, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
RecentlyAdded.Start();
|
||||
RecentlyAdded.StartNewsLetter();
|
||||
}
|
||||
if (key.Equals(JobNames.FaultQueueHandler, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@ using Ombi.Helpers.Analytics;
|
|||
using Ombi.Services.Interfaces;
|
||||
using Ombi.Services.Jobs;
|
||||
using Ombi.Services.Jobs.Interfaces;
|
||||
using Ombi.Services.Jobs.RecentlyAddedNewsletter;
|
||||
using Ombi.UI.Jobs;
|
||||
using Quartz;
|
||||
using Quartz.Impl;
|
||||
|
@ -48,8 +49,8 @@ namespace Ombi.UI.NinjectModules
|
|||
Bind<IWatcherCacher>().To<WatcherCacher>();
|
||||
Bind<ISonarrCacher>().To<SonarrCacher>();
|
||||
Bind<ISickRageCacher>().To<SickRageCacher>();
|
||||
Bind<IRecentlyAdded>().To<RecentlyAdded>();
|
||||
Bind<IMassEmail>().To<RecentlyAdded>();
|
||||
Bind<IRecentlyAdded>().To<RecentlyAddedNewsletter>();
|
||||
Bind<IMassEmail>().To<RecentlyAddedNewsletter>();
|
||||
Bind<IRadarrCacher>().To<RadarrCacher>();
|
||||
Bind<IPlexContentCacher>().To<PlexContentCacher>();
|
||||
Bind<IJobFactory>().To<CustomJobFactory>();
|
||||
|
@ -65,6 +66,7 @@ namespace Ombi.UI.NinjectModules
|
|||
Bind<IEmbyContentCacher>().To<EmbyContentCacher>();
|
||||
Bind<IEmbyEpisodeCacher>().To<EmbyEpisodeCacher>();
|
||||
Bind<IEmbyUserChecker>().To<EmbyUserChecker>();
|
||||
Bind<IEmbyAddedNewsletter>().To<EmbyAddedNewsletter>();
|
||||
|
||||
|
||||
Bind<IAnalytics>().To<Analytics>();
|
||||
|
|
|
@ -104,7 +104,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
@Html.Checkbox(Model.Settings.NewSearch, "NewSearch", "Use New Search")
|
||||
@*@Html.Checkbox(Model.Settings.NewSearch, "NewSearch", "Use New Search")*@
|
||||
@Html.Checkbox(Model.Settings.EnableIssues, "EnableIssues", "Enable Issues")
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button type="submit" id="save" class="btn btn-primary-outline">Submit</button>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue