Rework series parsing.
MODIFY
XRayBuilder.Core/src/Config/IXRayBuilderConfig.cs
XRayBuilder.Core/src/Config/IXRayBuilderConfig.cs
@@ -11,5 +11,6 @@ public interface IXRayBuilderConfig
/// When the old version is being built, enables excerpt shortening
/// </summary>
bool ShortenExcerptsLegacy { get; }
+ string AmazonTld { get; }
}
}
\ No newline at end of file

MODIFY
XRayBuilder.Core/src/Config/XRayBuilderConfig.cs
XRayBuilder.Core/src/Config/XRayBuilderConfig.cs
@@ -8,5 +8,6 @@ public sealed class XRayBuilderConfig : IXRayBuilderConfig
public bool UseSubdirectories { get; set; }
public bool UseNewVersion { get; set; }
public bool ShortenExcerptsLegacy { get; set; }
+ public string AmazonTld { get; set; }
}
}
\ No newline at end of file

MODIFY
XRayBuilder.Core/src/DataSources/Secondary/SecondarySourceGoodreads.cs
XRayBuilder.Core/src/DataSources/Secondary/SecondarySourceGoodreads.cs
using System.Threading.Tasks;
using Dasync.Collections;
using HtmlAgilityPack;
+using XRayBuilder.Core.Config;
using XRayBuilder.Core.DataSources.Amazon;
using XRayBuilder.Core.DataSources.Secondary.Model;
using XRayBuilder.Core.Libraries;
@@ -32,6 +33,7 @@ public sealed class SecondarySourceGoodreads : SecondarySource
private readonly IHttpClient _httpClient;
private readonly IAmazonClient _amazonClient;
private readonly IReadingTimeService _readingTimeService;
+ private readonly IXRayBuilderConfig _config;
private const int MaxConcurrentRequests = 10;
@@ -44,12 +46,13 @@ public sealed class SecondarySourceGoodreads : SecondarySource
private readonly Regex _regexEditions = new(@"editions/(?<editions>[0-9]*)-", RegexOptions.Compiled);
private readonly Regex _regexPages = new(@"(?<pages>(\d+)|(\d+,\d+)) pages", RegexOptions.Compiled);
- public SecondarySourceGoodreads(ILogger logger, IHttpClient httpClient, IAmazonClient amazonClient, IReadingTimeService readingTimeService)
+ public SecondarySourceGoodreads(ILogger logger, IHttpClient httpClient, IAmazonClient amazonClient, IReadingTimeService readingTimeService, IXRayBuilderConfig config)
{
_logger = logger;
_httpClient = httpClient;
_amazonClient = amazonClient;
_readingTimeService = readingTimeService;
+ _config = config;
}
private string ParseBookIdFromUrl(string input) => _regexBookId.Match(input).Groups["id"].Value;
@@ -167,6 +170,11 @@ public override async Task<SeriesInfo> GetSeriesInfoAsync(string dataUrl, Cancel
if (series.Total == 0)
return series;
+ _logger.Log((int) Convert.ToDouble(series.Position) == series.Total
+ ? $"This is the latest book in the {series.Name} series."
+ : $"This is book {series.Position} of {series.Total} in the {series.Name} series.");
+ _logger.Log($"Series URL: {series.Url}");
+
var positionInt = (int)Convert.ToDouble(series.Position, CultureInfo.InvariantCulture.NumberFormat);
var prevSearch = $"book {positionInt - 1}";
@@ -200,9 +208,17 @@ async Task<BookInfo> ParseSeriesBook(HtmlNode bookNode)
var bookIndexText = bookIndex.InnerText.ToLower();
if (bookIndexText == prevSearch && series.Previous == null)
+ {
series.Previous = await ParseSeriesBook(bookNode);
+ if(series.Previous != null)
+ _logger.Log($"Preceded by {series.Previous.Title}.");
+ }
else if (bookIndexText == nextSearch)
+ {
series.Next = await ParseSeriesBook(bookNode);
+ if(series.Next != null)
+ _logger.Log($"Followed by {series.Next.Title}.");
+ }
if (series.Previous != null && (series.Next != null || positionInt == series.Total))
break; // next and prev found or prev found and latest in series

MODIFY
XRayBuilder/src/Config/XRayBuilderConfig.cs
XRayBuilder/src/Config/XRayBuilderConfig.cs
@@ -10,5 +10,6 @@ public sealed class XRayBuilderConfig : IXRayBuilderConfig
public bool UseSubdirectories => Properties.Settings.Default.useSubDirectories;
public bool UseNewVersion => Properties.Settings.Default.useNewVersion;
public bool ShortenExcerptsLegacy => false;
+ public string AmazonTld => Properties.Settings.Default.amazonTLD;
}
}
\ No newline at end of file

Rework series parsing.