Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Bump series discovery batch size to 10, add abridged badge placeholder, bump 1.8.63

Nathan Poulson06b22571172d
diff --git a/lib/services/api_service.dart b/lib/services/api_service.dart
index e4cb531b..a3da8ebd 100644
--- a/lib/services/api_service.dart
+++ b/lib/services/api_service.dart
@@ -1317,11 +1317,9 @@ class ApiService {
/// releaseDate, runtimeMinutes, rating, coverUrl, sequence.
/// Books are deduplicated by sequence (prefers user's region) and sorted.
static Future<List<Map<String, dynamic>>> discoverAudibleSeries(String seriesAsin) async {
- // Step 1: Get all book ASINs from relationships
final relationships = await getAudibleSeriesBooks(seriesAsin);
if (relationships.isEmpty) return [];
- // Step 2: Deduplicate by sequence — group ASINs, pick one per sequence
final bySequence = <String, List<Map<String, dynamic>>>{};
for (final r in relationships) {
final seq = r['sequence'] as String? ?? '';
@@ -1330,7 +1328,6 @@ class ApiService {
bySequence.putIfAbsent(key, () => []).add(r);
}
- // Pick first ASIN per sequence (Audible returns regional ones for the user's TLD)
final uniqueBooks = <Map<String, dynamic>>[];
for (final entry in bySequence.entries) {
uniqueBooks.add({
@@ -1339,11 +1336,9 @@ class ApiService {
});
}
- // Step 3: Fetch details for each unique book (parallel, batched)
final results = <Map<String, dynamic>>[];
- // Fetch in batches of 5 to avoid overwhelming the API
- for (var i = 0; i < uniqueBooks.length; i += 5) {
- final batch = uniqueBooks.skip(i).take(5);
+ for (var i = 0; i < uniqueBooks.length; i += 10) {
+ final batch = uniqueBooks.skip(i).take(10);
final futures = batch.map((book) async {
final asin = book['asin'] as String;
final details = await getAudibleBookDetails(asin);
@@ -1376,7 +1371,6 @@ class ApiService {
results.addAll(batchResults.whereType<Map<String, dynamic>>());
}
- // Sort by sequence number
results.sort((a, b) {
final seqA = double.tryParse(a['sequence']?.toString() ?? '') ?? 999;
final seqB = double.tryParse(b['sequence']?.toString() ?? '') ?? 999;
diff --git a/lib/widgets/audible_series_sheet.dart b/lib/widgets/audible_series_sheet.dart
index 72f3df1f..c3bb740c 100644
--- a/lib/widgets/audible_series_sheet.dart
+++ b/lib/widgets/audible_series_sheet.dart
@@ -254,6 +254,8 @@ class _AudibleSeriesSheetState extends State<AudibleSeriesSheet> {
final coverUrl = book['coverUrl'] as String? ?? '';
final releaseDate = book['releaseDate'] as String? ?? '';
final runtime = _formatRuntime(book['runtimeMinutes']);
+ final bookFormat = (book['bookFormat'] as String? ?? '').toLowerCase();
+ final isAbridged = bookFormat.contains('abridg');
final owned = _isOwned(book);
final upcoming = _isUpcoming(book);
@@ -352,6 +354,21 @@ class _AudibleSeriesSheetState extends State<AudibleSeriesSheet> {
padding: const EdgeInsets.symmetric(horizontal: 6),
child: Text('·', style: TextStyle(color: cs.onSurfaceVariant.withValues(alpha: 0.3), fontSize: 10)),
),
+ if (isAbridged) ...[
+ Container(
+ padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),
+ decoration: BoxDecoration(
+ color: cs.error.withValues(alpha: 0.15),
+ borderRadius: BorderRadius.circular(4),
+ ),
+ child: Text('Abridged', style: TextStyle(fontSize: 9, fontWeight: FontWeight.w600, color: cs.error)),
+ ),
+ if (releaseDate.isNotEmpty || runtime.isNotEmpty)
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 6),
+ child: Text('·', style: TextStyle(color: cs.onSurfaceVariant.withValues(alpha: 0.3), fontSize: 10)),
+ ),
+ ],
if (runtime.isNotEmpty) ...[
Icon(Icons.schedule_rounded, size: 11, color: cs.onSurfaceVariant.withValues(alpha: 0.5)),
const SizedBox(width: 3),
diff --git a/lib/widgets/series_books_sheet.dart b/lib/widgets/series_books_sheet.dart
index 0f77a415..ea605e3a 100644
--- a/lib/widgets/series_books_sheet.dart
+++ b/lib/widgets/series_books_sheet.dart
@@ -618,9 +618,6 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
// Try to get a series ASIN from one of the books via Audnexus
String? seriesAsin;
- String resolveMethod = 'none';
-
- debugPrint('[FindSeries] Starting lookup for "${widget.seriesName}" (region=${ApiService.debugRegion}, tld=${ApiService.debugTld})');
for (final book in _books) {
final media = book['media'] as Map<String, dynamic>? ?? {};
@@ -628,57 +625,19 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
final bookAsin = metadata['asin'] as String? ?? '';
if (bookAsin.isEmpty) continue;
- debugPrint('[FindSeries] Trying book ASIN $bookAsin via Audnexus');
final audnexus = await ApiService.getAudnexusBook(bookAsin);
- if (audnexus == null) {
- debugPrint('[FindSeries] Audnexus returned null for $bookAsin');
- continue;
- }
+ if (audnexus == null) continue;
final primary = audnexus['seriesPrimary'] as Map<String, dynamic>?;
if (primary != null && primary['asin'] != null) {
seriesAsin = primary['asin'] as String;
- resolveMethod = 'audnexus-primary';
- debugPrint('[FindSeries] Got series ASIN $seriesAsin from primary (book $bookAsin)');
break;
}
final secondary = audnexus['seriesSecondary'] as Map<String, dynamic>?;
if (secondary != null && secondary['asin'] != null) {
seriesAsin = secondary['asin'] as String;
- resolveMethod = 'audnexus-secondary';
- debugPrint('[FindSeries] Got series ASIN $seriesAsin from secondary (book $bookAsin)');
break;
}
- debugPrint('[FindSeries] Audnexus had no series info for $bookAsin');
- }
-
- // Fallback: retry with region=us if device region isn't US
- if (seriesAsin == null && ApiService.debugRegion != 'us') {
- debugPrint('[FindSeries] Retrying with region=us');
- for (final book in _books) {
- final media = book['media'] as Map<String, dynamic>? ?? {};
- final metadata = media['metadata'] as Map<String, dynamic>? ?? {};
- final bookAsin = metadata['asin'] as String? ?? '';
- if (bookAsin.isEmpty) continue;
-
- final audnexus = await ApiService.getAudnexusBook(bookAsin, region: 'us');
- if (audnexus == null) continue;
-
- final primary = audnexus['seriesPrimary'] as Map<String, dynamic>?;
- if (primary != null && primary['asin'] != null) {
- seriesAsin = primary['asin'] as String;
- resolveMethod = 'audnexus-primary-us';
- debugPrint('[FindSeries] Got series ASIN $seriesAsin from US fallback (book $bookAsin)');
- break;
- }
- final secondary = audnexus['seriesSecondary'] as Map<String, dynamic>?;
- if (secondary != null && secondary['asin'] != null) {
- seriesAsin = secondary['asin'] as String;
- resolveMethod = 'audnexus-secondary-us';
- debugPrint('[FindSeries] Got series ASIN $seriesAsin from US fallback secondary (book $bookAsin)');
- break;
- }
- }
}
// Fallback: search Audible for the first book if no ASINs found
@@ -689,13 +648,11 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
final title = metadata['title'] as String? ?? '';
final author = metadata['authorName'] as String? ?? '';
- debugPrint('[FindSeries] Falling back to title search: "$title" by "$author"');
if (title.isNotEmpty && mounted) {
final auth = context.read<AuthProvider>();
final api = auth.apiService;
if (api != null) {
final results = await api.searchBooks(title: title, author: author.isNotEmpty ? author : null);
- debugPrint('[FindSeries] Title search returned ${results.length} results');
for (final r in results) {
final asin = r['asin'] as String? ?? '';
if (asin.isEmpty) continue;
@@ -704,8 +661,6 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
final primary = audnexus['seriesPrimary'] as Map<String, dynamic>?;
if (primary != null && primary['asin'] != null) {
seriesAsin = primary['asin'] as String;
- resolveMethod = 'title-search';
- debugPrint('[FindSeries] Got series ASIN $seriesAsin from title search (asin $asin)');
break;
}
}
@@ -713,8 +668,6 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
}
}
- debugPrint('[FindSeries] Result: seriesAsin=$seriesAsin via $resolveMethod');
-
if (!mounted) return;
if (seriesAsin == null) {
diff --git a/pubspec.yaml b/pubspec.yaml
index 9651dd8a..f90e7f65 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,7 +1,7 @@
name: absorb
description: An Audiobookshelf Client
publish_to: 'none'
-version: 1.8.62+80
+version: 1.8.63+80
# v1.8.41: JWT auth (accessToken + refreshToken), MANAGE_EXTERNAL_STORAGE removed from playstore flavor
# Build scripts (run from Git Bash):
# . ./build_bundle.sh - Play Store AAB (no MANAGE_EXTERNAL_STORAGE)