@@ -49,6 +49,7 @@ import '../../model/tag_set.dart';
49
49
import '../../service/history_service.dart' ;
50
50
import '../../service/gallery_download_service.dart' ;
51
51
import '../../service/storage_service.dart' ;
52
+ import '../../setting/eh_setting.dart' ;
52
53
import '../../setting/read_setting.dart' ;
53
54
import '../../utils/process_util.dart' ;
54
55
import '../../utils/route_util.dart' ;
@@ -720,24 +721,35 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
720
721
}
721
722
722
723
Future <Map <String , dynamic >> _getDetailsWithRedirectAndFallback ({bool useCache = true }) async {
723
- final String firstLink;
724
+ final String ? firstLink;
724
725
final String secondLink;
725
726
726
- /// 1. Try EH site first for EX link
727
+ /// 1. if redirect is enabled, try EH site first for EX link
727
728
/// 2. if a gallery can't be found in EH site, it may be moved into EX site
728
- if (state.galleryUrl.contains (EHConsts .EXIndex ) && ! _galleryOnlyInExSite ()) {
729
- firstLink = state.galleryUrl.replaceFirst (EHConsts .EXIndex , EHConsts .EHIndex );
730
- secondLink = state.galleryUrl;
729
+ if (state.galleryUrl.contains (EHConsts .EXIndex )) {
730
+ if (EHSetting .redirect2Eh.isTrue) {
731
+ firstLink = state.galleryUrl.replaceFirst (EHConsts .EXIndex , EHConsts .EHIndex );
732
+ secondLink = state.galleryUrl;
733
+ } else {
734
+ firstLink = null ;
735
+ secondLink = state.galleryUrl;
736
+ }
731
737
} else {
732
- firstLink = state.galleryUrl;
733
- secondLink = state.galleryUrl.replaceFirst (EHConsts .EHIndex , EHConsts .EXIndex );
738
+ if (_galleryOnlyInExSite ()) {
739
+ firstLink = null ;
740
+ secondLink = state.galleryUrl.replaceFirst (EHConsts .EHIndex , EHConsts .EXIndex );
741
+ } else {
742
+ firstLink = state.galleryUrl;
743
+ secondLink = state.galleryUrl.replaceFirst (EHConsts .EHIndex , EHConsts .EXIndex );
744
+ }
734
745
}
735
746
736
747
/// if we can't find gallery via firstLink, try second link
737
748
if (! isEmptyOrNull (firstLink)) {
749
+ Log .verbose ('Try to find gallery via firstLink: $firstLink ' );
738
750
try {
739
751
Map <String , dynamic > galleryAndDetailAndApikey = await EHRequest .requestDetailPage <Map <String , dynamic >>(
740
- galleryUrl: firstLink,
752
+ galleryUrl: firstLink! ,
741
753
parser: EHSpiderParser .detailPage2GalleryAndDetailAndApikey,
742
754
useCacheIfAvailable: useCache,
743
755
);
@@ -749,6 +761,7 @@ class DetailsPageLogic extends GetxController with LoginRequiredMixin, Scroll2To
749
761
}
750
762
751
763
try {
764
+ Log .verbose ('Try to find gallery via secondLink: $secondLink ' );
752
765
Map <String , dynamic > galleryAndDetailAndApikey = await EHRequest .requestDetailPage <Map <String , dynamic >>(
753
766
galleryUrl: secondLink,
754
767
parser: EHSpiderParser .detailPage2GalleryAndDetailAndApikey,
0 commit comments