mirror of
https://github.com/Readarr/Readarr
synced 2025-12-13 03:43:40 +01:00
Fixed: Adding book by edition id
This commit is contained in:
parent
4db158e0c9
commit
70856c217c
2 changed files with 12 additions and 8 deletions
|
|
@ -75,7 +75,7 @@ public void getting_details_of_invalid_author()
|
|||
[Test]
|
||||
public void getting_details_of_invalid_book()
|
||||
{
|
||||
Assert.Throws<BookNotFoundException>(() => Subject.GetBookInfo("99999999"));
|
||||
Assert.Throws<BookNotFoundException>(() => Subject.GetBookInfo("1"));
|
||||
}
|
||||
|
||||
private void ValidateAuthor(Author author)
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public Tuple<string, Book, List<AuthorMetadata>> GetBookInfo(string foreignBookI
|
|||
catch (BookInfoException e)
|
||||
{
|
||||
_logger.Warn(e, "Unexpected error getting book info");
|
||||
throw new AuthorNotFoundException(foreignBookId);
|
||||
throw new BookNotFoundException(foreignBookId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -398,9 +398,9 @@ private Book GetEditionInfo(int id, bool getAllEditions)
|
|||
}
|
||||
|
||||
var location = httpResponse.Headers.GetSingleValue("Location");
|
||||
var split = location.Split('/');
|
||||
var type = split[0];
|
||||
var newId = split[1];
|
||||
var split = location.Split('/').Reverse().ToList();
|
||||
var newId = split[0];
|
||||
var type = split[1];
|
||||
|
||||
Book book;
|
||||
List<AuthorMetadata> authors;
|
||||
|
|
@ -437,6 +437,10 @@ private Book GetEditionInfo(int id, bool getAllEditions)
|
|||
trimmed.AuthorMetadata = book.AuthorMetadata.Value;
|
||||
trimmed.SeriesLinks = book.SeriesLinks;
|
||||
var edition = book.Editions.Value.SingleOrDefault(e => e.ForeignEditionId == id.ToString());
|
||||
if (edition != null)
|
||||
{
|
||||
edition.Monitored = true;
|
||||
}
|
||||
|
||||
trimmed.Editions = new List<Edition> { edition };
|
||||
book = trimmed;
|
||||
|
|
@ -632,9 +636,9 @@ private Tuple<string, Book, List<AuthorMetadata>> PollBook(string foreignBookId)
|
|||
if (httpResponse.HasHttpRedirect)
|
||||
{
|
||||
var location = httpResponse.Headers.GetSingleValue("Location");
|
||||
var split = location.Split('/');
|
||||
var type = split[0];
|
||||
var newId = split[1];
|
||||
var split = location.Split('/').Reverse().ToList();
|
||||
var newId = split[0];
|
||||
var type = split[1];
|
||||
|
||||
if (type == "author")
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue