mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
feat: almost got it all working now
This commit is contained in:
parent
503b80a2a5
commit
5169ffd6ce
15 changed files with 227 additions and 28 deletions
|
@ -44,7 +44,10 @@ namespace Ombi.Api.Radarr.Models
|
|||
public int id { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class MovieQuality
|
||||
{
|
||||
public V3.Quality quality { get; set; }
|
||||
}
|
||||
public class Moviefile
|
||||
{
|
||||
public int movieId { get; set; }
|
||||
|
@ -54,7 +57,7 @@ namespace Ombi.Api.Radarr.Models
|
|||
public DateTime dateAdded { get; set; }
|
||||
public string sceneName { get; set; }
|
||||
public int indexerFlags { get; set; }
|
||||
public V3.Quality quality { get; set; }
|
||||
public MovieQuality quality { get; set; }
|
||||
public Mediainfo mediaInfo { get; set; }
|
||||
public string originalFilePath { get; set; }
|
||||
public bool qualityCutoffNotMet { get; set; }
|
||||
|
|
|
@ -35,7 +35,8 @@ namespace Ombi.Core.Tests.Rule.Search
|
|||
SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new EmbySettings());
|
||||
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new EmbyContent
|
||||
{
|
||||
TheMovieDbId = "123"
|
||||
TheMovieDbId = "123",
|
||||
Quality = "1"
|
||||
});
|
||||
var search = new SearchMovieViewModel()
|
||||
{
|
||||
|
@ -47,6 +48,47 @@ namespace Ombi.Core.Tests.Rule.Search
|
|||
Assert.True(search.Available);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Movie_ShouldBe_Available_WhenFoundInEmby_4K()
|
||||
{
|
||||
SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new EmbySettings());
|
||||
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new EmbyContent
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
Has4K = true
|
||||
});
|
||||
var search = new SearchMovieViewModel()
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
};
|
||||
var result = await Rule.Execute(search);
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.True(search.Available4K);
|
||||
Assert.False(search.Available);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Movie_ShouldBe_Available_WhenFoundInEmby_Both()
|
||||
{
|
||||
SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new EmbySettings());
|
||||
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new EmbyContent
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
Has4K = true,
|
||||
Quality = "1"
|
||||
});
|
||||
var search = new SearchMovieViewModel()
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
};
|
||||
var result = await Rule.Execute(search);
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.True(search.Available4K);
|
||||
Assert.True(search.Available);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Movie_ShouldBe_NotAvailable_WhenNotFoundInEmby()
|
||||
{
|
||||
|
|
|
@ -35,7 +35,8 @@ namespace Ombi.Core.Tests.Rule.Search
|
|||
SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new JellyfinSettings());
|
||||
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||
{
|
||||
ProviderId = "123"
|
||||
TheMovieDbId = "123",
|
||||
Quality = "1080"
|
||||
});
|
||||
var search = new SearchMovieViewModel()
|
||||
{
|
||||
|
@ -47,6 +48,47 @@ namespace Ombi.Core.Tests.Rule.Search
|
|||
Assert.True(search.Available);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin_4K()
|
||||
{
|
||||
SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new JellyfinSettings());
|
||||
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
Has4K = true
|
||||
});
|
||||
var search = new SearchMovieViewModel()
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
};
|
||||
var result = await Rule.Execute(search);
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.False(search.Available);
|
||||
Assert.True(search.Available4K);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin_Both()
|
||||
{
|
||||
SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new JellyfinSettings());
|
||||
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
Has4K = true,
|
||||
Quality = "1"
|
||||
});
|
||||
var search = new SearchMovieViewModel()
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
};
|
||||
var result = await Rule.Execute(search);
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.True(search.Available);
|
||||
Assert.True(search.Available4K);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Movie_Uses_Default_Url_When()
|
||||
{
|
||||
|
@ -66,7 +108,7 @@ namespace Ombi.Core.Tests.Rule.Search
|
|||
});
|
||||
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||
{
|
||||
ProviderId = "123",
|
||||
TheMovieDbId = "123",
|
||||
JellyfinId = 1.ToString()
|
||||
});
|
||||
var search = new SearchMovieViewModel()
|
||||
|
|
|
@ -28,25 +28,67 @@ namespace Ombi.Core.Tests.Rule.Search
|
|||
{
|
||||
var list = new List<RadarrCache>(){new RadarrCache
|
||||
{
|
||||
TheMovieDbId = 123
|
||||
TheMovieDbId = 123,
|
||||
HasRegular = true
|
||||
}}.AsQueryable();
|
||||
|
||||
|
||||
ContextMock.Setup(x => x.GetAll()).Returns(list);
|
||||
|
||||
var request = new SearchMovieViewModel { Id = 123 };
|
||||
var result =await Rule.Execute(request);
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.True(request.Approved);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Should_ReturnAvailabl_WhenMovieIsInRadarr_4K()
|
||||
{
|
||||
var list = new List<RadarrCache>(){new RadarrCache
|
||||
{
|
||||
TheMovieDbId = 123,
|
||||
Has4K = true,
|
||||
HasFile = true
|
||||
}}.AsQueryable();
|
||||
|
||||
ContextMock.Setup(x => x.GetAll()).Returns(list);
|
||||
|
||||
var request = new SearchMovieViewModel { Id = 123 };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.False(request.Available);
|
||||
Assert.True(request.Available4K);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Should_ReturnAvailable_WhenMovieIsInRadarr_Both()
|
||||
{
|
||||
var list = new List<RadarrCache>(){new RadarrCache
|
||||
{
|
||||
TheMovieDbId = 123,
|
||||
Has4K = true,
|
||||
HasRegular = true,
|
||||
HasFile = true
|
||||
}}.AsQueryable();
|
||||
|
||||
ContextMock.Setup(x => x.GetAll()).Returns(list);
|
||||
|
||||
var request = new SearchMovieViewModel { Id = 123 };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.True(request.Available);
|
||||
Assert.True(request.Available4K);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Should_ReturnNotApproved_WhenMovieIsNotInRadarr()
|
||||
{
|
||||
var list = DbHelper.GetQueryableMockDbSet(new RadarrCache
|
||||
{
|
||||
TheMovieDbId = 000012
|
||||
TheMovieDbId = 000012,
|
||||
});
|
||||
|
||||
ContextMock.Setup(x => x.GetAll()).Returns(list);
|
||||
|
|
|
@ -63,11 +63,29 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
obj.Available = true;
|
||||
obj.EmbyUrl = item.Url;
|
||||
if (obj is SearchMovieViewModel movie)
|
||||
{
|
||||
if (item.Has4K)
|
||||
{
|
||||
movie.Available4K = true;
|
||||
obj.EmbyUrl = item.Url;
|
||||
}
|
||||
|
||||
if (item.Quality.HasValue())
|
||||
{
|
||||
obj.Available = true;
|
||||
obj.EmbyUrl = item.Url;
|
||||
obj.Quality = item.Quality;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.Available = true;
|
||||
obj.EmbyUrl = item.Url;
|
||||
}
|
||||
|
||||
if (obj.Type == RequestType.TvShow)
|
||||
{
|
||||
|
|
|
@ -26,9 +26,8 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
|
||||
public async Task<RuleResult> Execute(SearchViewModel obj)
|
||||
{
|
||||
if (obj.Type == RequestType.Movie)
|
||||
if (obj is SearchMovieViewModel movie)
|
||||
{
|
||||
var movie = (SearchMovieViewModel)obj;
|
||||
var movieRequests = await Movie.GetRequestAsync(obj.Id);
|
||||
if (movieRequests != null) // Do we already have a request for this?
|
||||
{
|
||||
|
|
|
@ -80,8 +80,26 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
obj.TheMovieDbId = obj.Id.ToString();
|
||||
useTheMovieDb = true;
|
||||
}
|
||||
obj.Available = true;
|
||||
obj.JellyfinUrl = item.Url;
|
||||
if (obj is SearchMovieViewModel movie)
|
||||
{
|
||||
if (item.Has4K)
|
||||
{
|
||||
movie.Available4K = true;
|
||||
obj.JellyfinUrl = item.Url;
|
||||
}
|
||||
|
||||
if (item.Quality.HasValue())
|
||||
{
|
||||
obj.Available = true;
|
||||
obj.EmbyUrl = item.Url;
|
||||
obj.Quality = item.Quality;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.Available = true;
|
||||
obj.JellyfinUrl = item.Url;
|
||||
}
|
||||
|
||||
if (obj.Type == RequestType.TvShow)
|
||||
{
|
||||
|
|
|
@ -89,7 +89,25 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
obj.TheMovieDbId = obj.Id.ToString();
|
||||
useTheMovieDb = true;
|
||||
}
|
||||
obj.Available = true;
|
||||
|
||||
if (obj is SearchMovieViewModel movie)
|
||||
{
|
||||
if (item.Has4K)
|
||||
{
|
||||
movie.Available4K = true;
|
||||
}
|
||||
|
||||
if (item.Quality.HasValue())
|
||||
{
|
||||
obj.Available = true;
|
||||
obj.Quality = item.Quality;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.Available = true;
|
||||
}
|
||||
|
||||
if (item.Url.StartsWith("http"))
|
||||
{
|
||||
obj.PlexUrl = item.Url;
|
||||
|
@ -99,11 +117,9 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
// legacy content
|
||||
obj.PlexUrl = PlexHelper.BuildPlexMediaUrl(item.Url, host);
|
||||
}
|
||||
obj.Quality = item.Quality;
|
||||
|
||||
if (obj.Type == RequestType.TvShow)
|
||||
if (obj is SearchTvShowViewModel search)
|
||||
{
|
||||
var search = (SearchTvShowViewModel)obj;
|
||||
// Let's go through the episodes now
|
||||
if (search.SeasonRequests.Any())
|
||||
{
|
||||
|
|
|
@ -18,16 +18,23 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
|
||||
public Task<RuleResult> Execute(SearchViewModel obj)
|
||||
{
|
||||
if (obj.Type == RequestType.Movie)
|
||||
if (obj is SearchMovieViewModel movie)
|
||||
{
|
||||
// Check if it's in Radarr
|
||||
var result = _db.GetAll().FirstOrDefault(x => x.TheMovieDbId == obj.Id);
|
||||
if (result != null)
|
||||
{
|
||||
obj.Approved = true; // It's in radarr so it's approved... Maybe have a new property called "Processing" or something?
|
||||
movie.Approved = true; // It's in radarr so it's approved... Maybe have a new property called "Processing" or something?
|
||||
if (result.HasFile)
|
||||
{
|
||||
obj.Available = true;
|
||||
if (result.Has4K)
|
||||
{
|
||||
movie.Available4K = true;
|
||||
}
|
||||
if (result.HasRegular)
|
||||
{
|
||||
movie.Available = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,6 +209,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
if (has4kRequest && item.Has4K)
|
||||
{
|
||||
movie.Available4K = true;
|
||||
movie.Approved4K = true;
|
||||
movie.MarkedAsAvailable4K = DateTime.Now;
|
||||
}
|
||||
|
||||
|
@ -216,6 +217,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
if (item.Quality.HasValue())
|
||||
{
|
||||
movie.Available = true;
|
||||
movie.Approved = true;
|
||||
movie.MarkedAsAvailable = DateTime.Now;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace Ombi.Schedule.Jobs.Radarr
|
|||
{
|
||||
if (m.tmdbId > 0)
|
||||
{
|
||||
var is4k = m.movieFile?.quality?.resolution >= 2160;
|
||||
var is4k = m.movieFile?.quality?.quality?.resolution >= 2160;
|
||||
|
||||
// Do we have a cached movie for this already?
|
||||
var existing = await existingMovies.FirstOrDefaultAsync(x => x.TheMovieDbId == m.tmdbId);
|
||||
|
|
|
@ -79,12 +79,14 @@
|
|||
|
||||
<!-- 4k Status -->
|
||||
<span *permission="roleName4k">
|
||||
<button mat-raised-button class="btn-green btn-spacing" id="availableBtn" *ngIf="movie.available4K && !movie.plexUrl && !movie.embyUrl && !movie.jellyfinUrl"> {{
|
||||
'Common.Available4K' | translate }}</button>
|
||||
<button mat-raised-button class="btn-green btn-spacing" id="availableBtn4k" *ngIf="movie.available4K"> {{
|
||||
'Common.Available4K' | translate }}
|
||||
</button>
|
||||
|
||||
<span *ngIf="!movie.available4K">
|
||||
<span *ngIf="movie.has4KRequest || movie.approved4K; then requestedBtn4K else notRequestedBtn4K"></span>
|
||||
<ng-template #requestedBtn4K>
|
||||
<button id="requestedBtn4K" mat-raised-button *ngIf="!hasRequest || hasRequest && movieRequest && !movieRequest.denied4K" class="btn-spacing" color="warn" [disabled]>
|
||||
<button id="requestedBtn4K" mat-raised-button *ngIf="movieRequest && !movieRequest.denied4K" class="btn-spacing" color="warn" [disabled]>
|
||||
<i class="fas fa-check"></i>
|
||||
{{ 'Common.Requested4K' | translate }}
|
||||
</button>
|
||||
|
|
|
@ -64,6 +64,11 @@
|
|||
<div>{{movie.quality | quality}}</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="movie.available4K">
|
||||
<span class="label">{{'MediaDetails.Quality' | translate }} </span>
|
||||
<span >{{"4K" | quality}}</span>
|
||||
</div>
|
||||
|
||||
<div *ngIf="advancedOptions && request && request.rootPathOverrideTitle">
|
||||
<span class="label">{{'MediaDetails.RootFolderOverride' | translate }}</span>
|
||||
<div>{{request.rootPathOverrideTitle}}</div>
|
||||
|
|
|
@ -6,6 +6,9 @@ export class QualityPipe implements PipeTransform {
|
|||
if (value.toUpperCase() === "4K" || value.toUpperCase() === "8K") {
|
||||
return value;
|
||||
}
|
||||
if (value[value.length - 1].toUpperCase() === "P") {
|
||||
return value;
|
||||
}
|
||||
return value + "p";
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ export class RoleDirective implements OnInit {
|
|||
}
|
||||
|
||||
private updateView(): void {
|
||||
if (this.auth.hasRole(this.roleName)) {
|
||||
if (this.auth.hasRole(this.roleName) || this.auth.hasRole("admin")) {
|
||||
if (this.isHidden) {
|
||||
this.viewContainer.createEmbeddedView(this.templateRef);
|
||||
this.isHidden = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue