Browse Source

add configurable jellyfin page size

pull/2745/head
Jason Dove 7 months ago
parent
commit
4d5a833789
No known key found for this signature in database
  1. 1
      CHANGELOG.md
  2. 13
      ErsatzTV.Core/SystemEnvironment.cs
  3. 12
      ErsatzTV.Infrastructure/Jellyfin/JellyfinApiClient.cs

1
CHANGELOG.md

@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- e.g. if this is set to `1000`, queries taking longer than 1 second will be logged
- `ETV_SLOW_API_MS` - milliseconds threshold for logging slow API calls (at DEBUG level)
- This is currently limited to *Jellyfin*
- `ETV_JF_PAGE_SIZE` - page size for library scan API calls to Jellyfin; default value is 10
### Fixed
- Fix startup on systems unsupported by NvEncSharp

13
ErsatzTV.Core/SystemEnvironment.cs

@ -38,16 +38,24 @@ public class SystemEnvironment @@ -38,16 +38,24 @@ public class SystemEnvironment
MaximumUploadMb = maximumUploadMb;
string slowDbMsVariable = Environment.GetEnvironmentVariable("ETV_SLOW_DB_MS");
if (int.TryParse(slowDbMsVariable, out int slowDbMs))
if (int.TryParse(slowDbMsVariable, out int slowDbMs) && slowDbMs > 0)
{
SlowDbMs = slowDbMs;
}
string slowApiMsVariable = Environment.GetEnvironmentVariable("ETV_SLOW_API_MS");
if (int.TryParse(slowApiMsVariable, out int slowApiMs))
if (int.TryParse(slowApiMsVariable, out int slowApiMs) && slowApiMs > 0)
{
SlowApiMs = slowApiMs;
}
string jellyfinPageSizeVariable = Environment.GetEnvironmentVariable("ETV_JF_PAGE_SIZE");
if (!int.TryParse(jellyfinPageSizeVariable, out int jellyfinPageSize))
{
jellyfinPageSize = 10;
}
JellyfinPageSize = jellyfinPageSize;
}
public static string BaseUrl { get; }
@ -59,4 +67,5 @@ public class SystemEnvironment @@ -59,4 +67,5 @@ public class SystemEnvironment
public static int MaximumUploadMb { get; }
public static int? SlowDbMs { get; }
public static int? SlowApiMs { get; }
public static int JellyfinPageSize { get; set; }
}

12
ErsatzTV.Infrastructure/Jellyfin/JellyfinApiClient.cs

@ -294,17 +294,19 @@ public class JellyfinApiClient : IJellyfinApiClient @@ -294,17 +294,19 @@ public class JellyfinApiClient : IJellyfinApiClient
{
IJellyfinApi service = ServiceForAddress(address);
const int PAGE_SIZE = 10;
int pages = int.MaxValue;
for (var i = 0; i < pages; i++)
{
int skip = i * PAGE_SIZE;
int skip = i * SystemEnvironment.JellyfinPageSize;
JellyfinLibraryItemsResponse result = await getItems(service, parentId, skip, PAGE_SIZE);
JellyfinLibraryItemsResponse result = await getItems(
service,
parentId,
skip,
SystemEnvironment.JellyfinPageSize);
// update page count
pages = Math.Min(pages, (result.TotalRecordCount - 1) / PAGE_SIZE + 1);
pages = Math.Min(pages, (result.TotalRecordCount - 1) / SystemEnvironment.JellyfinPageSize + 1);
foreach (TItem item in result.Items.Map(item => mapper(maybeLibrary, item)).Somes())
{

Loading…
Cancel
Save