Merge pull request #2277 from tidusjar/develop

Develop
pull/2292/merge v3.0.3346
Jamie 7 years ago committed by GitHub
commit cf4d0acc6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,26 @@
# Changelog
## (unreleased)
### **New Features**
- Added a default set of root folders and qualities for Anime in Sonarr. [Jamie Rees]
### **Fixes**
- Fixed #2243 The refresh metadata was being run everytime we launched Ombi... [Jamie]
- Fixed a issue where the Plex Content Sync wouldn't pick up new shows #2276 #2244 #2261. [Jamie]
- Sort TvRequests by latest request. [Joe Harvey]
- Fixed build. [Jamie Rees]
- Fix newsletter card background overflow when only one item is available. [Anojh]
- Fix #1745. [Anojh]
## v3.0.3330 (2018-05-17)
### **New Features**

@ -142,7 +142,8 @@ namespace Ombi.Core.Engine
.Include(x => x.ChildRequests)
.ThenInclude(x => x.SeasonRequests)
.ThenInclude(x => x.Episodes)
.Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
.OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate))
.Skip(position).Take(count).ToListAsync();
// Filter out children
@ -154,7 +155,8 @@ namespace Ombi.Core.Engine
.Include(x => x.ChildRequests)
.ThenInclude(x => x.SeasonRequests)
.ThenInclude(x => x.Episodes)
.Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
.OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate))
.Skip(position).Take(count).ToListAsync();
}
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
@ -172,6 +174,7 @@ namespace Ombi.Core.Engine
.Include(x => x.ChildRequests)
.ThenInclude(x => x.SeasonRequests)
.ThenInclude(x => x.Episodes)
.OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate))
.Skip(position).Take(count).ToListAsync();
FilterChildren(allRequests, shouldHide);
@ -182,6 +185,7 @@ namespace Ombi.Core.Engine
.Include(x => x.ChildRequests)
.ThenInclude(x => x.SeasonRequests)
.ThenInclude(x => x.Episodes)
.OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate))
.Skip(position).Take(count).ToListAsync();
}

@ -118,17 +118,31 @@ namespace Ombi.Core.Senders
return null;
}
int.TryParse(s.QualityProfile, out var qualityToUse);
int qualityToUse;
string rootFolderPath;
if (model.SeriesType == SeriesType.Anime)
{
// Get the root path from the rootfolder selected.
// For some reason, if we haven't got one use the first root folder in Sonarr
// TODO make this overrideable via the UI
rootFolderPath = await GetSonarrRootPath(model.ParentRequest.RootFolder ?? int.Parse(s.RootPathAnime), s);
int.TryParse(s.QualityProfileAnime, out qualityToUse);
}
else
{
int.TryParse(s.QualityProfile, out qualityToUse);
// Get the root path from the rootfolder selected.
// For some reason, if we haven't got one use the first root folder in Sonarr
// TODO make this overrideable via the UI
rootFolderPath = await GetSonarrRootPath(model.ParentRequest.RootFolder ?? int.Parse(s.RootPath), s);
}
if (model.ParentRequest.QualityOverride.HasValue)
{
qualityToUse = model.ParentRequest.QualityOverride.Value;
}
// Get the root path from the rootfolder selected.
// For some reason, if we haven't got one use the first root folder in Sonarr
// TODO make this overrideable via the UI
var rootFolderPath = await GetSonarrRootPath(model.ParentRequest.RootFolder ?? int.Parse(s.RootPath), s);
try
{
// Does the series actually exist?
@ -160,13 +174,13 @@ namespace Ombi.Core.Senders
// Montitor the correct seasons,
// If we have that season in the model then it's monitored!
var seasonsToAdd = new List<Season>();
for (var i = 1; i < model.ParentRequest.TotalSeasons + 1; i++)
for (var i = 0; i < model.ParentRequest.TotalSeasons + 1; i++)
{
var index = i;
var season = new Season
{
seasonNumber = i,
monitored = model.SeasonRequests.Any(x => x.SeasonNumber == index)
monitored = model.SeasonRequests.Any(x => x.SeasonNumber == index && x.SeasonNumber != 0)
};
seasonsToAdd.Add(season);
}

@ -68,8 +68,6 @@ namespace Ombi.Schedule
RecurringJob.AddOrUpdate(() => _embyUserImporter.Start(), JobSettingsHelper.UserImporter(s));
RecurringJob.AddOrUpdate(() => _plexUserImporter.Start(), JobSettingsHelper.UserImporter(s));
RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s));
BackgroundJob.Enqueue(() => _refreshMetadata.Start());
}

@ -7,7 +7,7 @@ namespace Ombi.Schedule.Jobs.Ombi
protected virtual void AddBackgroundInsideTable(StringBuilder sb, string url)
{
sb.Append("<td align=\"center\" valign=\"top\" class=\"media-card\" style=\"font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 12px; vertical-align: top; padding: 3px; width: 502px; min-width: 500px; max-width: 500px; height: 235px; \">");
sb.AppendFormat("<table class=\"card-bg\" style=\"background-image: url({0}); border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; background-color: #1f1f1f; background-position: center; background-size: cover; background-repeat: no-repeat; background-clip: padding-box; border: 2px solid rgba(255,118,27,.4); height: 248px; max-height: 500px; \">", url);
sb.AppendFormat("<table class=\"card-bg\" style=\"background-image: url({0}); border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 500px; background-color: #1f1f1f; background-position: center; background-size: cover; background-repeat: no-repeat; background-clip: padding-box; border: 2px solid rgba(255,118,27,.4); height: 248px; max-height: 500px; \">", url);
sb.Append("<tr>");
sb.Append("<td>");
sb.Append("<table class=\"bg-tint\" style=\"background-color: rgba(0, 0, 0, .6); position: absolute; width: 490px; height: 239px; \">");

@ -119,7 +119,7 @@ namespace Ombi.Schedule.Jobs.Plex
{
try
{
Logger.LogInformation("Starting to cache the content on server {0}", servers.Name);
Logger.LogInformation("Starting to cache the content on server {0}", servers.Name);
if (recentlyAddedSearch)
{
@ -162,8 +162,10 @@ namespace Ombi.Schedule.Jobs.Plex
if (content.viewGroup.Equals(PlexMediaType.Episode.ToString(), StringComparison.CurrentCultureIgnoreCase))
{
Logger.LogInformation("Found some episodes, this must be a recently added sync");
var count = 0;
foreach (var epInfo in content.Metadata)
{
count++;
var grandParentKey = epInfo.grandparentRatingKey;
// Lookup the rating key
var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri, grandParentKey);
@ -174,18 +176,59 @@ namespace Ombi.Schedule.Jobs.Plex
}
await ProcessTvShow(servers, show, contentToAdd, recentlyAddedSearch, processedContent);
if (contentToAdd.Any())
{
await Repo.AddRange(contentToAdd, false);
if (recentlyAddedSearch)
{
foreach (var plexServerContent in contentToAdd)
{
processedContent.Add(plexServerContent.Id);
}
}
contentToAdd.Clear();
}
if (count > 200)
{
await Repo.SaveChangesAsync();
}
}
// Save just to make sure we don't leave anything hanging
await Repo.SaveChangesAsync();
await EpisodeSync.ProcessEpsiodes(content.Metadata, allEps);
}
if (content.viewGroup.Equals(PlexMediaType.Show.ToString(), StringComparison.CurrentCultureIgnoreCase))
{
// Process Shows
Logger.LogInformation("Processing TV Shows");
var count = 0;
foreach (var show in content.Metadata ?? new Metadata[] { })
{
count++;
await ProcessTvShow(servers, show, contentToAdd, recentlyAddedSearch, processedContent);
if (contentToAdd.Any())
{
await Repo.AddRange(contentToAdd, false);
if (recentlyAddedSearch)
{
foreach (var plexServerContent in contentToAdd)
{
processedContent.Add(plexServerContent.Id);
}
}
contentToAdd.Clear();
}
if (count > 200)
{
await Repo.SaveChangesAsync();
}
}
await Repo.SaveChangesAsync();
}
if (content.viewGroup.Equals(PlexMediaType.Movie.ToString(), StringComparison.CurrentCultureIgnoreCase))
{
@ -464,21 +507,6 @@ namespace Ombi.Schedule.Jobs.Plex
show.title);
}
}
if (contentToAdd.Count > 500 || recentlyAdded)
{
await Repo.AddRange(contentToAdd);
foreach (var plexServerContent in contentToAdd)
{
contentProcessed.Add(plexServerContent.Id);
}
contentToAdd.Clear();
}
if (contentToAdd.Any())
{
await Repo.AddRange(contentToAdd);
}
}
/// <summary>

@ -13,6 +13,10 @@
/// The root path.
/// </value>
public string RootPath { get; set; }
public string QualityProfileAnime { get; set; }
public string RootPathAnime { get; set; }
public bool AddOnly { get; set; }
}
}

@ -14,7 +14,7 @@ namespace Ombi.Store.Repository
Task<T> Find(object key);
IQueryable<T> GetAll();
Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate);
Task AddRange(IEnumerable<T> content);
Task AddRange(IEnumerable<T> content, bool save = true);
Task<T> Add(T content);
Task DeleteRange(IEnumerable<T> req);
Task Delete(T request);

@ -35,10 +35,13 @@ namespace Ombi.Store.Repository
return await _db.FirstOrDefaultAsync(predicate);
}
public async Task AddRange(IEnumerable<T> content)
public async Task AddRange(IEnumerable<T> content, bool save = true)
{
_db.AddRange(content);
await _ctx.SaveChangesAsync();
if (save)
{
await _ctx.SaveChangesAsync();
}
}
public async Task<T> Add(T content)

@ -65,8 +65,10 @@ export interface ISonarrSettings extends IExternalSettings {
apiKey: string;
enabled: boolean;
qualityProfile: string;
qualityProfileAnime: string;
seasonFolders: boolean;
rootPath: string;
rootPathAnime: string;
fullRootPath: string;
addOnly: boolean;
}

@ -68,6 +68,14 @@
<small *ngIf="form.get('qualityProfile').hasError('required')" class="error-text">A Default Quality Profile is required</small>
</div>
<div class="form-group">
<label for="select" class="control-label">Quality Profiles (Anime)</label>
<div id="qualityProfileAnime">
<select class="form-control form-control-custom" id="qualityProfileAnime" formControlName="qualityProfileAnime">
<option *ngFor="let quality of qualities" value="{{quality.id}}" >{{quality.name}}</option>
</select>
</div>
</div>
<div class="form-group">
<div>
@ -85,6 +93,15 @@
<small *ngIf="form.get('rootPath').hasError('required')" class="error-text">A Default Root Path is required</small>
</div>
<div class="form-group">
<label for="rootFoldersAnime" class="control-label">Default Root Folders (Anime)</label>
<div id="rootFoldersAnime">
<select class="form-control form-control-custom" formControlName="rootPathAnime">
<option *ngFor="let folder of rootFoldersAnime" value="{{folder.id}}">{{folder.path}}</option>
</select>
</div>
</div>
<div class="form-group">

@ -15,7 +15,9 @@ import { SettingsService } from "../../services";
export class SonarrComponent implements OnInit {
public qualities: ISonarrProfile[];
public qualitiesAnime: ISonarrProfile[];
public rootFolders: ISonarrRootFolder[];
public rootFoldersAnime: ISonarrRootFolder[];
public selectedRootFolder: ISonarrRootFolder;
public selectedQuality: ISonarrProfile;
public profilesRunning: boolean;
@ -37,6 +39,8 @@ export class SonarrComponent implements OnInit {
apiKey: [x.apiKey, [Validators.required]],
qualityProfile: [x.qualityProfile, [Validators.required]],
rootPath: [x.rootPath, [Validators.required]],
qualityProfileAnime: [x.qualityProfileAnime],
rootPathAnime: [x.rootPathAnime],
ssl: [x.ssl],
subDir: [x.subDir],
ip: [x.ip, [Validators.required]],
@ -64,6 +68,7 @@ export class SonarrComponent implements OnInit {
.subscribe(x => {
this.qualities = x;
this.qualities.unshift({ name: "Please Select", id: -1 });
this.qualitiesAnime = x;
this.profilesRunning = false;
this.notificationService.success("Successfully retrieved the Quality Profiles");
@ -76,6 +81,7 @@ export class SonarrComponent implements OnInit {
.subscribe(x => {
this.rootFolders = x;
this.rootFolders.unshift({ path: "Please Select", id: -1 });
this.rootFoldersAnime = x;
this.rootFoldersRunning = false;
this.notificationService.success("Successfully retrieved the Root Folders");

Loading…
Cancel
Save