Tachiyomi Enhancements (#845)

* Added a new endpoint to get all Series with Progress info.

* Fixed up some potential NPEs during scan

* Commented out filter code, not ready for it.

* Fixed up a parsing case for european comics

* Refactored FilterDto to allow for specifying multiple formats to return.

* Refactored FilterDto to allow for specifying multiple formats to return.

* Refactored the UI to show OPDS as 3rd Party Clients since Tachiyomi now uses OPDS url scheme for authentication.
This commit is contained in:
Joseph Milazzo 2021-12-10 15:04:52 -06:00 committed by GitHub
parent 658ca290e1
commit 384ebcef5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 120 additions and 99 deletions

View file

@ -11,20 +11,20 @@ namespace API.Data.Metadata
/// <remarks>See reference of the loose spec here: https://github.com/Kussie/ComicInfoStandard/blob/main/ComicInfo.xsd</remarks>
public class ComicInfo
{
public string Summary { get; set; }
public string Title { get; set; }
public string Series { get; set; }
public string Number { get; set; }
public string Volume { get; set; }
public string Notes { get; set; }
public string Genre { get; set; }
public string Summary { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string Series { get; set; } = string.Empty;
public string Number { get; set; } = string.Empty;
public string Volume { get; set; } = string.Empty;
public string Notes { get; set; } = string.Empty;
public string Genre { get; set; } = string.Empty;
public int PageCount { get; set; }
// ReSharper disable once InconsistentNaming
public string LanguageISO { get; set; }
public string LanguageISO { get; set; } = string.Empty;
/// <summary>
/// This is the link to where the data was scraped from
/// </summary>
public string Web { get; set; }
public string Web { get; set; } = string.Empty;
public int Day { get; set; }
public int Month { get; set; }
public int Year { get; set; }
@ -33,29 +33,23 @@ namespace API.Data.Metadata
/// <summary>
/// Rating based on the content. Think PG-13, R for movies. See <see cref="AgeRating"/> for valid types
/// </summary>
public string AgeRating { get; set; }
// public AgeRating AgeRating
// {
// get => ConvertAgeRatingToEnum(_AgeRating);
// set => ConvertAgeRatingToEnum(value);
// }
public string AgeRating { get; set; } = string.Empty;
/// <summary>
/// User's rating of the content
/// </summary>
public float UserRating { get; set; }
public string AlternateSeries { get; set; }
public string StoryArc { get; set; }
public string SeriesGroup { get; set; }
public string AlternativeSeries { get; set; }
public string AlternativeNumber { get; set; }
public string AlternateSeries { get; set; } = string.Empty;
public string StoryArc { get; set; } = string.Empty;
public string SeriesGroup { get; set; } = string.Empty;
public string AlternativeSeries { get; set; } = string.Empty;
public string AlternativeNumber { get; set; } = string.Empty;
/// <summary>
/// This is Epub only: calibre:title_sort
/// Represents the sort order for the title
/// </summary>
public string TitleSort { get; set; }
public string TitleSort { get; set; } = string.Empty;
@ -63,14 +57,14 @@ namespace API.Data.Metadata
/// <summary>
/// This is the Author. For Books, we map creator tag in OPF to this field. Comma separated if multiple.
/// </summary>
public string Writer { get; set; }
public string Penciller { get; set; }
public string Inker { get; set; }
public string Colorist { get; set; }
public string Letterer { get; set; }
public string CoverArtist { get; set; }
public string Editor { get; set; }
public string Publisher { get; set; }
public string Writer { get; set; } = string.Empty;
public string Penciller { get; set; } = string.Empty;
public string Inker { get; set; } = string.Empty;
public string Colorist { get; set; } = string.Empty;
public string Letterer { get; set; } = string.Empty;
public string CoverArtist { get; set; } = string.Empty;
public string Editor { get; set; } = string.Empty;
public string Publisher { get; set; } = string.Empty;
public static AgeRating ConvertAgeRatingToEnum(string value)
{

View file

@ -178,8 +178,11 @@ public class SeriesRepository : ISeriesRepository
public async Task<PagedList<SeriesDto>> GetSeriesDtoForLibraryIdAsync(int libraryId, int userId, UserParams userParams, FilterDto filter)
{
var formats = filter.GetSqlFilter();
var userLibraries = await GetUserLibraries(libraryId, userId);
var query = _context.Series
.Where(s => s.LibraryId == libraryId && formats.Contains(s.Format))
.Where(s => userLibraries.Contains(s.LibraryId) && formats.Contains(s.Format))
.OrderBy(s => s.SortName)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
.AsNoTracking();
@ -187,6 +190,24 @@ public class SeriesRepository : ISeriesRepository
return await PagedList<SeriesDto>.CreateAsync(query, userParams.PageNumber, userParams.PageSize);
}
private async Task<List<int>> GetUserLibraries(int libraryId, int userId)
{
if (libraryId == 0)
{
return await _context.Library
.Include(l => l.AppUsers)
.Where(library => library.AppUsers.Any(user => user.Id == userId))
.AsNoTracking()
.Select(library => library.Id)
.ToListAsync();
}
return new List<int>()
{
libraryId
};
}
public async Task<IEnumerable<SearchResultDto>> SearchSeries(int[] libraryIds, string searchQuery)
{
return await _context.Series
@ -357,26 +378,10 @@ public class SeriesRepository : ISeriesRepository
{
var formats = filter.GetSqlFilter();
if (libraryId == 0)
{
var userLibraries = _context.Library
.Include(l => l.AppUsers)
.Where(library => library.AppUsers.Any(user => user.Id == userId))
.AsNoTracking()
.Select(library => library.Id)
.ToList();
var allQuery = _context.Series
.Where(s => userLibraries.Contains(s.LibraryId) && formats.Contains(s.Format))
.OrderByDescending(s => s.Created)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
.AsNoTracking();
return await PagedList<SeriesDto>.CreateAsync(allQuery, userParams.PageNumber, userParams.PageSize);
}
var userLibraries = await GetUserLibraries(libraryId, userId);
var query = _context.Series
.Where(s => s.LibraryId == libraryId && formats.Contains(s.Format))
.Where(s => userLibraries.Contains(s.LibraryId) && formats.Contains(s.Format))
.OrderByDescending(s => s.Created)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
.AsSplitQuery()
@ -397,20 +402,8 @@ public class SeriesRepository : ISeriesRepository
public async Task<IEnumerable<SeriesDto>> GetOnDeck(int userId, int libraryId, UserParams userParams, FilterDto filter)
{
var formats = filter.GetSqlFilter();
IList<int> userLibraries;
if (libraryId == 0)
{
userLibraries = _context.Library
.Include(l => l.AppUsers)
.Where(library => library.AppUsers.Any(user => user.Id == userId))
.AsNoTracking()
.Select(library => library.Id)
.ToList();
}
else
{
userLibraries = new List<int>() {libraryId};
}
var userLibraries = await GetUserLibraries(libraryId, userId);
var series = _context.Series
.Where(s => formats.Contains(s.Format) && userLibraries.Contains(s.LibraryId))