Skip to content

Commit

Permalink
Adapt to the change that users can no longer view the ranking data of…
Browse files Browse the repository at this point in the history
… galleries uploaded by others

适配E站不再能查看非本人上传画廊的排行数据的变动
  • Loading branch information
jiangtian616 committed Nov 2, 2024
1 parent 9e68c8d commit fb16434
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
4 changes: 3 additions & 1 deletion changelog/v8.0.5+267.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
- 优化搜索标签提示
- 适配E站不再能查看非本人上传画廊的排行数据的变动

--------------------

- Optimize the search tag prompt
- Optimize the search tag prompt
- Adapt to the change that users can no longer view the ranking data of galleries uploaded by others
19 changes: 10 additions & 9 deletions lib/src/utils/eh_spider_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -806,22 +806,23 @@ class EHSpiderParser {
static GalleryStats statPage2GalleryStats(Headers headers, dynamic data) {
Document document = parse(data as String);

Element rankScoreTbody = document.querySelector('.stuffbox > table > tbody')!;
/// Ranking is only available for owner
Element? rankScoreTbody = document.querySelector('.stuffbox > table > tbody');
List<Element> graphs = document.querySelectorAll('#graphs > div');
Element yearlyStatTbody = graphs[2].querySelector('table > tbody')!;
Element monthlyStatTbody = graphs[1].querySelector('table > tbody')!;
Element dailyStatTbody = graphs[0].querySelector('table > tbody')!;

return GalleryStats(
totalVisits: int.parse(document.querySelector('.stuffbox > p > strong')!.text.replaceAll(',', '')),
allTimeRanking: int.tryParse(rankScoreTbody.querySelector('tr:nth-child(2) > td:nth-child(4)')?.text.replaceAll(',', '') ?? ''),
allTimeScore: int.tryParse(rankScoreTbody.querySelector('tr:nth-child(2) > td:nth-child(5)')?.text.replaceAll(',', '') ?? ''),
yearRanking: int.tryParse(rankScoreTbody.querySelector('tr:nth-child(4) > td:nth-child(4)')?.text.replaceAll(',', '') ?? ''),
yearScore: int.tryParse(rankScoreTbody.querySelector('tr:nth-child(4) > td:nth-child(5)')?.text.replaceAll(',', '') ?? ''),
monthRanking: int.tryParse(rankScoreTbody.querySelector('tr:nth-child(6) > td:nth-child(4)')?.text.replaceAll(',', '') ?? ''),
monthScore: int.tryParse(rankScoreTbody.querySelector('tr:nth-child(6) > td:nth-child(5)')?.text.replaceAll(',', '') ?? ''),
dayRanking: int.tryParse(rankScoreTbody.querySelector('tr:nth-child(8) > td:nth-child(4)')?.text.replaceAll(',', '') ?? ''),
dayScore: int.tryParse(rankScoreTbody.querySelector('tr:nth-child(8) > td:nth-child(5)')?.text.replaceAll(',', '') ?? ''),
allTimeRanking: int.tryParse(rankScoreTbody?.querySelector('tr:nth-child(2) > td:nth-child(4)')?.text.replaceAll(',', '') ?? ''),
allTimeScore: int.tryParse(rankScoreTbody?.querySelector('tr:nth-child(2) > td:nth-child(5)')?.text.replaceAll(',', '') ?? ''),
yearRanking: int.tryParse(rankScoreTbody?.querySelector('tr:nth-child(4) > td:nth-child(4)')?.text.replaceAll(',', '') ?? ''),
yearScore: int.tryParse(rankScoreTbody?.querySelector('tr:nth-child(4) > td:nth-child(5)')?.text.replaceAll(',', '') ?? ''),
monthRanking: int.tryParse(rankScoreTbody?.querySelector('tr:nth-child(6) > td:nth-child(4)')?.text.replaceAll(',', '') ?? ''),
monthScore: int.tryParse(rankScoreTbody?.querySelector('tr:nth-child(6) > td:nth-child(5)')?.text.replaceAll(',', '') ?? ''),
dayRanking: int.tryParse(rankScoreTbody?.querySelector('tr:nth-child(8) > td:nth-child(4)')?.text.replaceAll(',', '') ?? ''),
dayScore: int.tryParse(rankScoreTbody?.querySelector('tr:nth-child(8) > td:nth-child(5)')?.text.replaceAll(',', '') ?? ''),
yearlyStats: _parseStats(yearlyStatTbody),
monthlyStats: _parseStats(monthlyStatTbody),
dailyStats: _parseStats(dailyStatTbody),
Expand Down
5 changes: 5 additions & 0 deletions lib/src/widget/eh_gallery_stat_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ class _EHGalleryStatDialogState extends State<EHGalleryStatDialog> {
snack('getGalleryStatisticsFailed'.tr, e.message);
setStateSafely(() => loadingState = LoadingState.error);
return;
} catch (e) {
log.error('getGalleryStatisticsFailed'.tr, e.toString());
snack('getGalleryStatisticsFailed'.tr, e.toString());
setStateSafely(() => loadingState = LoadingState.error);
return;
}

if (mounted) {
Expand Down
22 changes: 11 additions & 11 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -929,18 +929,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.7"
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.8"
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -1499,7 +1499,7 @@ packages:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
version: "0.0.99"
smart_auth:
dependency: transitive
description:
Expand Down Expand Up @@ -1592,10 +1592,10 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
Expand All @@ -1616,10 +1616,10 @@ packages:
dependency: transitive
description:
name: string_scanner
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.2.0"
syncfusion_flutter_charts:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1929,10 +1929,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.3.0"
version: "14.2.5"
wakelock_plus:
dependency: "direct main"
description:
Expand Down

0 comments on commit fb16434

Please sign in to comment.