Skip to content

Commit c25219d

Browse files
committed
skip hyrdus check and only check rating:safe on donmai
1 parent b159934 commit c25219d

File tree

7 files changed

+474
-409
lines changed

7 files changed

+474
-409
lines changed

.vscode/launch.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "loliSnatcher",
9+
"request": "launch",
10+
"type": "dart"
11+
},
12+
{
13+
"name": "loliSnatcher (play store)",
14+
"request": "launch",
15+
"type": "dart",
16+
"flutterMode": "profile",
17+
"args": [
18+
"--dart-define=LS_IS_STORE=true"
19+
]
20+
},
21+
{
22+
"name": "loliSnatcher (profile mode)",
23+
"request": "launch",
24+
"type": "dart",
25+
"flutterMode": "profile"
26+
},
27+
{
28+
"name": "loliSnatcher (release mode)",
29+
"request": "launch",
30+
"type": "dart",
31+
"flutterMode": "release"
32+
}
33+
]
34+
}

analysis_options.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ linter:
3434
prefer_is_empty: true
3535
non_constant_identifier_names: true
3636
overridden_fields: true
37-
avoid_print: false # Uncomment to disable the `avoid_print` rule
38-
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
3937
file_names: true # .dart files should use 'lowercase_with_underscores' naming scheme
4038
always_use_package_imports: true
4139
unawaited_futures: true
4240
use_build_context_synchronously: false
41+
require_trailing_commas: true
4342

4443
# analyzer:
4544
# language:

lib/src/boorus/danbooru_handler.dart

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class DanbooruHandler extends BooruHandler {
2929

3030
@override
3131
String validateTags(String tags) {
32-
if (tags.toLowerCase().contains('rating:safe')) {
32+
if (tags.toLowerCase().contains('rating:safe') &&
33+
booru.baseURL!.contains('danbooru.donmai.us')) {
3334
tags = tags.toLowerCase().replaceAll('rating:safe', 'rating:general');
3435
}
3536
return tags;
@@ -57,16 +58,25 @@ class DanbooruHandler extends BooruHandler {
5758
*/
5859
if (current.containsKey("file_url")) {
5960
if ((current["file_url"].length > 0)) {
60-
addTagsWithType(current['tag_string_general'].toString().split(" "), TagType.none);
61-
addTagsWithType(current['tag_string_character'].toString().split(" "), TagType.character);
62-
addTagsWithType(current['tag_string_copyright'].toString().split(" "), TagType.copyright);
63-
addTagsWithType(current['tag_string_artist'].toString().split(" "), TagType.artist);
64-
addTagsWithType(current['tag_string_meta'].toString().split(" "), TagType.meta);
61+
addTagsWithType(
62+
current['tag_string_general'].toString().split(" "), TagType.none);
63+
addTagsWithType(current['tag_string_character'].toString().split(" "),
64+
TagType.character);
65+
addTagsWithType(current['tag_string_copyright'].toString().split(" "),
66+
TagType.copyright);
67+
addTagsWithType(
68+
current['tag_string_artist'].toString().split(" "), TagType.artist);
69+
addTagsWithType(
70+
current['tag_string_meta'].toString().split(" "), TagType.meta);
6571

6672
final bool isZip = current['file_url'].toString().endsWith(".zip");
67-
final String? dateStr = current['created_at']?.toString().substring(0, current['created_at']!.toString().length - 6);
73+
final String? dateStr = current['created_at']
74+
?.toString()
75+
.substring(0, current['created_at']!.toString().length - 6);
6876
BooruItem item = BooruItem(
69-
fileURL: isZip ? current["large_file_url"].toString() : current["file_url"].toString(),
77+
fileURL: isZip
78+
? current["large_file_url"].toString()
79+
: current["file_url"].toString(),
7080
sampleURL: current["large_file_url"].toString(),
7181
thumbnailURL: current["preview_file_url"].toString(),
7282
tagsList: current["tag_string"].toString().split(" "),
@@ -82,7 +92,8 @@ class DanbooruHandler extends BooruHandler {
8292
sources: [current["source"].toString()],
8393
md5String: current["md5"].toString(),
8494
postDate: dateStr, // 2021-06-17T16:27:45.743-04:00
85-
postDateFormat: "yyyy-MM-dd't'HH:mm:ss'.'SSSZ", // when timezone support added: "yyyy-MM-dd't'HH:mm:ssZ",
95+
postDateFormat:
96+
"yyyy-MM-dd't'HH:mm:ss'.'SSSZ", // when timezone support added: "yyyy-MM-dd't'HH:mm:ssZ",
8697
);
8798
return item;
8899
} else {
@@ -101,8 +112,10 @@ class DanbooruHandler extends BooruHandler {
101112
@override
102113
String makeURL(String tags) {
103114
// EXAMPLE: https://danbooru.donmai.us/posts.json?tags=rating:safe%20order:rank&limit=20&page=1
104-
final String loginStr = booru.userID?.isNotEmpty == true ? "&login=${booru.userID}" : "";
105-
final String apiKeyStr = booru.apiKey?.isNotEmpty == true ? "&api_key=${booru.apiKey}" : "";
115+
final String loginStr =
116+
booru.userID?.isNotEmpty == true ? "&login=${booru.userID}" : "";
117+
final String apiKeyStr =
118+
booru.apiKey?.isNotEmpty == true ? "&api_key=${booru.apiKey}" : "";
106119
return "${booru.baseURL}/posts.json?tags=$tags&limit=${limit.toString()}&page=${pageNum.toString()}$loginStr$apiKeyStr";
107120
}
108121

@@ -129,7 +142,8 @@ class DanbooruHandler extends BooruHandler {
129142

130143
@override
131144
String? parseTagSuggestion(responseItem, int index) {
132-
final String tagStr = (responseItem['antecedent'] ?? responseItem['value'])?.toString() ?? "";
145+
final String tagStr =
146+
(responseItem['antecedent'] ?? responseItem['value'])?.toString() ?? "";
133147
if (tagStr.isEmpty) return null;
134148

135149
final String rawTagType = responseItem["category"]?.toString() ?? "";
@@ -149,7 +163,9 @@ class DanbooruHandler extends BooruHandler {
149163

150164
@override
151165
CommentItem? parseComment(responseItem, int index) {
152-
final String? dateStr = responseItem['created_at']?.toString().substring(0, responseItem['created_at']!.toString().length - 6);
166+
final String? dateStr = responseItem['created_at']
167+
?.toString()
168+
.substring(0, responseItem['created_at']!.toString().length - 6);
153169
return CommentItem(
154170
id: responseItem["id"].toString(),
155171
title: responseItem["post_id"].toString(),

lib/src/data/constants.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ class Constants {
44
static String appName = "LoliSnatcher";
55
// TODO don't forget to update on every new release
66
// TODO take these from smth like .env?
7-
static String appVersion = "2.3.1";
8-
static int appBuildNumber = 181;
7+
static String appVersion = "2.3.2";
8+
static int appBuildNumber = 182;
99
//
1010

1111
static const int defaultItemLimit = 20;
1212

1313
static const int tagStaleTime = 3 * 24 * 60 * 60 * 1000; // 3 days
1414

15-
static const String discordURL = 'https://discord.gg/pRNcfTEJ';
16-
}
15+
static const String discordURL = 'https://discord.gg/r9E4HDx9dz';
16+
}

0 commit comments

Comments
 (0)