@@ -285,18 +285,31 @@ class AnnasArchieve {
285285 // _bookInfoParser FUNCTION (Detail Page - Fixed 'unable to get data' error)
286286 // --------------------------------------------------------------------
287287 Future <BookInfoData ?> _bookInfoParser (
288- resData, url, String currentBaseUrl) async {
288+ resData, url, String currentBaseUrl, String ? donationKey ) async {
289289 var document = parse (resData.toString ());
290290 final main = document.querySelector ('div.main-inner' );
291291 if (main == null ) return null ;
292292
293293 // --- Mirror Link Extraction ---
294294 String ? mirror;
295- final slowDownloadLinks =
296- main.querySelectorAll ('ul.list-inside a[href*="/slow_download/"]' );
297- if (slowDownloadLinks.isNotEmpty &&
298- slowDownloadLinks.first.attributes['href' ] != null ) {
299- mirror = currentBaseUrl + slowDownloadLinks.first.attributes['href' ]! ;
295+
296+ if (donationKey != null && donationKey.isNotEmpty) {
297+ final fastDownloadLinks =
298+ main.querySelectorAll ('ul.list-inside a[href*="/fast_download/"]' );
299+ if (fastDownloadLinks.isNotEmpty &&
300+ fastDownloadLinks.first.attributes['href' ] != null ) {
301+ mirror =
302+ "$currentBaseUrl ${fastDownloadLinks .first .attributes ['href' ]!}?key=$donationKey " ;
303+ }
304+ }
305+
306+ if (mirror == null ) {
307+ final slowDownloadLinks =
308+ main.querySelectorAll ('ul.list-inside a[href*="/slow_download/"]' );
309+ if (slowDownloadLinks.isNotEmpty &&
310+ slowDownloadLinks.first.attributes['href' ] != null ) {
311+ mirror = currentBaseUrl + slowDownloadLinks.first.attributes['href' ]! ;
312+ }
300313 }
301314 // --------------------------------
302315
@@ -487,7 +500,8 @@ class AnnasArchieve {
487500 }
488501 }
489502
490- Future <BookInfoData > bookInfo ({required String url}) async {
503+ Future <BookInfoData > bookInfo (
504+ {required String url, String ? donationKey}) async {
491505 _logger.info ('Fetching book info' ,
492506 tag: 'AnnasArchive' , metadata: {'url' : url});
493507
@@ -524,8 +538,8 @@ class AnnasArchieve {
524538 );
525539 }
526540
527- BookInfoData ? data =
528- await _bookInfoParser ( response.data, adjustedUrl, currentBaseUrl);
541+ BookInfoData ? data = await _bookInfoParser (
542+ response.data, adjustedUrl, currentBaseUrl, donationKey );
529543 if (data != null ) {
530544 return data;
531545 } else {
0 commit comments