A cross platform Audiobookshelf client for Android and iOS
Dart
Queue the rest of a series past book 100 instead of stopping there
Barnabas7e8728c5055d
diff --git a/lib/providers/_lp_absorbing.dart b/lib/providers/_lp_absorbing.dartindex 00e25fd0..fb2b055a 100644--- a/lib/providers/_lp_absorbing.dart+++ b/lib/providers/_lp_absorbing.dart@@ -886,7 +886,7 @@ mixin _AbsorbingMixin on ChangeNotifier, _StateMixin, _CoreMixin {}if (_api == null) return null;try {- final books = await _api!.getBooksBySeries(libraryId, seriesId, limit: 100);+ final books = await _api!.getAllBooksBySeries(libraryId, seriesId);if (books.isNotEmpty) {_upNextSeriesCache[seriesId] = (DateTime.now(), books);}@@ -1593,11 +1593,7 @@ mixin _AbsorbingMixin on ChangeNotifier, _StateMixin, _CoreMixin {List<dynamic> books;try {- books = await api.getBooksBySeries(- libraryId,- seriesId,- limit: 100,- );+ books = await api.getAllBooksBySeries(libraryId, seriesId);} catch (error) {debugPrint('[QueueDownload] Series fetch failed: $error');return [_queueDownloadItem(currentKey, current)];@@ -1787,7 +1783,7 @@ mixin _AbsorbingMixin on ChangeNotifier, _StateMixin, _CoreMixin {Future<List<Map<String, dynamic>>> fetchBooksBySeries(String libraryId, String seriesId) async {if (_api == null) return const [];- final books = await _api!.getBooksBySeries(libraryId, seriesId, limit: 100);+ final books = await _api!.getAllBooksBySeries(libraryId, seriesId);return books.whereType<Map<String, dynamic>>().toList();}diff --git a/lib/providers/_lp_core.dart b/lib/providers/_lp_core.dartindex 934b3e3d..a7e4dc02 100644--- a/lib/providers/_lp_core.dart+++ b/lib/providers/_lp_core.dart@@ -3358,11 +3358,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {if (seriesId == null || currentSeq == null) return;final libraryId = data?['libraryId'] as String? ?? _selectedLibraryId;- final books = await _api!.getBooksBySeries(- libraryId ?? '',- seriesId,- limit: 100,- );+ final books = await _api!.getAllBooksBySeries(libraryId ?? '', seriesId);if (books.isEmpty) return;final dl = DownloadService();diff --git a/lib/services/api_service.dart b/lib/services/api_service.dartindex 1cffd86b..85ce7702 100644--- a/lib/services/api_service.dart+++ b/lib/services/api_service.dart@@ -1758,6 +1758,38 @@ class ApiService {return [];}+ /// Every book in a series, in sequence order. The queue and rolling+ /// download need the whole series: a capped page only ever holds the first+ /// N sequences, so a long series (GH #377, 200+ entries) never queued+ /// anything past that cap. limit=0 is unlimited on the server.+ Future<List<dynamic>> getAllBooksBySeries(+ String libraryId,+ String seriesId,+ ) async {+ try {+ final filterValue = base64Encode(utf8.encode(seriesId));+ final url = '$_cleanBaseUrl/api/libraries/$libraryId/items'+ '?filter=series.$filterValue'+ '&sort=media.metadata.series.sequence&limit=0&collapseseries=0';+ final sw = Stopwatch()..start();+ final response = await _authGet(+ Uri.parse(url),+ timeout: const Duration(seconds: 30),+ );+ if (response.statusCode == 200) {+ final data = jsonDecode(response.body) as Map<String, dynamic>;+ final results = data['results'] as List<dynamic>? ?? [];+ debugPrint('[API] getAllBooksBySeries $seriesId: ${results.length} books '+ '(total=${data['total']}) in ${sw.elapsedMilliseconds}ms');+ return results;+ }+ debugPrint('[API] getAllBooksBySeries $seriesId: HTTP ${response.statusCode}');+ } catch (e) {+ debugPrint('[API] getAllBooksBySeries error: $e');+ }+ return [];+ }+/// Expose clean base URL for audio player to build URLsString get cleanBaseUrl => _cleanBaseUrl;