Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Add Find Missing Books in series, split CodeMagic workflows, bump 1.8.60

Barnabas3f251e42a363
diff --git a/codemagic.yaml b/codemagic.yaml
index 666b5a1a..a6a114ce 100644
--- a/codemagic.yaml
+++ b/codemagic.yaml
@@ -1,6 +1,46 @@
workflows:
+ github-release:
+ name: GitHub APK Only
+ max_build_duration: 60
+ instance_type: mac_mini_m2
+ environment:
+ android_signing:
+ - absorb_keystore
+ groups:
+ - github_credentials
+ flutter: stable
+ java: 17
+ scripts:
+ - name: Set up key.properties
+ script: |
+ cat >> $CM_BUILD_DIR/android/key.properties <<EOF
+ storePassword=$CM_KEYSTORE_PASSWORD
+ keyPassword=$CM_KEY_PASSWORD
+ keyAlias=$CM_KEY_ALIAS
+ storeFile=$CM_KEYSTORE_PATH
+ EOF
+ - name: Build GitHub APK
+ script: flutter build apk --release --flavor github --dart-define=GITHUB_BUILD=true
+ - name: Publish to GitHub Draft Release
+ script: |
+ VERSION="v$(grep 'version:' pubspec.yaml | head -1 | sed 's/version: //' | cut -d'+' -f1)"
+ if gh release view "$VERSION" --repo "$CM_REPO_SLUG" &>/dev/null; then
+ gh release upload "$VERSION" \
+ build/app/outputs/apk/github/release/*.apk \
+ --clobber \
+ --repo "$CM_REPO_SLUG"
+ else
+ gh release create "$VERSION" \
+ build/app/outputs/apk/github/release/*.apk \
+ --draft \
+ --title "$VERSION" \
+ --repo "$CM_REPO_SLUG"
+ fi
+ artifacts:
+ - build/app/outputs/apk/github/release/*.apk
+
android-release:
- name: Android Release
+ name: Android Release (GitHub + Play Store)
max_build_duration: 60
instance_type: mac_mini_m2
environment:
diff --git a/lib/services/api_service.dart b/lib/services/api_service.dart
index ca247382..ab2789d1 100644
--- a/lib/services/api_service.dart
+++ b/lib/services/api_service.dart
@@ -1223,6 +1223,163 @@ class ApiService {
return null;
}
+ // ─── Audible Series Discovery ─────────────────────────────
+
+ /// Map region code to Audible API TLD.
+ static String get _audibleTld {
+ const tlds = {
+ 'us': '.com', 'uk': '.co.uk', 'gb': '.co.uk', 'au': '.com.au',
+ 'ca': '.ca', 'de': '.de', 'fr': '.fr', 'it': '.it', 'es': '.es',
+ 'jp': '.co.jp', 'in': '.in', 'br': '.com.br',
+ };
+ return tlds[_region] ?? '.com';
+ }
+
+ /// Fetch full book metadata from Audnexus by ASIN.
+ /// Returns the raw Audnexus response including seriesPrimary, releaseDate, etc.
+ static Future<Map<String, dynamic>?> getAudnexusBook(String asin) async {
+ try {
+ final response = await http.get(
+ Uri.parse('https://api.audnex.us/books/$asin?region=$_region'),
+ ).timeout(const Duration(seconds: 10));
+ if (response.statusCode == 200) {
+ return jsonDecode(response.body) as Map<String, dynamic>;
+ }
+ } catch (e) {
+ debugPrint('[API] getAudnexusBook error: $e');
+ }
+ return null;
+ }
+
+ /// Get all book ASINs in an Audible series using the catalog relationships endpoint.
+ /// Returns a list of { asin, sequence, sort } maps.
+ static Future<List<Map<String, dynamic>>> getAudibleSeriesBooks(String seriesAsin) async {
+ try {
+ final url = 'https://api.audible$_audibleTld/1.0/catalog/products/$seriesAsin'
+ '?response_groups=relationships';
+ debugPrint('[API] getAudibleSeriesBooks: $url');
+ final response = await http.get(Uri.parse(url))
+ .timeout(const Duration(seconds: 15));
+
+ if (response.statusCode == 200) {
+ final data = jsonDecode(response.body) as Map<String, dynamic>;
+ final product = data['product'] as Map<String, dynamic>? ?? {};
+ final relationships = product['relationships'] as List<dynamic>? ?? [];
+
+ final books = <Map<String, dynamic>>[];
+ for (final r in relationships) {
+ if (r is! Map<String, dynamic>) continue;
+ final asin = r['asin'] as String?;
+ if (asin == null || asin.isEmpty) continue;
+ books.add({
+ 'asin': asin,
+ 'sequence': r['sequence']?.toString() ?? '',
+ 'sort': r['sort']?.toString() ?? '0',
+ });
+ }
+ return books;
+ }
+ debugPrint('[API] getAudibleSeriesBooks status=${response.statusCode}');
+ } catch (e) {
+ debugPrint('[API] getAudibleSeriesBooks error: $e');
+ }
+ return [];
+ }
+
+ /// Fetch details for a single book from the Audible catalog API.
+ /// Returns title, authors, narrators, release_date, runtime, rating, cover, etc.
+ static Future<Map<String, dynamic>?> getAudibleBookDetails(String asin) async {
+ try {
+ final url = 'https://api.audible$_audibleTld/1.0/catalog/products/$asin'
+ '?response_groups=product_attrs,product_desc,product_details,series,rating,media';
+ final response = await http.get(Uri.parse(url))
+ .timeout(const Duration(seconds: 10));
+
+ if (response.statusCode == 200) {
+ final data = jsonDecode(response.body) as Map<String, dynamic>;
+ return data['product'] as Map<String, dynamic>?;
+ }
+ } catch (e) {
+ debugPrint('[API] getAudibleBookDetails error: $e');
+ }
+ return null;
+ }
+
+ /// High-level: discover all books in an Audible series, returning enriched data.
+ /// [seriesAsin] is the Audible series ASIN.
+ /// Returns a list of book maps with: asin, title, subtitle, authors, narrators,
+ /// 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? ?? '';
+ final sort = r['sort'] as String? ?? '0';
+ final key = seq.isNotEmpty ? seq : 'sort_$sort';
+ 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({
+ ...entry.value.first,
+ '_allAsins': entry.value.map((e) => e['asin'] as String).toList(),
+ });
+ }
+
+ // 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);
+ final futures = batch.map((book) async {
+ final asin = book['asin'] as String;
+ final details = await getAudibleBookDetails(asin);
+ if (details == null) return null;
+
+ final authors = (details['authors'] as List<dynamic>? ?? [])
+ .map((a) => (a as Map<String, dynamic>)['name'] ?? '').join(', ');
+ final narrators = (details['narrators'] as List<dynamic>? ?? [])
+ .map((n) => (n as Map<String, dynamic>)['name'] ?? '').join(', ');
+ final rating = details['rating'] as Map<String, dynamic>?;
+
+ return <String, dynamic>{
+ 'asin': asin,
+ 'title': details['title'] ?? '',
+ 'subtitle': details['subtitle'] ?? '',
+ 'authors': authors,
+ 'narrators': narrators,
+ 'releaseDate': details['release_date'] ?? '',
+ 'runtimeMinutes': details['runtime_length_min'] ?? 0,
+ 'rating': rating?['overall_distribution']?['display_average_rating']
+ ?? rating?['num_reviews'] != null ? (rating?['overall_distribution']?['display_average_rating'] ?? 0.0) : 0.0,
+ 'numRatings': rating?['overall_distribution']?['num_ratings'] ?? 0,
+ 'coverUrl': details['product_images']?['500'] ?? details['product_images']?['1024'] ?? '',
+ 'sequence': book['sequence'] ?? '',
+ 'sort': book['sort'] ?? '0',
+ 'publisherSummary': details['publisher_summary'] ?? '',
+ };
+ });
+ final batchResults = await Future.wait(futures);
+ 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;
+ return seqA.compareTo(seqB);
+ });
+
+ return results;
+ }
+
// ─── Admin Endpoints ──────────────────────────────────────
/// Get all users (admin only)
diff --git a/lib/widgets/audible_series_sheet.dart b/lib/widgets/audible_series_sheet.dart
new file mode 100644
index 00000000..5b68e5e8
--- /dev/null
+++ b/lib/widgets/audible_series_sheet.dart
@@ -0,0 +1,333 @@
+import 'package:flutter/material.dart';
+import 'package:cached_network_image/cached_network_image.dart';
+import '../services/api_service.dart';
+import 'stackable_sheet.dart';
+
+/// Show a bottom sheet with Audible series discovery results.
+/// Shows missing books and upcoming releases for a series.
+void showAudibleSeriesSheet(BuildContext context, {
+ required String seriesName,
+ required String seriesAsin,
+ required Set<String> ownedTitles,
+ required Set<String> ownedAsins,
+}) {
+ showStackableSheet(
+ context: context,
+ showHandle: true,
+ builder: (ctx, scrollController) => AudibleSeriesSheet(
+ seriesName: seriesName,
+ seriesAsin: seriesAsin,
+ ownedTitles: ownedTitles,
+ ownedAsins: ownedAsins,
+ scrollController: scrollController,
+ ),
+ );
+}
+
+class AudibleSeriesSheet extends StatefulWidget {
+ final String seriesName;
+ final String seriesAsin;
+ final Set<String> ownedTitles;
+ final Set<String> ownedAsins;
+ final ScrollController scrollController;
+
+ const AudibleSeriesSheet({
+ super.key,
+ required this.seriesName,
+ required this.seriesAsin,
+ required this.ownedTitles,
+ required this.ownedAsins,
+ required this.scrollController,
+ });
+
+ @override
+ State<AudibleSeriesSheet> createState() => _AudibleSeriesSheetState();
+}
+
+class _AudibleSeriesSheetState extends State<AudibleSeriesSheet> {
+ List<Map<String, dynamic>> _allBooks = [];
+ bool _isLoading = true;
+ String? _error;
+ bool _showAll = false; // false = missing only, true = all books
+
+ @override
+ void initState() {
+ super.initState();
+ _fetchSeries();
+ }
+
+ Future<void> _fetchSeries() async {
+ try {
+ final books = await ApiService.discoverAudibleSeries(widget.seriesAsin);
+ if (!mounted) return;
+ if (books.isEmpty) {
+ setState(() { _isLoading = false; _error = 'No books found on Audible'; });
+ return;
+ }
+ setState(() { _allBooks = books; _isLoading = false; });
+ } catch (e) {
+ if (!mounted) return;
+ setState(() { _isLoading = false; _error = 'Failed to load series from Audible'; });
+ }
+ }
+
+ bool _isOwned(Map<String, dynamic> book) {
+ final asin = book['asin'] as String? ?? '';
+ if (widget.ownedAsins.contains(asin)) return true;
+ // Fuzzy title match — normalize and compare
+ final title = (book['title'] as String? ?? '').toLowerCase().trim();
+ for (final owned in widget.ownedTitles) {
+ if (owned.toLowerCase().trim() == title) return true;
+ }
+ return false;
+ }
+
+ bool _isUpcoming(Map<String, dynamic> book) {
+ final dateStr = book['releaseDate'] as String? ?? '';
+ if (dateStr.isEmpty) return false;
+ final date = DateTime.tryParse(dateStr);
+ if (date == null) return false;
+ return date.isAfter(DateTime.now());
+ }
+
+ String _formatRuntime(dynamic minutes) {
+ final mins = (minutes is num) ? minutes.toInt() : 0;
+ if (mins <= 0) return '';
+ final h = mins ~/ 60;
+ final m = mins % 60;
+ if (h > 0 && m > 0) return '${h}h ${m}m';
+ if (h > 0) return '${h}h';
+ return '${m}m';
+ }
+
+ String _formatDate(String dateStr) {
+ final date = DateTime.tryParse(dateStr);
+ if (date == null) return dateStr;
+ const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
+ return '${months[date.month - 1]} ${date.day}, ${date.year}';
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final cs = Theme.of(context).colorScheme;
+ final tt = Theme.of(context).textTheme;
+
+ final displayBooks = _showAll
+ ? _allBooks
+ : _allBooks.where((b) => !_isOwned(b)).toList();
+
+ final missingCount = _allBooks.where((b) => !_isOwned(b)).length;
+ final upcomingCount = _allBooks.where((b) => _isUpcoming(b)).length;
+
+ return ClipRect(child: Column(
+ children: [
+ // Header
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const SizedBox(width: 48),
+ Expanded(
+ child: Column(children: [
+ Icon(Icons.travel_explore_rounded, size: 20, color: cs.primary),
+ const SizedBox(height: 4),
+ Text(widget.seriesName,
+ maxLines: 2, overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.center,
+ style: tt.titleLarge?.copyWith(fontWeight: FontWeight.w600)),
+ ]),
+ ),
+ const SizedBox(width: 48),
+ ],
+ ),
+ const SizedBox(height: 4),
+ if (!_isLoading && _error == null)
+ Text(
+ '${_allBooks.length} on Audible · $missingCount missing${upcomingCount > 0 ? ' · $upcomingCount upcoming' : ''}',
+ style: tt.bodyMedium?.copyWith(color: cs.onSurfaceVariant),
+ ),
+ const SizedBox(height: 8),
+
+ // Filter toggle
+ if (!_isLoading && _error == null && _allBooks.isNotEmpty)
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Row(children: [
+ _filterChip(cs, 'Missing ($missingCount)', !_showAll, () => setState(() => _showAll = false)),
+ const SizedBox(width: 8),
+ _filterChip(cs, 'All (${_allBooks.length})', _showAll, () => setState(() => _showAll = true)),
+ ]),
+ ),
+ const SizedBox(height: 8),
+
+ // Content
+ if (_isLoading)
+ Expanded(child: Center(child: Column(mainAxisSize: MainAxisSize.min, children: [
+ const CircularProgressIndicator(strokeWidth: 2),
+ const SizedBox(height: 12),
+ Text('Searching Audible...', style: tt.bodySmall?.copyWith(color: cs.onSurface.withValues(alpha: 0.4))),
+ ])))
+ else if (_error != null)
+ Expanded(child: Center(child: Text(_error!, style: tt.bodyLarge?.copyWith(color: cs.onSurfaceVariant))))
+ else if (displayBooks.isEmpty)
+ Expanded(child: Center(child: Column(mainAxisSize: MainAxisSize.min, children: [
+ Icon(Icons.check_circle_outline_rounded, size: 48, color: cs.primary.withValues(alpha: 0.5)),
+ const SizedBox(height: 12),
+ Text('You have the complete series!', style: tt.bodyLarge?.copyWith(color: cs.onSurfaceVariant)),
+ ])))
+ else
+ Expanded(
+ child: ListView.builder(
+ controller: widget.scrollController,
+ padding: EdgeInsets.fromLTRB(16, 0, 16, 24 + MediaQuery.of(context).viewPadding.bottom),
+ itemCount: displayBooks.length,
+ itemBuilder: (context, index) => _buildBookCard(cs, tt, displayBooks[index]),
+ ),
+ ),
+ ],
+ ));
+ }
+
+ Widget _filterChip(ColorScheme cs, String label, bool selected, VoidCallback onTap) {
+ return GestureDetector(
+ onTap: onTap,
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
+ decoration: BoxDecoration(
+ color: selected ? cs.primary.withValues(alpha: 0.15) : cs.onSurface.withValues(alpha: 0.06),
+ borderRadius: BorderRadius.circular(20),
+ border: Border.all(color: selected ? cs.primary.withValues(alpha: 0.3) : cs.onSurface.withValues(alpha: 0.1)),
+ ),
+ child: Text(label, style: TextStyle(
+ color: selected ? cs.primary : cs.onSurfaceVariant,
+ fontSize: 12, fontWeight: FontWeight.w600,
+ )),
+ ),
+ );
+ }
+
+ Widget _buildBookCard(ColorScheme cs, TextTheme tt, Map<String, dynamic> book) {
+ final title = book['title'] as String? ?? '';
+ final subtitle = book['subtitle'] as String? ?? '';
+ final authors = book['authors'] as String? ?? '';
+ final narrators = book['narrators'] as String? ?? '';
+ final sequence = book['sequence'] as String? ?? '';
+ final coverUrl = book['coverUrl'] as String? ?? '';
+ final releaseDate = book['releaseDate'] as String? ?? '';
+ final runtime = _formatRuntime(book['runtimeMinutes']);
+ final owned = _isOwned(book);
+ final upcoming = _isUpcoming(book);
+
+ return Padding(
+ padding: const EdgeInsets.only(bottom: 8),
+ child: Card(
+ elevation: 0,
+ color: upcoming
+ ? cs.primaryContainer.withValues(alpha: 0.3)
+ : owned
+ ? cs.surfaceContainerHigh.withValues(alpha: 0.5)
+ : cs.surfaceContainerHigh,
+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
+ clipBehavior: Clip.antiAlias,
+ child: SizedBox(
+ height: 112,
+ child: Row(children: [
+ // Cover
+ AspectRatio(
+ aspectRatio: 1,
+ child: Stack(children: [
+ Positioned.fill(
+ child: coverUrl.isNotEmpty
+ ? CachedNetworkImage(
+ imageUrl: coverUrl, fit: BoxFit.cover,
+ placeholder: (_, __) => _placeholder(cs),
+ errorWidget: (_, __, ___) => _placeholder(cs))
+ : _placeholder(cs),
+ ),
+ if (sequence.isNotEmpty)
+ Positioned(top: 4, left: 4,
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 2),
+ decoration: BoxDecoration(color: Colors.black.withValues(alpha: 0.7), borderRadius: BorderRadius.circular(6)),
+ child: Text('#$sequence', style: const TextStyle(color: Colors.white, fontSize: 9, fontWeight: FontWeight.w600)),
+ ),
+ ),
+ if (upcoming)
+ Positioned(bottom: 4, left: 4,
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 2),
+ decoration: BoxDecoration(color: cs.primary.withValues(alpha: 0.9), borderRadius: BorderRadius.circular(6)),
+ child: const Text('UPCOMING', style: TextStyle(color: Colors.white, fontSize: 8, fontWeight: FontWeight.w700)),
+ ),
+ ),
+ if (owned)
+ Positioned(bottom: 4, right: 4,
+ child: Container(
+ padding: const EdgeInsets.all(3),
+ decoration: BoxDecoration(color: Colors.black.withValues(alpha: 0.7), shape: BoxShape.circle),
+ child: Icon(Icons.check_rounded, size: 12,
+ color: Theme.of(context).brightness == Brightness.dark ? Colors.greenAccent[400] : Colors.green.shade700),
+ ),
+ ),
+ ]),
+ ),
+ // Details
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(12, 10, 12, 10),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(title, maxLines: 2, overflow: TextOverflow.ellipsis,
+ style: tt.bodyMedium?.copyWith(fontWeight: FontWeight.w600, color: cs.onSurface)),
+ if (subtitle.isNotEmpty)
+ Padding(
+ padding: const EdgeInsets.only(top: 1),
+ child: Text(subtitle, maxLines: 1, overflow: TextOverflow.ellipsis,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant.withValues(alpha: 0.7), fontSize: 11)),
+ ),
+ const Spacer(),
+ if (authors.isNotEmpty)
+ Text(authors, maxLines: 1, overflow: TextOverflow.ellipsis,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant, fontSize: 11)),
+ if (narrators.isNotEmpty)
+ Text('Narrated by $narrators', maxLines: 1, overflow: TextOverflow.ellipsis,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant.withValues(alpha: 0.6), fontSize: 10)),
+ const SizedBox(height: 4),
+ Row(children: [
+ if (releaseDate.isNotEmpty) ...[
+ Icon(upcoming ? Icons.event_rounded : Icons.calendar_today_rounded,
+ size: 11, color: upcoming ? cs.primary : cs.onSurfaceVariant.withValues(alpha: 0.5)),
+ const SizedBox(width: 3),
+ Text(_formatDate(releaseDate),
+ style: TextStyle(fontSize: 10, fontWeight: upcoming ? FontWeight.w600 : FontWeight.w400,
+ color: upcoming ? cs.primary : cs.onSurfaceVariant.withValues(alpha: 0.5))),
+ ],
+ 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),
+ Text(runtime, style: TextStyle(fontSize: 10, color: cs.onSurfaceVariant.withValues(alpha: 0.5))),
+ ],
+ ]),
+ ],
+ ),
+ ),
+ ),
+ ]),
+ ),
+ ),
+ );
+ }
+
+ Widget _placeholder(ColorScheme cs) {
+ return Container(
+ color: cs.surfaceContainerHighest,
+ child: Center(child: Icon(Icons.auto_stories_rounded, color: cs.onSurface.withValues(alpha: 0.15), size: 32)),
+ );
+ }
+}
diff --git a/lib/widgets/series_books_sheet.dart b/lib/widgets/series_books_sheet.dart
index 6a41a9ba..089adc65 100644
--- a/lib/widgets/series_books_sheet.dart
+++ b/lib/widgets/series_books_sheet.dart
@@ -12,6 +12,8 @@ import 'book_detail_sheet.dart';
import 'library_grid_tiles.dart';
import 'episode_list_sheet.dart';
import 'stackable_sheet.dart';
+import 'audible_series_sheet.dart';
+import '../services/api_service.dart';
/// Show a bottom sheet with all books in a series, sorted by sequence.
/// Can be called from any screen.
@@ -585,6 +587,90 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
}
}
+ Future<void> _findOnAudible() async {
+ // Collect owned titles and ASINs for cross-referencing
+ final ownedTitles = <String>{};
+ final ownedAsins = <String>{};
+ for (final book in _books) {
+ final media = book['media'] as Map<String, dynamic>? ?? {};
+ final metadata = media['metadata'] as Map<String, dynamic>? ?? {};
+ final title = metadata['title'] as String? ?? '';
+ final asin = metadata['asin'] as String? ?? '';
+ if (title.isNotEmpty) ownedTitles.add(title);
+ if (asin.isNotEmpty) ownedAsins.add(asin);
+ }
+
+ // Try to get a series ASIN from one of the books
+ // First check if any book already has an ASIN we can use to look up via Audnexus
+ String? seriesAsin;
+
+ // Try each book's ASIN until we find a series ASIN
+ 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);
+ if (audnexus == null) continue;
+
+ final primary = audnexus['seriesPrimary'] as Map<String, dynamic>?;
+ if (primary != null && primary['asin'] != null) {
+ seriesAsin = primary['asin'] as String;
+ break;
+ }
+ final secondary = audnexus['seriesSecondary'] as Map<String, dynamic>?;
+ if (secondary != null && secondary['asin'] != null) {
+ seriesAsin = secondary['asin'] as String;
+ break;
+ }
+ }
+
+ // If no book has an ASIN, try searching Audible for the first book to get one
+ if (seriesAsin == null && _books.isNotEmpty) {
+ final firstBook = _books.first;
+ final media = firstBook['media'] as Map<String, dynamic>? ?? {};
+ final metadata = media['metadata'] as Map<String, dynamic>? ?? {};
+ final title = metadata['title'] as String? ?? '';
+ final author = metadata['authorName'] as String? ?? '';
+
+ 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);
+ for (final r in results) {
+ final asin = r['asin'] as String? ?? '';
+ if (asin.isEmpty) continue;
+ final audnexus = await ApiService.getAudnexusBook(asin);
+ if (audnexus == null) continue;
+ final primary = audnexus['seriesPrimary'] as Map<String, dynamic>?;
+ if (primary != null && primary['asin'] != null) {
+ seriesAsin = primary['asin'] as String;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!mounted) return;
+
+ if (seriesAsin == null) {
+ ScaffoldMessenger.of(context).showSnackBar(
+ const SnackBar(content: Text('Could not find this series on Audible')),
+ );
+ return;
+ }
+
+ showAudibleSeriesSheet(context,
+ seriesName: widget.seriesName,
+ seriesAsin: seriesAsin,
+ ownedTitles: ownedTitles,
+ ownedAsins: ownedAsins,
+ );
+ }
+
Widget _buildOverflowMenu(ColorScheme cs) {
final allDone = _allFinished;
final dl = DownloadService();
@@ -673,6 +759,8 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
await lib.toggleRollingDownload(widget.seriesId!);
setState(() => _autoDownloadEnabled = lib.isRollingDownloadEnabled(widget.seriesId!));
}),
+ _moreItem(cs, Icons.search_rounded, 'Find Missing Books',
+ onTap: () { Navigator.pop(ctx); _findOnAudible(); }),
]),
),
);
diff --git a/pubspec.lock b/pubspec.lock
index a53cf918..49089619 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -109,10 +109,10 @@ packages:
dependency: transitive
description:
name: characters
- sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
+ sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
url: "https://pub.dev"
source: hosted
- version: "1.4.1"
+ version: "1.4.0"
checked_yaml:
dependency: transitive
description:
@@ -359,10 +359,10 @@ packages:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
- sha256: ee8068e0e1cd16c4a82714119918efdeed33b3ba7772c54b5d094ab53f9b7fd1
+ sha256: c2fe1001710127dfa7da89977a08d591398370d099aacdaa6d44da7eb14b8476
url: "https://pub.dev"
source: hosted
- version: "2.0.33"
+ version: "2.0.31"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -457,10 +457,10 @@ packages:
dependency: transitive
description:
name: json_annotation
- sha256: cb09e7dac6210041fad964ed7fbee004f14258b4eca4040f72d1234062ace4c8
+ sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
url: "https://pub.dev"
source: hosted
- version: "4.11.0"
+ version: "4.9.0"
just_audio:
dependency: "direct main"
description:
@@ -488,26 +488,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
- sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
+ sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
url: "https://pub.dev"
source: hosted
- version: "11.0.2"
+ version: "10.0.9"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
- sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
+ sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
url: "https://pub.dev"
source: hosted
- version: "3.0.10"
+ version: "3.0.9"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
- sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
+ sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
- version: "3.0.2"
+ version: "3.0.1"
lints:
dependency: transitive
description:
@@ -544,18 +544,18 @@ packages:
dependency: transitive
description:
name: matcher
- sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
+ sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
url: "https://pub.dev"
source: hosted
- version: "0.12.18"
+ version: "0.12.17"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
- sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
+ sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
- version: "0.13.0"
+ version: "0.11.1"
material_design_icons_flutter:
dependency: "direct main"
description:
@@ -568,10 +568,10 @@ packages:
dependency: transitive
description:
name: meta
- sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
+ sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
url: "https://pub.dev"
source: hosted
- version: "1.17.0"
+ version: "1.16.0"
mime:
dependency: transitive
description:
@@ -648,18 +648,18 @@ packages:
dependency: transitive
description:
name: path_provider_android
- sha256: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e
+ sha256: "3b4c1fc3aa55ddc9cd4aa6759984330d5c8e66aa7702a6223c61540dc6380c37"
url: "https://pub.dev"
source: hosted
- version: "2.2.22"
+ version: "2.2.19"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
- sha256: "6d13aece7b3f5c5a9731eaf553ff9dcbc2eff41087fd2df587fd0fed9a3eb0c4"
+ sha256: "16eef174aacb07e09c351502740fa6254c165757638eba1e9116b0a781201bbd"
url: "https://pub.dev"
source: hosted
- version: "2.5.1"
+ version: "2.4.2"
path_provider_linux:
dependency: transitive
description:
@@ -824,26 +824,26 @@ packages:
dependency: "direct main"
description:
name: shared_preferences
- sha256: "2939ae520c9024cb197fc20dee269cd8cdbf564c8b5746374ec6cacdc5169e64"
+ sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5"
url: "https://pub.dev"
source: hosted
- version: "2.5.4"
+ version: "2.5.3"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
- sha256: cbc40be9be1c5af4dab4d6e0de4d5d3729e6f3d65b89d21e1815d57705644a6f
+ sha256: bd14436108211b0d4ee5038689a56d4ae3620fd72fd6036e113bf1345bc74d9e
url: "https://pub.dev"
source: hosted
- version: "2.4.20"
+ version: "2.4.13"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
- sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f"
+ sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03"
url: "https://pub.dev"
source: hosted
- version: "2.5.6"
+ version: "2.5.4"
shared_preferences_linux:
dependency: transitive
description:
@@ -901,10 +901,10 @@ packages:
dependency: transitive
description:
name: source_span
- sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab"
+ sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
url: "https://pub.dev"
source: hosted
- version: "1.10.2"
+ version: "1.10.1"
sqflite:
dependency: transitive
description:
@@ -917,10 +917,10 @@ packages:
dependency: transitive
description:
name: sqflite_android
- sha256: ecd684501ebc2ae9a83536e8b15731642b9570dc8623e0073d227d0ee2bfea88
+ sha256: "2b3070c5fa881839f8b402ee4a39c1b4d561704d4ebbbcfb808a119bc2a1701b"
url: "https://pub.dev"
source: hosted
- version: "2.4.2+2"
+ version: "2.4.1"
sqflite_common:
dependency: transitive
description:
@@ -989,10 +989,10 @@ packages:
dependency: transitive
description:
name: test_api
- sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
+ sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
url: "https://pub.dev"
source: hosted
- version: "0.7.9"
+ version: "0.7.4"
timezone:
dependency: transitive
description:
@@ -1029,18 +1029,18 @@ packages:
dependency: transitive
description:
name: url_launcher_android
- sha256: "767344bf3063897b5cf0db830e94f904528e6dd50a6dfaf839f0abf509009611"
+ sha256: "81777b08c498a292d93ff2feead633174c386291e35612f8da438d6e92c4447e"
url: "https://pub.dev"
source: hosted
- version: "6.3.28"
+ version: "6.3.20"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
- sha256: "580fe5dfb51671ae38191d316e027f6b76272b026370708c2d898799750a02b0"
+ sha256: d80b3f567a617cb923546034cc94bfe44eb15f989fe670b37f26abdb9d939cb7
url: "https://pub.dev"
source: hosted
- version: "6.4.1"
+ version: "6.3.4"
url_launcher_linux:
dependency: transitive
description:
@@ -1053,10 +1053,10 @@ packages:
dependency: transitive
description:
name: url_launcher_macos
- sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18"
+ sha256: c043a77d6600ac9c38300567f33ef12b0ef4f4783a2c1f00231d2b1941fea13f
url: "https://pub.dev"
source: hosted
- version: "3.2.5"
+ version: "3.2.3"
url_launcher_platform_interface:
dependency: transitive
description:
@@ -1069,10 +1069,10 @@ packages:
dependency: transitive
description:
name: url_launcher_web
- sha256: d0412fcf4c6b31ecfdb7762359b7206ffba3bbffd396c6d9f9c4616ece476c1f
+ sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2"
url: "https://pub.dev"
source: hosted
- version: "2.4.2"
+ version: "2.4.1"
url_launcher_windows:
dependency: transitive
description:
@@ -1093,10 +1093,10 @@ packages:
dependency: transitive
description:
name: vector_math
- sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
+ sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
- version: "2.2.0"
+ version: "2.1.4"
vibration:
dependency: "direct main"
description:
@@ -1117,10 +1117,10 @@ packages:
dependency: transitive
description:
name: vm_service
- sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60"
+ sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
url: "https://pub.dev"
source: hosted
- version: "15.0.2"
+ version: "15.0.0"
wakelock_plus:
dependency: "direct main"
description:
@@ -1133,10 +1133,10 @@ packages:
dependency: transitive
description:
name: wakelock_plus_platform_interface
- sha256: "24b84143787220a403491c2e5de0877fbbb87baf3f0b18a2a988973863db4b03"
+ sha256: "036deb14cd62f558ca3b73006d52ce049fabcdcb2eddfe0bf0fe4e8a943b5cf2"
url: "https://pub.dev"
source: hosted
- version: "1.4.0"
+ version: "1.3.0"
web:
dependency: transitive
description:
@@ -1157,10 +1157,10 @@ packages:
dependency: transitive
description:
name: webview_flutter_android
- sha256: "2a03df01df2fd30b075d1e7f24c28aee593f2e5d5ac4c3c4283c5eda63717b24"
+ sha256: "9a25f6b4313978ba1c2cda03a242eea17848174912cfb4d2d8ee84a556f248e3"
url: "https://pub.dev"
source: hosted
- version: "4.10.13"
+ version: "4.10.1"
webview_flutter_platform_interface:
dependency: transitive
description:
@@ -1173,10 +1173,10 @@ packages:
dependency: transitive
description:
name: webview_flutter_wkwebview
- sha256: "2df8fd9ada04d699b9db8e79aa783a16e5d89b69e5b74009b87e16b59912cf98"
+ sha256: fb46db8216131a3e55bcf44040ca808423539bc6732e7ed34fb6d8044e3d512f
url: "https://pub.dev"
source: hosted
- version: "3.24.0"
+ version: "3.23.0"
win32:
dependency: transitive
description:
@@ -1226,5 +1226,5 @@ packages:
source: hosted
version: "3.1.3"
sdks:
- dart: ">=3.10.0 <4.0.0"
- flutter: ">=3.38.0"
+ dart: ">=3.8.0 <4.0.0"
+ flutter: ">=3.32.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 352dc184..057b66de 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,7 +1,7 @@
name: absorb
description: An Audiobookshelf Client
publish_to: 'none'
-version: 1.8.59+76
+version: 1.8.60+77
# 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)