mirror of
https://github.com/Radarr/Radarr
synced 2025-01-04 06:23:32 +00:00
Fixed: Alt Titles on Main Load, Alt Titles API updates
This commit is contained in:
parent
ac59b7060e
commit
d86c811543
6 changed files with 41 additions and 25 deletions
|
@ -50,7 +50,7 @@ public BasicRepository(IDatabase database, IEventAggregator eventAggregator)
|
|||
_eventAggregator = eventAggregator;
|
||||
}
|
||||
|
||||
protected QueryBuilder<TModel> Query => DataMapper.Query<TModel>();
|
||||
protected QueryBuilder<TModel> Query => AddJoinQueries(DataMapper.Query<TModel>());
|
||||
|
||||
protected void Delete(Expression<Func<TModel, bool>> filter)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ protected void Delete(Expression<Func<TModel, bool>> filter)
|
|||
|
||||
public IEnumerable<TModel> All()
|
||||
{
|
||||
return DataMapper.Query<TModel>().ToList();
|
||||
return AddJoinQueries(DataMapper.Query<TModel>()).ToList();
|
||||
}
|
||||
|
||||
public int Count()
|
||||
|
@ -296,6 +296,11 @@ private void PublishModelEvent(TModel model, ModelAction action)
|
|||
}
|
||||
}
|
||||
|
||||
protected virtual QueryBuilder<TActual> AddJoinQueries<TActual>(QueryBuilder<TActual> baseQuery)
|
||||
{
|
||||
return baseQuery;
|
||||
}
|
||||
|
||||
protected virtual bool PublishModelEvents => false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ public interface IAlternativeTitleService
|
|||
AlternativeTitle AddAltTitle(AlternativeTitle title, Movie movie);
|
||||
List<AlternativeTitle> AddAltTitles(List<AlternativeTitle> titles, Movie movie);
|
||||
AlternativeTitle GetById(int id);
|
||||
List<AlternativeTitle> GetAllTitles();
|
||||
void DeleteNotEnoughVotes(List<AlternativeTitle> mappingsTitles);
|
||||
}
|
||||
|
||||
|
@ -58,6 +59,11 @@ public AlternativeTitle GetById(int id)
|
|||
return _titleRepo.Get(id);
|
||||
}
|
||||
|
||||
public List<AlternativeTitle> GetAllTitles()
|
||||
{
|
||||
return _titleRepo.All().ToList();
|
||||
}
|
||||
|
||||
public void RemoveTitle(AlternativeTitle title)
|
||||
{
|
||||
_titleRepo.Delete(title);
|
||||
|
|
|
@ -270,5 +270,14 @@ public Movie FindByTmdbId(int tmdbid)
|
|||
{
|
||||
return Query.Where(m => m.TmdbId == tmdbid).FirstOrDefault();
|
||||
}
|
||||
|
||||
protected override QueryBuilder<TActual> AddJoinQueries<TActual>(QueryBuilder<TActual> baseQuery)
|
||||
{
|
||||
baseQuery = base.AddJoinQueries(baseQuery);
|
||||
baseQuery = baseQuery.Join<Movie, AlternativeTitle>(JoinType.Left, m => m.AlternativeTitles,
|
||||
(m, t) => m.Id == t.MovieId);
|
||||
|
||||
return baseQuery;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -450,16 +450,12 @@ public string Message
|
|||
{
|
||||
case MappingResultType.Success:
|
||||
return $"Successfully mapped release name {ReleaseName} to movie {Movie}";
|
||||
break;
|
||||
case MappingResultType.SuccessLenientMapping:
|
||||
return $"Successfully mapped parts of the release name {ReleaseName} to movie {Movie}";
|
||||
break;
|
||||
case MappingResultType.NotParsable:
|
||||
return $"Failed to find movie title in release name {ReleaseName}";
|
||||
break;
|
||||
case MappingResultType.TitleNotFound:
|
||||
return $"Could not find {RemoteMovie.ParsedMovieInfo.MovieTitle}";
|
||||
break;
|
||||
case MappingResultType.WrongYear:
|
||||
return $"Failed to map movie, expected year {RemoteMovie.Movie.Year}, but found {RemoteMovie.ParsedMovieInfo.Year}";
|
||||
case MappingResultType.WrongTitle:
|
||||
|
|
|
@ -1,19 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Marr.Data;
|
||||
using Nancy;
|
||||
using Radarr.Api.V2;
|
||||
using NzbDrone.Common.Cache;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.MovieImport;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.MetadataSource.RadarrAPI;
|
||||
using NzbDrone.Core.Movies.AlternativeTitles;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.Events;
|
||||
using Radarr.Http;
|
||||
|
@ -33,9 +22,11 @@ public AlternativeTitleModule(IAlternativeTitleService altTitleService, IMovieSe
|
|||
_altTitleService = altTitleService;
|
||||
_movieService = movieService;
|
||||
_radarrApi = radarrApi;
|
||||
CreateResource = AddTitle;
|
||||
GetResourceById = GetTitle;
|
||||
_eventAggregator = eventAggregator;
|
||||
|
||||
CreateResource = AddTitle;
|
||||
GetResourceById = GetAltTitle;
|
||||
GetResourceAll = GetAltTitles;
|
||||
}
|
||||
|
||||
private int AddTitle(AlternativeTitleResource altTitle)
|
||||
|
@ -49,9 +40,23 @@ private int AddTitle(AlternativeTitleResource altTitle)
|
|||
return addedTitle.Id;
|
||||
}
|
||||
|
||||
private AlternativeTitleResource GetTitle(int id)
|
||||
private AlternativeTitleResource GetAltTitle(int id)
|
||||
{
|
||||
return _altTitleService.GetById(id).ToResource();
|
||||
}
|
||||
|
||||
private List<AlternativeTitleResource> GetAltTitles()
|
||||
{
|
||||
var movieIdQuery = Request.Query.MovieId;
|
||||
|
||||
if (movieIdQuery.HasValue)
|
||||
{
|
||||
int movieId = Convert.ToInt32(movieIdQuery.Value);
|
||||
|
||||
return _altTitleService.GetAllTitlesForMovie(movieId).ToResource();
|
||||
}
|
||||
|
||||
return _altTitleService.GetAllTitles().ToResource();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Radarr.Http.REST;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Movies.AlternativeTitles;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Languages;
|
||||
|
||||
namespace Radarr.Api.V2.Movies
|
||||
|
|
Loading…
Reference in a new issue