mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-26 22:46:37 -04:00
New: Readarr 0.1
This commit is contained in:
@@ -5,7 +5,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
{
|
||||
public class AlbumSearchCommand : Command
|
||||
{
|
||||
public List<int> AlbumIds { get; set; }
|
||||
public List<int> BookIds { get; set; }
|
||||
|
||||
public override bool SendUpdatesToClient => true;
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
{
|
||||
}
|
||||
|
||||
public AlbumSearchCommand(List<int> albumIds)
|
||||
public AlbumSearchCommand(List<int> bookIds)
|
||||
{
|
||||
AlbumIds = albumIds;
|
||||
BookIds = bookIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private void SearchForMissingAlbums(List<Album> albums, bool userInvokedSearch)
|
||||
private void SearchForMissingAlbums(List<Book> albums, bool userInvokedSearch)
|
||||
{
|
||||
_logger.ProgressInfo("Performing missing search for {0} albums", albums.Count);
|
||||
var downloadedCount = 0;
|
||||
@@ -58,10 +58,10 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
|
||||
public void Execute(AlbumSearchCommand message)
|
||||
{
|
||||
foreach (var albumId in message.AlbumIds)
|
||||
foreach (var bookId in message.BookIds)
|
||||
{
|
||||
var decisions =
|
||||
_nzbSearchService.AlbumSearch(albumId, false, message.Trigger == CommandTrigger.Manual, false);
|
||||
_nzbSearchService.AlbumSearch(bookId, false, message.Trigger == CommandTrigger.Manual, false);
|
||||
var processed = _processDownloadDecisions.ProcessDecisions(decisions);
|
||||
|
||||
_logger.ProgressInfo("Album search completed. {0} reports downloaded.", processed.Grabbed.Count);
|
||||
@@ -70,13 +70,13 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
|
||||
public void Execute(MissingAlbumSearchCommand message)
|
||||
{
|
||||
List<Album> albums;
|
||||
List<Book> albums;
|
||||
|
||||
if (message.ArtistId.HasValue)
|
||||
if (message.AuthorId.HasValue)
|
||||
{
|
||||
int artistId = message.ArtistId.Value;
|
||||
int authorId = message.AuthorId.Value;
|
||||
|
||||
var pagingSpec = new PagingSpec<Album>
|
||||
var pagingSpec = new PagingSpec<Book>
|
||||
{
|
||||
Page = 1,
|
||||
PageSize = 100000,
|
||||
@@ -84,13 +84,13 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
SortKey = "Id"
|
||||
};
|
||||
|
||||
pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Artist.Value.Monitored == true);
|
||||
pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Author.Value.Monitored == true);
|
||||
|
||||
albums = _albumService.AlbumsWithoutFiles(pagingSpec).Records.Where(e => e.ArtistId.Equals(artistId)).ToList();
|
||||
albums = _albumService.AlbumsWithoutFiles(pagingSpec).Records.Where(e => e.AuthorId.Equals(authorId)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var pagingSpec = new PagingSpec<Album>
|
||||
var pagingSpec = new PagingSpec<Book>
|
||||
{
|
||||
Page = 1,
|
||||
PageSize = 100000,
|
||||
@@ -98,7 +98,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
SortKey = "Id"
|
||||
};
|
||||
|
||||
pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Artist.Value.Monitored == true);
|
||||
pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Author.Value.Monitored == true);
|
||||
|
||||
albums = _albumService.AlbumsWithoutFiles(pagingSpec).Records.ToList();
|
||||
}
|
||||
@@ -111,13 +111,13 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
|
||||
public void Execute(CutoffUnmetAlbumSearchCommand message)
|
||||
{
|
||||
Expression<Func<Album, bool>> filterExpression;
|
||||
Expression<Func<Book, bool>> filterExpression;
|
||||
|
||||
filterExpression = v =>
|
||||
v.Monitored == true &&
|
||||
v.Artist.Value.Monitored == true;
|
||||
v.Author.Value.Monitored == true;
|
||||
|
||||
var pagingSpec = new PagingSpec<Album>
|
||||
var pagingSpec = new PagingSpec<Book>
|
||||
{
|
||||
Page = 1,
|
||||
PageSize = 100000,
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
{
|
||||
public class ArtistSearchCommand : Command
|
||||
{
|
||||
public int ArtistId { get; set; }
|
||||
public int AuthorId { get; set; }
|
||||
|
||||
public override bool SendUpdatesToClient => true;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
|
||||
public void Execute(ArtistSearchCommand message)
|
||||
{
|
||||
var decisions = _nzbSearchService.ArtistSearch(message.ArtistId, false, message.Trigger == CommandTrigger.Manual, false);
|
||||
var decisions = _nzbSearchService.ArtistSearch(message.AuthorId, false, message.Trigger == CommandTrigger.Manual, false);
|
||||
var processed = _processDownloadDecisions.ProcessDecisions(decisions);
|
||||
|
||||
_logger.ProgressInfo("Artist search completed. {0} reports downloaded.", processed.Grabbed.Count);
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
{
|
||||
public class CutoffUnmetAlbumSearchCommand : Command
|
||||
{
|
||||
public int? ArtistId { get; set; }
|
||||
public int? AuthorId { get; set; }
|
||||
|
||||
public override bool SendUpdatesToClient => true;
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
{
|
||||
}
|
||||
|
||||
public CutoffUnmetAlbumSearchCommand(int artistId)
|
||||
public CutoffUnmetAlbumSearchCommand(int authorId)
|
||||
{
|
||||
ArtistId = artistId;
|
||||
AuthorId = authorId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
|
||||
{
|
||||
public abstract class SearchCriteriaBase
|
||||
{
|
||||
private static readonly Regex SpecialCharacter = new Regex(@"[`'’.]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
private static readonly Regex SpecialCharacter = new Regex(@"[`'’]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
private static readonly Regex NonWord = new Regex(@"[\W]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
private static readonly Regex BeginningThe = new Regex(@"^the\s", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
@@ -16,9 +16,8 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
|
||||
public virtual bool UserInvokedSearch { get; set; }
|
||||
public virtual bool InteractiveSearch { get; set; }
|
||||
|
||||
public Artist Artist { get; set; }
|
||||
public List<Album> Albums { get; set; }
|
||||
public List<Track> Tracks { get; set; }
|
||||
public Author Artist { get; set; }
|
||||
public List<Book> Albums { get; set; }
|
||||
|
||||
public string ArtistQuery => GetQueryTitle(Artist.Name);
|
||||
|
||||
@@ -35,6 +34,7 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
|
||||
var cleanTitle = BeginningThe.Replace(title, string.Empty);
|
||||
|
||||
cleanTitle = cleanTitle.Replace(" & ", " ");
|
||||
cleanTitle = cleanTitle.Replace(".", " ");
|
||||
cleanTitle = SpecialCharacter.Replace(cleanTitle, "");
|
||||
cleanTitle = NonWord.Replace(cleanTitle, "+");
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
{
|
||||
public class MissingAlbumSearchCommand : Command
|
||||
{
|
||||
public int? ArtistId { get; set; }
|
||||
public int? AuthorId { get; set; }
|
||||
|
||||
public override bool SendUpdatesToClient => true;
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
{
|
||||
}
|
||||
|
||||
public MissingAlbumSearchCommand(int artistId)
|
||||
public MissingAlbumSearchCommand(int authorId)
|
||||
{
|
||||
ArtistId = artistId;
|
||||
AuthorId = authorId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
{
|
||||
public interface ISearchForNzb
|
||||
{
|
||||
List<DownloadDecision> AlbumSearch(int albumId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch);
|
||||
List<DownloadDecision> ArtistSearch(int artistId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch);
|
||||
List<DownloadDecision> AlbumSearch(int bookId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch);
|
||||
List<DownloadDecision> ArtistSearch(int authorId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch);
|
||||
}
|
||||
|
||||
public class NzbSearchService : ISearchForNzb
|
||||
@@ -41,19 +41,19 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public List<DownloadDecision> AlbumSearch(int albumId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch)
|
||||
public List<DownloadDecision> AlbumSearch(int bookId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch)
|
||||
{
|
||||
var album = _albumService.GetAlbum(albumId);
|
||||
var album = _albumService.GetAlbum(bookId);
|
||||
return AlbumSearch(album, missingOnly, userInvokedSearch, interactiveSearch);
|
||||
}
|
||||
|
||||
public List<DownloadDecision> ArtistSearch(int artistId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch)
|
||||
public List<DownloadDecision> ArtistSearch(int authorId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch)
|
||||
{
|
||||
var artist = _artistService.GetArtist(artistId);
|
||||
var artist = _artistService.GetArtist(authorId);
|
||||
return ArtistSearch(artist, missingOnly, userInvokedSearch, interactiveSearch);
|
||||
}
|
||||
|
||||
public List<DownloadDecision> ArtistSearch(Artist artist, bool missingOnly, bool userInvokedSearch, bool interactiveSearch)
|
||||
public List<DownloadDecision> ArtistSearch(Author artist, bool missingOnly, bool userInvokedSearch, bool interactiveSearch)
|
||||
{
|
||||
var searchSpec = Get<ArtistSearchCriteria>(artist, userInvokedSearch, interactiveSearch);
|
||||
var albums = _albumService.GetAlbumsByArtist(artist.Id);
|
||||
@@ -65,11 +65,11 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec);
|
||||
}
|
||||
|
||||
public List<DownloadDecision> AlbumSearch(Album album, bool missingOnly, bool userInvokedSearch, bool interactiveSearch)
|
||||
public List<DownloadDecision> AlbumSearch(Book album, bool missingOnly, bool userInvokedSearch, bool interactiveSearch)
|
||||
{
|
||||
var artist = _artistService.GetArtist(album.ArtistId);
|
||||
var artist = _artistService.GetArtist(album.AuthorId);
|
||||
|
||||
var searchSpec = Get<AlbumSearchCriteria>(artist, new List<Album> { album }, userInvokedSearch, interactiveSearch);
|
||||
var searchSpec = Get<AlbumSearchCriteria>(artist, new List<Book> { album }, userInvokedSearch, interactiveSearch);
|
||||
|
||||
searchSpec.AlbumTitle = album.Title;
|
||||
if (album.ReleaseDate.HasValue)
|
||||
@@ -85,7 +85,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec);
|
||||
}
|
||||
|
||||
private TSpec Get<TSpec>(Artist artist, List<Album> albums, bool userInvokedSearch, bool interactiveSearch)
|
||||
private TSpec Get<TSpec>(Author artist, List<Book> albums, bool userInvokedSearch, bool interactiveSearch)
|
||||
where TSpec : SearchCriteriaBase, new()
|
||||
{
|
||||
var spec = new TSpec();
|
||||
@@ -98,7 +98,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
return spec;
|
||||
}
|
||||
|
||||
private static TSpec Get<TSpec>(Artist artist, bool userInvokedSearch, bool interactiveSearch)
|
||||
private static TSpec Get<TSpec>(Author artist, bool userInvokedSearch, bool interactiveSearch)
|
||||
where TSpec : SearchCriteriaBase, new()
|
||||
{
|
||||
var spec = new TSpec();
|
||||
|
||||
Reference in New Issue
Block a user