Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5f830f5
Add Bindery metadata discovery API and book request models (#16)
koinupapi Nov 28, 2026
aa21518
Add Bindery author addition options and defaults API (#16)
koinupapi Nov 28, 2026
32fefae
Connect native Bindery discovery search and addition screens (#16)
koinupapi Nov 28, 2026
d561399
Integrate compact library toolbar, counts and contextual FABs (#16 #2…
koinupapi Nov 28, 2026
d60d8e7
Add linked series discovery and refresh library after additions (#16)
koinupapi Nov 28, 2026
2d51165
Display metadata and proxied artwork in Bindery discovery (#16)
koinupapi Nov 28, 2026
26399e3
Add author profile and root folder selectors (#16)
koinupapi Nov 28, 2026
34a9ce7
Show configured monitoring defaults and refresh after format expansio…
koinupapi Nov 28, 2026
b58f9f3
Guard discovery additions and test default request semantics (#16)
koinupapi Nov 28, 2026
3b0bd92
Correct addition result type and cover discovery navigation and serie…
koinupapi Nov 28, 2026
f1ac5cd
Label configured profile defaults and guard result context (#16)
koinupapi Nov 28, 2026
29b18b8
Validate combined Bindery discovery milestone (#16 #28 #29 #30) [buil…
koinupapi Nov 28, 2026
2075090
Align Bindery search and segmented navigation with Sonarr (#16 #30)
koinupapi Nov 28, 2026
027656f
Adapt Sonarr result cards and configuration sheet for Bindery (#16)
koinupapi Nov 28, 2026
f1488d9
Use existing Radarr choice-chip filter sheet pattern for Bindery (#30)
koinupapi Nov 28, 2026
8112b08
Review Bindery search state and navigation refinements (#16 #30)
koinupapi Nov 28, 2026
810bd64
Validate and build Bindery UI refinements (#16 #28 #29 #30) [build apk]
koinupapi Nov 28, 2026
08270f8
Fix filter sheet closing delimiters and detail widget key (#30) [buil…
koinupapi Nov 28, 2026
dd62efd
Extract Bindery filter sheet into explicit builder method (#30) [buil…
koinupapi Nov 28, 2026
1ed946c
Align existing widget test with Discover search toolbar (#16 #30) [bu…
koinupapi Nov 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/validate-ae/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ runs:
working-directory: app
run: |
dart analyze lib
flutter test test/add_instance_flow_test.dart test/instance_serialization_test.dart test/bindery_brand_icon_test.dart test/bindery_library_api_test.dart test/bindery_library_screen_test.dart
flutter test test/add_instance_flow_test.dart test/instance_serialization_test.dart test/bindery_brand_icon_test.dart test/bindery_library_api_test.dart test/bindery_library_screen_test.dart test/bindery_discovery_api_test.dart
- if: inputs.suite == 'all' || inputs.suite == 'bindery'
shell: bash
working-directory: packages/core_models
Expand Down
112 changes: 112 additions & 0 deletions app/lib/src/bindery/discovery_api.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import 'package:dio/dio.dart';

import 'library_api.dart';

/// Metadata identifiers are not local database IDs.
class BinderyDiscoveryResult {
BinderyDiscoveryResult(this.kind, this.data) {
if (foreignId.isEmpty || title.isEmpty) {
throw const FormatException('Invalid metadata result');
}
}
final BinderyCollection kind;
final Map<String, dynamic> data;
String get foreignId => kind == BinderyCollection.series ? _string('foreignId') : _string(kind == BinderyCollection.author
? 'foreignAuthorId' : 'foreignBookId');
String get title => _string(kind == BinderyCollection.author
? 'authorName' : 'title');
String get image => _string('imageUrl');
String get _libraryKey => kind == BinderyCollection.author
? 'libraryAuthorId' : 'libraryBookId';
int? get libraryId => kind == BinderyCollection.series ? null : data[_libraryKey] is int ? data[_libraryKey] as int : null;
String _string(String key) => data[key] is String ? data[key] as String : '';
Map<String, dynamic> authorRequest({
required bool searchOnAdd,
String? mediaType,
String? monitorMode,
int? monitorLatestCount,
String? monitorNewItems,
int? metadataProfileId,
int? rootFolderId,
int? audiobookRootFolderId,
int? qualityProfileId,
bool qualityProfileChanged = false,
}) {
if (kind != BinderyCollection.author) throw StateError('Not an author');
return {
'foreignAuthorId': foreignId,
'authorName': title,
'monitored': true,
'searchOnAdd': searchOnAdd,
if (mediaType != null) 'mediaType': mediaType,
if (monitorMode != null) 'monitorMode': monitorMode,
if (monitorLatestCount != null) 'monitorLatestCount': monitorLatestCount,
if (monitorNewItems != null) 'monitorNewItems': monitorNewItems,
if (metadataProfileId != null) 'metadataProfileId': metadataProfileId,
if (rootFolderId != null) 'rootFolderId': rootFolderId,
if (audiobookRootFolderId != null) 'audiobookRootFolderId': audiobookRootFolderId,
if (qualityProfileChanged) 'qualityProfileId': qualityProfileId,
};
}
Map<String, dynamic> bookRequest({String mediaType = '', required bool searchOnAdd}) {
if (kind != BinderyCollection.book) throw StateError('Not a book');
final author = data['author'];
return {
'foreignBookId': foreignId,
'foreignAuthorId': author is Map ? author['foreignAuthorId'] ?? '' : '',
'authorName': author is Map ? author['authorName'] ?? '' : '',
'searchOnAdd': searchOnAdd,
if (mediaType.isNotEmpty) 'mediaType': mediaType,
};
}
}

class BinderyDiscoveryApi {
BinderyDiscoveryApi(this.dio);
final Dio dio;
Future<List<BinderyDiscoveryResult>> search(BinderyCollection kind, String term) async {
if (term.trim().isEmpty) return [];
final response = await dio.get<dynamic>(kind == BinderyCollection.series ? 'api/v1/series/hardcover/search' : 'api/v1/search/${kind.name}',
queryParameters: {'term': term.trim()});
final rows = response.data;
if (rows is! List) throw const FormatException('Invalid metadata response');
return rows.map((row) {
if (row is! Map) throw const FormatException('Invalid metadata row');
return BinderyDiscoveryResult(kind, Map<String, dynamic>.from(row));
}).toList();
}
Future<BinderyItem> addSeries(BinderyDiscoveryResult result) async {
if (result.kind != BinderyCollection.series) throw ArgumentError('Not a series');
final response = await dio.post<dynamic>('api/v1/series', data: {
'hardcover': {for (final key in ['foreignId', 'providerId', 'slug', 'title', 'authorName', 'bookCount']) if (result.data.containsKey(key)) key: result.data[key]},
});
return BinderyItem(BinderyCollection.series, Map<String, dynamic>.from(response.data as Map));
}
Future<String?> setting(String key) async {
final response = await dio.get<dynamic>('api/v1/setting/$key');
final data = response.data;
if (data is! Map) throw const FormatException('Invalid setting');
return data['value']?.toString();
}
Future<List<Map<String, dynamic>>> profiles(String resource) async {
if (!['metadataprofile', 'qualityprofile', 'rootfolder'].contains(resource)) {
throw ArgumentError('Unsupported profile resource');
}
final response = await dio.get<dynamic>('api/v1/$resource');
if (response.data is! List) throw const FormatException('Invalid profile list');
return (response.data as List).map((row) => Map<String, dynamic>.from(row as Map)).toList();
}
Future<BinderyItem> addAuthor(Map<String, dynamic> request) async {
final response = await dio.post<dynamic>('api/v1/author', data: request);
if (response.data is! Map) throw const FormatException('Invalid added author');
return BinderyItem(BinderyCollection.author, Map<String, dynamic>.from(response.data as Map));
}
Future<BinderyItem> addBook(BinderyDiscoveryResult result, {
String mediaType = '', required bool searchOnAdd,
}) async {
final response = await dio.post<dynamic>('api/v1/author/book',
data: result.bookRequest(mediaType: mediaType, searchOnAdd: searchOnAdd));
if (response.data is! Map) throw const FormatException('Invalid added book');
return BinderyItem(BinderyCollection.book, Map<String, dynamic>.from(response.data as Map));
}
}
Loading
Loading