-
Notifications
You must be signed in to change notification settings - Fork 41
/
eh_bookmark.dart
51 lines (40 loc) · 1.42 KB
/
eh_bookmark.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// This source code is a part of Project Violet.
// Copyright (C) 2020-2024. violet-team. Licensed under the Apache-2.0 License.
import 'dart:collection';
import 'package:html/parser.dart';
import 'package:violet/component/eh/eh_headers.dart';
import 'package:violet/util/helper.dart';
class EHBookmark {
static List<HashSet<int>>? bookmarkInfo;
static Future<List<HashSet<int>>> process() async {
// https://e-hentai.org/favorites.php?page=0&favcat=0
// https://exhentai.org/favorites.php?page=0&favcat=0
var result = <HashSet<int>>[];
const candidateHosts = [
'https://exhentai.org',
'https://e-hentai.org',
];
for (final host in candidateHosts) {
for (int i = 0; i < 10; i++) {
var bookmark = HashSet<int>();
await catchUnwind(() async {
for (int j = 0; j < 1000; j++) {
final html = await EHSession.requestString(
'$host/favorites.php?favcat=$i&page=$j');
final prev = bookmark.length;
parse(html).querySelectorAll('a[href*="/g/"]').forEach((element) {
final href = element.attributes['href'];
if (href == null) return;
bookmark.add(int.parse((href.split('/')[4])));
});
if (prev == bookmark.length) {
break;
}
}
});
result.add(bookmark);
}
}
return bookmarkInfo = result;
}
}