mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
Made some good process on getting the backend up and running for requesting albums etc
This commit is contained in:
parent
f921d84b0b
commit
4b7d7410ae
15 changed files with 114 additions and 42 deletions
|
@ -67,13 +67,16 @@ namespace Ombi.Core.Engine.V2
|
|||
|
||||
foreach (var g in artist.ReleaseGroups)
|
||||
{
|
||||
info.ReleaseGroups.Add(new ReleaseGroup
|
||||
var release = new ReleaseGroup
|
||||
{
|
||||
Type = g.PrimaryType,
|
||||
ReleaseType = g.PrimaryType,
|
||||
Id = g.Id,
|
||||
Title = g.Title,
|
||||
ReleaseDate = g.FirstReleaseDate,
|
||||
});
|
||||
};
|
||||
|
||||
await RunSearchRules(release);
|
||||
info.ReleaseGroups.Add(release);
|
||||
}
|
||||
|
||||
info.Links = GetLinksForArtist(artist);
|
||||
|
|
|
@ -28,7 +28,6 @@ namespace Ombi.Core.Models.Search
|
|||
[NotMapped]
|
||||
public string TheMovieDbId { get; set; }
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public bool Subscribed { get; set; }
|
||||
[NotMapped]
|
||||
|
|
|
@ -53,13 +53,4 @@ namespace Ombi.Core.Models.Search.V2.Music
|
|||
public string Google { get; set; }
|
||||
public string Apple { get; set; }
|
||||
}
|
||||
|
||||
public class ReleaseGroup
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string ReleaseDate { get; set; }
|
||||
public string Type { get; set; }
|
||||
|
||||
}
|
||||
}
|
17
src/Ombi.Core/Models/Search/V2/Music/ReleaseGroup.cs
Normal file
17
src/Ombi.Core/Models/Search/V2/Music/ReleaseGroup.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Core.Models.Search.V2.Music
|
||||
{
|
||||
public class ReleaseGroup : SearchViewModel
|
||||
{
|
||||
public new string Id { get; set; }
|
||||
public override RequestType Type => RequestType.Album;
|
||||
public string Title { get; set; }
|
||||
public string ReleaseDate { get; set; }
|
||||
public string ReleaseType { get; set; }
|
||||
public decimal PercentOfTracks { get; set; }
|
||||
public bool Monitored { get; set; }
|
||||
public bool PartiallyAvailable => PercentOfTracks != 100 && PercentOfTracks > 0;
|
||||
public bool FullyAvailable => PercentOfTracks == 100;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Core.Models.Search;
|
||||
using Ombi.Core.Models.Search.V2.Music;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
|
@ -89,7 +90,8 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
}
|
||||
if (obj.Type == RequestType.Album)
|
||||
{
|
||||
var album = (SearchAlbumViewModel) obj;
|
||||
if (obj is SearchAlbumViewModel album)
|
||||
{
|
||||
var albumRequest = await Music.GetRequestAsync(album.ForeignAlbumId);
|
||||
if (albumRequest != null) // Do we already have a request for this?
|
||||
{
|
||||
|
@ -100,6 +102,21 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
if (obj is ReleaseGroup release)
|
||||
{
|
||||
var albumRequest = await Music.GetRequestAsync(release.Id);
|
||||
if (albumRequest != null) // Do we already have a request for this?
|
||||
{
|
||||
obj.Requested = true;
|
||||
obj.RequestId = albumRequest.Id;
|
||||
obj.Approved = albumRequest.Approved;
|
||||
obj.Available = albumRequest.Available;
|
||||
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
|
||||
return Success();
|
||||
}
|
||||
return Success();
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Core.Models.Search;
|
||||
using Ombi.Core.Models.Search.V2.Music;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
|
||||
namespace Ombi.Core.Rule.Rules.Search
|
||||
{
|
||||
public class LidarrAlbumCacheRule : SpecificRule, ISpecificRule<object>
|
||||
public class LidarrAlbumCacheRule : BaseSearchRule, IRules<SearchViewModel>
|
||||
{
|
||||
public LidarrAlbumCacheRule(IExternalRepository<LidarrAlbumCache> db)
|
||||
{
|
||||
|
@ -17,20 +18,33 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
|
||||
private readonly IExternalRepository<LidarrAlbumCache> _db;
|
||||
|
||||
public Task<RuleResult> Execute(object objec)
|
||||
public Task<RuleResult> Execute(SearchViewModel objec)
|
||||
{
|
||||
if (objec is SearchAlbumViewModel obj)
|
||||
{
|
||||
var obj = (SearchAlbumViewModel) objec;
|
||||
// Check if it's in Lidarr
|
||||
var result = _db.GetAll().FirstOrDefault(x => x.ForeignAlbumId.Equals(obj.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
|
||||
var result = _db.GetAll().FirstOrDefault(x =>
|
||||
x.ForeignAlbumId.Equals(obj.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
|
||||
if (result != null)
|
||||
{
|
||||
obj.PercentOfTracks = result.PercentOfTracks;
|
||||
obj.Monitored = true; // It's in Lidarr so it's monitored
|
||||
}
|
||||
}
|
||||
|
||||
if (objec is ReleaseGroup release)
|
||||
{
|
||||
// Check if it's in Lidarr
|
||||
var result = _db.GetAll().FirstOrDefault(x =>
|
||||
x.ForeignAlbumId.Equals(release.Id, StringComparison.InvariantCultureIgnoreCase));
|
||||
if (result != null)
|
||||
{
|
||||
release.PercentOfTracks = result.PercentOfTracks;
|
||||
release.Monitored = true; // It's in Lidarr so it's monitored
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult(Success());
|
||||
}
|
||||
|
||||
public override SpecificRules Rule => SpecificRules.LidarrAlbum;
|
||||
}
|
||||
}
|
|
@ -23,7 +23,16 @@ export interface IReleaseGroups {
|
|||
id: string;
|
||||
title: string;
|
||||
releaseDate: string;
|
||||
type: string;
|
||||
releaseType: string;
|
||||
approved: boolean;
|
||||
requested: boolean;
|
||||
requestId: number;
|
||||
available: boolean;
|
||||
subscribed: boolean;
|
||||
showSubscribe: boolean;
|
||||
monitored: boolean;
|
||||
partiallyAvailable: boolean;
|
||||
fullyAvailable: boolean;
|
||||
|
||||
image: string; // Set by another api call
|
||||
}
|
||||
|
|
|
@ -28,6 +28,11 @@
|
|||
|
||||
<div class="col-12 col-lg-6 col-xl-6 media-row">
|
||||
|
||||
<button mat-raised-button class="btn-spacing" color="primary" (click)="requestAllAlbums()">
|
||||
<i
|
||||
class="fa fa-plus"></i> {{
|
||||
'MediaDetails.RequestAllAlbums' | translate }}</button>
|
||||
|
||||
<!-- <button mat-raised-button class="btn-green btn-spacing" *ngIf="movie.available"> {{
|
||||
'Common.Available' | translate }}</button> -->
|
||||
<!-- <span *ngIf="!movie.available">
|
||||
|
|
|
@ -55,7 +55,7 @@ export class ArtistDetailsComponent {
|
|||
return this.artist.background
|
||||
}
|
||||
|
||||
public async request() {
|
||||
public async requestAllAlbums() {
|
||||
// const result = await this.requestService.requestMovie({ theMovieDbId: this.theMovidDbId, languageCode: null }).toPromise();
|
||||
// if (result.result) {
|
||||
// this.movie.requested = true;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<span *ngFor="let r of albums">
|
||||
<div class="col-md-2" >
|
||||
<div class="sidebar affixable affix-top preview-poster">
|
||||
<div class="poster">
|
||||
<div class="poster" [class.monitored]="r.monitored" [class.available]="r.available">
|
||||
<img class="real grow" matTooltip="{{r.title}}"
|
||||
src="{{r.image ? r.image : 'images/default-music-placeholder.png'}}" alt="Poster"
|
||||
style="display: block;">
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
@import 'Styles/buttons.scss';
|
||||
|
||||
// border: solid 3px #fff;
|
||||
.monitored {
|
||||
border: solid 3px $orange !important;
|
||||
}
|
||||
.available {
|
||||
border: solid 3px $green !important;
|
||||
}
|
|
@ -5,7 +5,7 @@ import { ActivatedRoute } from "@angular/router";
|
|||
|
||||
@Component({
|
||||
templateUrl: "./artist-release-panel.component.html",
|
||||
styleUrls: ["../../../../media-details.component.scss"],
|
||||
styleUrls: ["../../../../media-details.component.scss", "./artist-release-panel.component.scss"],
|
||||
selector: "artist-release-panel",
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
|
@ -27,7 +27,7 @@ export class ArtistReleasePanel implements OnChanges {
|
|||
|
||||
private loadAlbums(): void {
|
||||
if (this.releases) {
|
||||
this.albums = this.releases.filter(x => x.type === "Album");
|
||||
this.albums = this.releases.filter(x => x.releaseType === "Album");
|
||||
this.albums = this.albums.sort((a: IReleaseGroups, b: IReleaseGroups) => {
|
||||
return this.getTime(new Date(b.releaseDate)) - this.getTime(new Date(a.releaseDate));
|
||||
});
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
}
|
||||
|
||||
#info-wrapper .sidebar .poster {
|
||||
border: solid 3px #fff !important;
|
||||
border: solid 3px #fff;
|
||||
position: relative;
|
||||
-webkit-box-shadow: 0 0 20px 0 #666;
|
||||
box-shadow: 0 0 20px 0 #666;
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
.btn-blue {
|
||||
background-color: #1976D2;
|
||||
|
||||
$blue: #1976D2;
|
||||
$pink: #C2185B;
|
||||
$green:#1DE9B6;
|
||||
$orange:#F57C00;
|
||||
|
||||
.btn-blue {
|
||||
background-color: $blue;
|
||||
}
|
||||
|
||||
.btn-pink {
|
||||
background-color: #C2185B;
|
||||
background-color: $pink;
|
||||
}
|
||||
|
||||
.btn-green {
|
||||
background-color: #1DE9B6;
|
||||
background-color: $green;
|
||||
}
|
||||
|
||||
.btn-orange {
|
||||
background-color: #F57C00;
|
||||
background-color: $orange;
|
||||
}
|
||||
|
|
|
@ -204,6 +204,7 @@
|
|||
"SimilarTitle": "Similar",
|
||||
"VideosTitle": "Videos",
|
||||
"AlbumsTitle":"Albums",
|
||||
"RequestAllAlbums":"Request All Albums",
|
||||
"Casts": {
|
||||
"CastTitle": "Cast",
|
||||
"Character": "Character",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue