mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-06-06 05:49:03 +08:00
Add new API
This commit is contained in:
@@ -248,6 +248,12 @@ abstract class _EHApi {
|
||||
Future<ApiResult<GMetaInfos>> _getGalleriesMeta(@Path("gids") String gids,
|
||||
// ignore: unused_element
|
||||
{@CancelRequest() CancelToken? cancel});
|
||||
@GET('/gallery/thumbnail/{gids}')
|
||||
// ignore: unused_element
|
||||
Future<ApiResult<GalleryThumbnails>> _getGalleriesThumbnail(
|
||||
@Path("gids") String gids,
|
||||
// ignore: unused_element
|
||||
{@CancelRequest() CancelToken? cancel});
|
||||
@GET('/gallery/list')
|
||||
Future<ApiResult<List<GMeta>>> listGalleries(
|
||||
{@Query("all") bool? all,
|
||||
@@ -455,6 +461,11 @@ class EHApi extends __EHApi {
|
||||
return _getGalleriesMeta(gids.join(","), cancel: cancel);
|
||||
}
|
||||
|
||||
Future<ApiResult<GalleryThumbnails>> getGalleriesThumbnail(List<int> gids,
|
||||
{CancelToken? cancel}) {
|
||||
return _getGalleriesThumbnail(gids.join(","), cancel: cancel);
|
||||
}
|
||||
|
||||
Future<ApiResult<Tags>> getTags(List<int> ids, {CancelToken? cancel}) {
|
||||
return _getTags(ids.join(","), cancel: cancel);
|
||||
}
|
||||
|
||||
@@ -1174,6 +1174,47 @@ class __EHApi implements _EHApi {
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ApiResult<GalleryThumbnails>> _getGalleriesThumbnail(
|
||||
String gids, {
|
||||
CancelToken? cancel,
|
||||
}) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
queryParameters.removeWhere((k, v) => v == null);
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _options = _setStreamType<ApiResult<GalleryThumbnails>>(Options(
|
||||
method: 'GET',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/gallery/thumbnail/${gids}',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
cancelToken: cancel,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
)));
|
||||
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
|
||||
late ApiResult<GalleryThumbnails> _value;
|
||||
try {
|
||||
_value = ApiResult<GalleryThumbnails>.fromJson(
|
||||
_result.data!,
|
||||
(json) => GalleryThumbnails.fromJson(json as Map<String, dynamic>),
|
||||
);
|
||||
} on Object catch (e, s) {
|
||||
errorLogger?.logError(e, s, _options);
|
||||
rethrow;
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ApiResult<List<GMeta>>> listGalleries({
|
||||
bool? all,
|
||||
|
||||
@@ -237,3 +237,18 @@ class GMetaSearchInfo {
|
||||
: titleJpn
|
||||
: title;
|
||||
}
|
||||
|
||||
class GalleryThumbnails {
|
||||
const GalleryThumbnails({
|
||||
required this.thumbnails,
|
||||
});
|
||||
final Map<int, ApiResult<ExtendedPMeta>> thumbnails;
|
||||
factory GalleryThumbnails.fromJson(Map<String, dynamic> json) =>
|
||||
GalleryThumbnails(
|
||||
thumbnails: json.map((key, value) => MapEntry(
|
||||
int.parse(key),
|
||||
ApiResult<ExtendedPMeta>.fromJson(
|
||||
value as Map<String, dynamic>,
|
||||
(json) =>
|
||||
ExtendedPMeta.fromJson(json as Map<String, dynamic>)))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user