mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
commit
023ad680e2
9 changed files with 161 additions and 15 deletions
|
@ -94,7 +94,7 @@ namespace Ombi.Core.Migration.Migrations
|
|||
content.Add(new RecentlyAddedLog
|
||||
{
|
||||
AddedAt = DateTime.UtcNow,
|
||||
ProviderId = ep.ProviderId
|
||||
ProviderId = ep.RatingKey
|
||||
});
|
||||
}
|
||||
|
||||
|
|
134
Ombi.Core.Migration/Migrations/Version2210.cs
Normal file
134
Ombi.Core.Migration/Migrations/Version2210.cs
Normal file
|
@ -0,0 +1,134 @@
|
|||
#region Copyright
|
||||
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: Version1100.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.Data;
|
||||
using NLog;
|
||||
using Ombi.Core.SettingModels;
|
||||
using Ombi.Store;
|
||||
using Ombi.Store.Models;
|
||||
using Ombi.Store.Models.Emby;
|
||||
using Ombi.Store.Models.Plex;
|
||||
using Ombi.Store.Repository;
|
||||
using Quartz.Collection;
|
||||
|
||||
namespace Ombi.Core.Migration.Migrations
|
||||
{
|
||||
[Migration(22100, "v2.21.0.0")]
|
||||
public class Version2210 : BaseMigration, IMigration
|
||||
{
|
||||
public Version2210(IRepository<RecentlyAddedLog> log,
|
||||
IRepository<PlexContent> content, IRepository<PlexEpisodes> plexEp, IRepository<EmbyContent> embyContent, IRepository<EmbyEpisodes> embyEp)
|
||||
{
|
||||
Log = log;
|
||||
PlexContent = content;
|
||||
PlexEpisodes = plexEp;
|
||||
EmbyContent = embyContent;
|
||||
EmbyEpisodes = embyEp;
|
||||
}
|
||||
|
||||
public int Version => 22000;
|
||||
private IRepository<RecentlyAddedLog> Log { get; }
|
||||
private IRepository<PlexContent> PlexContent { get; }
|
||||
private IRepository<PlexEpisodes> PlexEpisodes { get; }
|
||||
private IRepository<EmbyContent> EmbyContent { get; }
|
||||
private IRepository<EmbyEpisodes> EmbyEpisodes { get; }
|
||||
|
||||
public void Start(IDbConnection con)
|
||||
{
|
||||
UpdateRecentlyAdded(con);
|
||||
UpdateSchema(con, Version);
|
||||
|
||||
}
|
||||
|
||||
private void UpdateRecentlyAdded(IDbConnection con)
|
||||
{
|
||||
|
||||
//Delete the recently added table, lets start again
|
||||
Log.DeleteAll("RecentlyAddedLog");
|
||||
|
||||
|
||||
|
||||
// Plex
|
||||
var plexAllContent = PlexContent.GetAll();
|
||||
var content = new HashSet<RecentlyAddedLog>();
|
||||
foreach (var plexContent in plexAllContent)
|
||||
{
|
||||
if(plexContent.Type == PlexMediaType.Artist) continue;
|
||||
content.Add(new RecentlyAddedLog
|
||||
{
|
||||
AddedAt = DateTime.UtcNow,
|
||||
ProviderId = plexContent.ProviderId
|
||||
});
|
||||
}
|
||||
Log.BatchInsert(content, "RecentlyAddedLog");
|
||||
|
||||
var plexEpisodeses = PlexEpisodes.GetAll();
|
||||
content.Clear();
|
||||
foreach (var ep in plexEpisodeses)
|
||||
{
|
||||
content.Add(new RecentlyAddedLog
|
||||
{
|
||||
AddedAt = DateTime.UtcNow,
|
||||
ProviderId = ep.RatingKey
|
||||
});
|
||||
}
|
||||
Log.BatchInsert(content, "RecentlyAddedLog");
|
||||
|
||||
// Emby
|
||||
content.Clear();
|
||||
var embyContent = EmbyContent.GetAll();
|
||||
foreach (var plexContent in embyContent)
|
||||
{
|
||||
content.Add(new RecentlyAddedLog
|
||||
{
|
||||
AddedAt = DateTime.UtcNow,
|
||||
ProviderId = plexContent.EmbyId
|
||||
});
|
||||
}
|
||||
Log.BatchInsert(content, "RecentlyAddedLog");
|
||||
|
||||
var embyEpisodes = EmbyEpisodes.GetAll();
|
||||
content.Clear();
|
||||
foreach (var ep in embyEpisodes)
|
||||
{
|
||||
content.Add(new RecentlyAddedLog
|
||||
{
|
||||
AddedAt = DateTime.UtcNow,
|
||||
ProviderId = ep.EmbyId
|
||||
});
|
||||
}
|
||||
Log.BatchInsert(content, "RecentlyAddedLog");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -69,6 +69,7 @@
|
|||
<Compile Include="MigrationAttribute.cs" />
|
||||
<Compile Include="MigrationRunner.cs" />
|
||||
<Compile Include="Migrations\BaseMigration.cs" />
|
||||
<Compile Include="Migrations\Version2210.cs" />
|
||||
<Compile Include="Migrations\Version2200.cs" />
|
||||
<Compile Include="Migrations\Version1100.cs" />
|
||||
<Compile Include="Migrations\Version195.cs" />
|
||||
|
|
|
@ -115,9 +115,9 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
|||
|
||||
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 filteredSeries = series.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList();
|
||||
var filteredMovies = movie.Where(m => recentlyAdded.All(x => x.ProviderId != m.EmbyId)).ToList();
|
||||
var filteredEp = episodes.Where(m => recentlyAdded.All(x => x.ProviderId != m.EmbyId)).ToList();
|
||||
var filteredSeries = series.Where(m => recentlyAdded.All(x => x.ProviderId != m.EmbyId)).ToList();
|
||||
|
||||
var info = new List<EmbyRecentlyAddedModel>();
|
||||
foreach (var m in filteredMovies)
|
||||
|
@ -144,6 +144,11 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
|||
|
||||
// Check if there are any epiosdes, then get the series info.
|
||||
// Otherwise then just add the series to the newsletter
|
||||
if (test && !filteredEp.Any() && episodes.Any())
|
||||
{
|
||||
// if this is a test make sure we show something
|
||||
filteredEp = episodes.Take(5).ToList();
|
||||
}
|
||||
if (filteredEp.Any())
|
||||
{
|
||||
var recentlyAddedModel = new List<EmbyRecentlyAddedModel>();
|
||||
|
@ -239,7 +244,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
|||
{
|
||||
RecentlyAddedLog.Insert(new RecentlyAddedLog
|
||||
{
|
||||
ProviderId = a.ProviderId,
|
||||
ProviderId = a.EmbyId,
|
||||
AddedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
|
@ -247,7 +252,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
|||
{
|
||||
RecentlyAddedLog.Insert(new RecentlyAddedLog
|
||||
{
|
||||
ProviderId = a.ProviderId,
|
||||
ProviderId = a.EmbyId,
|
||||
AddedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
|
@ -255,7 +260,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
|||
{
|
||||
RecentlyAddedLog.Insert(new RecentlyAddedLog
|
||||
{
|
||||
ProviderId = s.ProviderId,
|
||||
ProviderId = s.EmbyId,
|
||||
AddedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
|||
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 filteredEp = episodes.Where(m => recentlyAdded.All(x => x.ProviderId != m.RatingKey)).ToList();
|
||||
var filteredSeries = series.Where(x => recentlyAdded.All(c => c.ProviderId != x.ProviderId)).ToList();
|
||||
|
||||
var info = new List<PlexRecentlyAddedModel>();
|
||||
|
@ -144,6 +144,11 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
|||
newsletter.MovieCount = info.Count;
|
||||
|
||||
info.Clear();
|
||||
if (test && !filteredEp.Any() && episodes.Any())
|
||||
{
|
||||
// if this is a test make sure we show something
|
||||
filteredEp = episodes.Take(5).ToList();
|
||||
}
|
||||
if (filteredEp.Any())
|
||||
{
|
||||
var recentlyAddedModel = new List<PlexRecentlyAddedModel>();
|
||||
|
@ -226,7 +231,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
|||
{
|
||||
RecentlyAddedLog.Insert(new RecentlyAddedLog
|
||||
{
|
||||
ProviderId = a.ProviderId,
|
||||
ProviderId = a.RatingKey,
|
||||
AddedAt = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
|
@ -335,7 +340,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
|||
|
||||
try
|
||||
{
|
||||
var info = TvApi.ShowLookupByTheTvDbId(int.Parse(PlexHelper.GetProviderIdFromPlexGuid(t.Metadata.Directory.Guid)));
|
||||
var info = TvApi.ShowLookupByTheTvDbId(int.Parse(PlexHelper.GetProviderIdFromPlexGuid(t?.Metadata?.Directory?.Guid ?? string.Empty)));
|
||||
|
||||
var banner = info.image?.original;
|
||||
if (!string.IsNullOrEmpty(banner))
|
||||
|
@ -370,7 +375,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
|||
for (var i = 0; i < orderedEpisodes.Count; i++)
|
||||
{
|
||||
var ep = orderedEpisodes[i];
|
||||
if (i <= orderedEpisodes.Count - 1)
|
||||
if (i < orderedEpisodes.Count - 1)
|
||||
{
|
||||
epSb.Append($"{ep.Video.FirstOrDefault().Index},");
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ namespace Ombi.Store.Models
|
|||
[Table("RecentlyAddedLog")]
|
||||
public class RecentlyAddedLog : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// This is actually a unique id for that content...
|
||||
/// </summary>
|
||||
public string ProviderId { get; set; }
|
||||
public DateTime AddedAt { get; set; }
|
||||
}
|
|
@ -68,7 +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\RecentlyAddedLog.cs" />
|
||||
<Compile Include="Models\Plex\PlexEpisodes.cs" />
|
||||
<Compile Include="Models\Emby\EmbyUsers.cs" />
|
||||
<Compile Include="Models\Plex\PlexUsers.cs" />
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<div class="form-group">
|
||||
<div>
|
||||
|
||||
<button id="recentlyAddedBtn" class="btn btn-primary-outline">Send test email to Admin @Html.ToolTip("Note: nothing will send if there is no new content...")
|
||||
<button id="recentlyAddedBtn" class="btn btn-primary-outline">Send test email to Admin @Html.ToolTip("Note: If there is nothing new when testing this, we will just grab some random titles. If there are new items, then we will show those new items. Testing will not mark the content as 'Previously Sent'")
|
||||
<div id="testEmailSpinner"></div></button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -7,8 +7,6 @@ assembly_info:
|
|||
assembly_version: '3.0.0'
|
||||
assembly_file_version: '{version}'
|
||||
assembly_informational_version: '3.0.0'
|
||||
|
||||
|
||||
before_build:
|
||||
- cmd: cd ombi/ombi
|
||||
- appveyor-retry dotnet restore
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue