mirror of
https://github.com/Readarr/Readarr.git
synced 2026-01-31 01:02:20 -05:00
fixes to build errors
This commit is contained in:
@@ -82,5 +82,12 @@ public void SetContent(string data)
|
||||
var encoding = HttpHeader.GetEncodingFromContentType(Headers.ContentType);
|
||||
ContentData = encoding.GetBytes(data);
|
||||
}
|
||||
|
||||
public void AddBasicAuthentication(string username, string password)
|
||||
{
|
||||
var authInfo = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes($"{username}:{password}"));
|
||||
|
||||
Headers.Set("Authorization", "Basic " + authInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Books;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ public interface IAuthorRepository : IBasicRepository<Author>
|
||||
bool AuthorPathExists(string path);
|
||||
Author FindByName(string cleanName);
|
||||
Author FindById(string foreignAuthorId);
|
||||
Dictionary<int, string> AllAuthorPaths();
|
||||
Author GetAuthorByMetadataId(int authorMetadataId);
|
||||
List<Author> GetAuthorsByMetadataId(IEnumerable<int> authorMetadataId);
|
||||
}
|
||||
@@ -60,6 +61,15 @@ public Author GetAuthorByMetadataId(int authorMetadataId)
|
||||
return Query(s => s.AuthorMetadataId == authorMetadataId).SingleOrDefault();
|
||||
}
|
||||
|
||||
public Dictionary<int, string> AllAuthorPaths()
|
||||
{
|
||||
using (var conn = _database.OpenConnection())
|
||||
{
|
||||
var strSql = "SELECT Id AS [Key], Path AS [Value] FROM Authors";
|
||||
return conn.Query<KeyValuePair<int, string>>(strSql).ToDictionary(x => x.Key, x => x.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Author> GetAuthorsByMetadataId(IEnumerable<int> authorMetadataIds)
|
||||
{
|
||||
return Query(s => authorMetadataIds.Contains(s.AuthorMetadataId));
|
||||
|
||||
@@ -27,6 +27,7 @@ public interface IAuthorService
|
||||
List<Author> AllForTag(int tagId);
|
||||
Author UpdateAuthor(Author author);
|
||||
List<Author> UpdateAuthors(List<Author> authors, bool useExistingRelativeFolder);
|
||||
Dictionary<int, string> AllAuthorPaths();
|
||||
bool AuthorPathExists(string folder);
|
||||
void RemoveAddOptions(Author author);
|
||||
}
|
||||
@@ -131,6 +132,11 @@ public Author FindByNameInexact(string title)
|
||||
return null;
|
||||
}
|
||||
|
||||
public Dictionary<int, string> AllAuthorPaths()
|
||||
{
|
||||
return _authorRepository.AllAuthorPaths();
|
||||
}
|
||||
|
||||
public List<Author> GetCandidates(string title)
|
||||
{
|
||||
var authors = GetAllAuthors();
|
||||
|
||||
@@ -156,23 +156,23 @@ private IEnumerable<DownloadDecision> GetBookDecisions(List<ReleaseInfo> reports
|
||||
|
||||
if (searchCriteria != null)
|
||||
{
|
||||
if (parsedAlbumInfo == null)
|
||||
if (parsedBookInfo == null)
|
||||
{
|
||||
parsedAlbumInfo = new ParsedAlbumInfo
|
||||
parsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
Quality = QualityParser.ParseQuality(report.Title, null, 0)
|
||||
Quality = QualityParser.ParseQuality(report.Title, null)
|
||||
};
|
||||
}
|
||||
|
||||
if (parsedAlbumInfo.ArtistName.IsNullOrWhiteSpace())
|
||||
if (parsedBookInfo.AuthorName.IsNullOrWhiteSpace())
|
||||
{
|
||||
var remoteAlbum = new RemoteAlbum
|
||||
var remoteBook = new RemoteBook
|
||||
{
|
||||
Release = report,
|
||||
ParsedAlbumInfo = parsedAlbumInfo
|
||||
ParsedBookInfo = parsedBookInfo
|
||||
};
|
||||
|
||||
decision = new DownloadDecision(remoteAlbum, new Rejection("Unable to parse release"));
|
||||
decision = new DownloadDecision(remoteBook, new Rejection("Unable to parse release"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCrite
|
||||
_logger.Debug("Checking if release is higher quality than queued release. Queued: {0}", remoteBook.ParsedBookInfo.Quality);
|
||||
|
||||
if (!_upgradableSpecification.IsUpgradable(qualityProfile,
|
||||
new List<QualityModel> { remoteBook.ParsedBookInfo.Quality },
|
||||
remoteBook.ParsedBookInfo.Quality,
|
||||
queuedItemPreferredWordScore,
|
||||
subject.ParsedBookInfo.Quality,
|
||||
subject.PreferredWordScore))
|
||||
@@ -79,7 +79,7 @@ public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCrite
|
||||
_logger.Debug("Checking if profiles allow upgrading. Queued: {0}", remoteBook.ParsedBookInfo.Quality);
|
||||
|
||||
if (!_upgradableSpecification.IsUpgradeAllowed(qualityProfile,
|
||||
new List<QualityModel> { remoteBook.ParsedBookInfo.Quality },
|
||||
remoteBook.ParsedBookInfo.Quality,
|
||||
subject.ParsedBookInfo.Quality))
|
||||
{
|
||||
return Decision.Reject("Another release is queued and the Quality profile does not allow upgrades");
|
||||
|
||||
@@ -73,7 +73,7 @@ public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase sea
|
||||
|
||||
var upgradeable = _upgradableSpecification.IsUpgradable(
|
||||
subject.Author.QualityProfile,
|
||||
new List<QualityModel> { mostRecent.Quality },
|
||||
mostRecent.Quality,
|
||||
preferredWordScore,
|
||||
subject.ParsedBookInfo.Quality,
|
||||
subject.PreferredWordScore);
|
||||
|
||||
@@ -35,13 +35,10 @@ public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase sea
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get a distinct list of all current track qualities for a given book
|
||||
var currentQualities = new List<QualityModel> { file.Quality };
|
||||
|
||||
_logger.Debug("Comparing file quality with report. Existing files contain {0}", currentQualities.ConcatToString());
|
||||
_logger.Debug("Comparing file quality with report. Existing files contain {0}", file.Quality);
|
||||
|
||||
if (!_upgradableSpecification.IsUpgradeAllowed(qualityProfile,
|
||||
currentQualities,
|
||||
file.Quality,
|
||||
subject.ParsedBookInfo.Quality))
|
||||
{
|
||||
_logger.Debug("Upgrading is not allowed by the quality profile");
|
||||
|
||||
@@ -14,7 +14,7 @@ public AggregatePreferredWordScore(IPreferredWordService preferredWordServiceCal
|
||||
|
||||
public RemoteBook Aggregate(RemoteBook remoteBook)
|
||||
{
|
||||
remoteBook.PreferredWordScore = _preferredWordServiceCalculator.Calculate(remoteAlbum.Author, remoteBook.Release.Title, remoteBook.Release.IndexerId);
|
||||
remoteBook.PreferredWordScore = _preferredWordServiceCalculator.Calculate(remoteBook.Author, remoteBook.Release.Title, remoteBook.Release.IndexerId);
|
||||
|
||||
return remoteBook;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public void DownloadReport(RemoteBook remoteBook)
|
||||
}
|
||||
catch (DownloadClientRejectedReleaseException)
|
||||
{
|
||||
_logger.Trace("Release {0} rejected by download client, possible duplicate.", remoteAlbum);
|
||||
_logger.Trace("Release {0} rejected by download client, possible duplicate.", remoteBook);
|
||||
throw;
|
||||
}
|
||||
catch (ReleaseDownloadException ex)
|
||||
|
||||
@@ -41,7 +41,7 @@ public void Handle(AuthorScannedEvent message)
|
||||
_logger.Debug("Looking for existing extra files in {0}", author.Path);
|
||||
|
||||
var filesOnDisk = _diskScanService.GetNonBookFiles(author.Path);
|
||||
var possibleExtraFiles = _diskScanService.FilterFiles(author.Path, filesOnDisk);
|
||||
var possibleExtraFiles = _diskScanService.FilterPaths(author.Path, filesOnDisk);
|
||||
|
||||
var filteredFiles = possibleExtraFiles;
|
||||
var importedFiles = new List<string>();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Books;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
@@ -38,10 +38,10 @@ public void Clean()
|
||||
return;
|
||||
}
|
||||
|
||||
var artists = _authorService.GetAllAuthors();
|
||||
var authors = _authorService.AllAuthorPaths();
|
||||
var imageExtensions = new List<string> { ".jpg", ".png", ".gif" };
|
||||
|
||||
foreach (var author in artists)
|
||||
foreach (var author in authors)
|
||||
{
|
||||
var images = _metaFileService.GetFilesByAuthor(author.Key)
|
||||
.Where(c => c.LastUpdated > new DateTime(2014, 12, 27) && imageExtensions.Any(x => c.RelativePath.EndsWith(x, StringComparison.InvariantCultureIgnoreCase)));
|
||||
|
||||
@@ -19,20 +19,20 @@ public virtual IndexerPageableRequestChain GetRecentRequests()
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
public IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria)
|
||||
public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria)
|
||||
{
|
||||
var pageableRequests = new IndexerPageableRequestChain();
|
||||
|
||||
pageableRequests.Add(GetRequest("search-torrents", Settings.Categories, string.Format(" & type=name&query={0}+{1}", Uri.EscapeDataString(searchCriteria.ArtistQuery.Trim()), Uri.EscapeDataString(searchCriteria.AlbumQuery.Trim()))));
|
||||
pageableRequests.Add(GetRequest("search-torrents", Settings.Categories, string.Format(" & type=name&query={0}+{1}", Uri.EscapeDataString(searchCriteria.AuthorQuery.Trim()), Uri.EscapeDataString(searchCriteria.BookQuery.Trim()))));
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
public IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria)
|
||||
public IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria)
|
||||
{
|
||||
var pageableRequests = new IndexerPageableRequestChain();
|
||||
|
||||
pageableRequests.Add(GetRequest("search-torrents", Settings.Categories, string.Format(" & type=name&query={0}", Uri.EscapeDataString(searchCriteria.ArtistQuery.Trim()))));
|
||||
pageableRequests.Add(GetRequest("search-torrents", Settings.Categories, string.Format(" & type=name&query={0}", Uri.EscapeDataString(searchCriteria.AuthorQuery.Trim()))));
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
@@ -43,10 +43,7 @@ private IEnumerable<IndexerRequest> GetRequest(string searchType, IEnumerable<in
|
||||
|
||||
var baseUrl = string.Format("{0}/api.php?action={1}&category={2}{3}", Settings.BaseUrl.TrimEnd('/'), searchType, categoriesQuery, parameters);
|
||||
|
||||
var request = new IndexerRequest(baseUrl, HttpAccept.Json);
|
||||
request.HttpRequest.AddBasicAuthentication(Settings.Username.Trim(), Settings.Passkey.Trim());
|
||||
|
||||
yield return request;
|
||||
yield return new IndexerRequest(baseUrl, HttpAccept.Json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Books;
|
||||
using NzbDrone.Core.Books.Calibre;
|
||||
using NzbDrone.Core.MediaFiles.BookImport;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles.BookImport;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
|
||||
@@ -104,11 +104,11 @@ public void HandleAsync(AuthorDeletedEvent message)
|
||||
if (message.DeleteFiles)
|
||||
{
|
||||
var author = message.Author;
|
||||
var allArtists = _artistService.GetAllAuthors();
|
||||
var allArtists = _authorService.AllAuthorPaths();
|
||||
|
||||
foreach (var s in allArtists)
|
||||
{
|
||||
if (s.Key == artist.Id)
|
||||
if (s.Key == author.Id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ public Prowl(IProwlProxy prowlProxy)
|
||||
|
||||
public override void OnGrab(GrabMessage message)
|
||||
{
|
||||
_prowlProxy.SendNotification(ALBUM_GRABBED_TITLE, message.Message, Settings.ApiKey);
|
||||
_prowlProxy.SendNotification(BOOK_GRABBED_TITLE, message.Message, Settings.ApiKey);
|
||||
}
|
||||
|
||||
public override void OnReleaseImport(AlbumDownloadMessage message)
|
||||
public override void OnReleaseImport(BookDownloadMessage message)
|
||||
{
|
||||
_prowlProxy.SendNotification(ALBUM_DOWNLOADED_TITLE, message.Message, Settings.ApiKey);
|
||||
_prowlProxy.SendNotification(BOOK_DOWNLOADED_TITLE, message.Message, Settings.ApiKey);
|
||||
}
|
||||
|
||||
public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
||||
|
||||
@@ -21,12 +21,12 @@ public SendGrid(ISendGridProxy proxy, Logger logger)
|
||||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
_proxy.SendNotification(BOOK_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnReleaseImport(AlbumDownloadMessage message)
|
||||
public override void OnReleaseImport(BookDownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(ALBUM_DOWNLOADED_TITLE, message.Message, Settings);
|
||||
_proxy.SendNotification(BOOK_DOWNLOADED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
||||
@@ -39,7 +39,7 @@ public override void OnDownloadFailure(DownloadFailedMessage message)
|
||||
_proxy.SendNotification(DOWNLOAD_FAILURE_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnImportFailure(AlbumDownloadMessage message)
|
||||
public override void OnImportFailure(BookDownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(IMPORT_FAILURE_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ public override void OnGrab(GrabMessage message)
|
||||
var payload = new WebhookGrabPayload
|
||||
{
|
||||
EventType = WebhookEventType.Grab,
|
||||
Artist = new WebhookAuthor(message.Author),
|
||||
Albums = remoteBook.Books.ConvertAll(x => new WebhookBook(x)
|
||||
Author = new WebhookAuthor(message.Author),
|
||||
Books = remoteBook.Books.ConvertAll(x => new WebhookBook(x)
|
||||
{
|
||||
// TODO: Stop passing these parameters inside an album v3
|
||||
Quality = quality.Quality.Name,
|
||||
@@ -49,7 +49,7 @@ public override void OnReleaseImport(BookDownloadMessage message)
|
||||
var payload = new WebhookImportPayload
|
||||
{
|
||||
EventType = WebhookEventType.Download,
|
||||
Artist = new WebhookAuthor(message.Author),
|
||||
Author = new WebhookAuthor(message.Author),
|
||||
Book = new WebhookBook(message.Book),
|
||||
BookFiles = bookFiles.ConvertAll(x => new WebhookBookFile(x)),
|
||||
IsUpgrade = message.OldFiles.Any(),
|
||||
@@ -65,7 +65,7 @@ public override void OnRename(Author author)
|
||||
var payload = new WebhookRenamePayload
|
||||
{
|
||||
EventType = WebhookEventType.Rename,
|
||||
Artist = new WebhookAuthor(author)
|
||||
Author = new WebhookAuthor(author)
|
||||
};
|
||||
|
||||
_proxy.SendWebhook(payload, Settings);
|
||||
@@ -76,7 +76,7 @@ public override void OnBookRetag(BookRetagMessage message)
|
||||
var payload = new WebhookRetagPayload
|
||||
{
|
||||
EventType = WebhookEventType.Retag,
|
||||
Artist = new WebhookAuthor(message.Author)
|
||||
Author = new WebhookAuthor(message.Author)
|
||||
};
|
||||
|
||||
_proxy.SendWebhook(payload, Settings);
|
||||
@@ -114,7 +114,7 @@ private ValidationFailure SendWebhookTest()
|
||||
var payload = new WebhookGrabPayload
|
||||
{
|
||||
EventType = WebhookEventType.Test,
|
||||
Artist = new WebhookAuthor()
|
||||
Author = new WebhookAuthor()
|
||||
{
|
||||
Id = 1,
|
||||
Name = "Test Name",
|
||||
|
||||
@@ -2,6 +2,6 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookRenamePayload : WebhookPayload
|
||||
{
|
||||
public WebhookArtist Artist { get; set; }
|
||||
public WebhookAuthor Author { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookRetagPayload : WebhookPayload
|
||||
{
|
||||
public WebhookArtist Artist { get; set; }
|
||||
public WebhookAuthor Author { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ public PreferredWordService(IReleaseProfileService releaseProfileService, ITermM
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public int Calculate(Author series, string title, int indexerId)
|
||||
public int Calculate(Author author, string title, int indexerId)
|
||||
{
|
||||
_logger.Trace("Calculating preferred word score for '{0}'", title);
|
||||
|
||||
var releaseProfiles = _releaseProfileService.EnabledForTags(artist.Tags, indexerId);
|
||||
var releaseProfiles = _releaseProfileService.EnabledForTags(author.Tags, indexerId);
|
||||
var matchingPairs = new List<KeyValuePair<string, int>>();
|
||||
|
||||
foreach (var releaseProfile in releaseProfiles)
|
||||
|
||||
@@ -22,7 +22,7 @@ protected override bool IsValid(PropertyValidatorContext context)
|
||||
return true;
|
||||
}
|
||||
|
||||
return !_artistService.GetAllAuthors().Any(s => context.PropertyValue.ToString().IsParentPath(s.Value));
|
||||
return !_authorService.GetAllAuthors().Any(s => context.PropertyValue.ToString().IsParentPath(s.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ protected override bool IsValid(PropertyValidatorContext context)
|
||||
dynamic instance = context.ParentContext.InstanceToValidate;
|
||||
var instanceId = (int)instance.Id;
|
||||
|
||||
return !_authorService.GetAllAuthors().Any(s => s.Value.PathEquals(context.PropertyValue.ToString()) && s.Key != instanceId);
|
||||
return !_authorService.AllAuthorPaths().Any(s => s.Value.PathEquals(context.PropertyValue.ToString()) && s.Key != instanceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user