Skip to content

Commit 3ad652c

Browse files
committed
Ascended
1 parent 5eb2583 commit 3ad652c

File tree

13 files changed

+359
-261
lines changed

13 files changed

+359
-261
lines changed

SmartImage.Lib/Clients/Booru/BaseGelbooruClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public virtual async Task<IFlurlResponse> GetPostsAsync(PostsRequest r)
7272
foreach (PropertyInfo p in r.GetType().GetProperties()) {
7373
var o = p.GetValue(r);
7474

75-
if (o == null || o is string s && string.IsNullOrWhiteSpace(s) || o.Equals(0)) {
75+
if (o == null || o is string s && String.IsNullOrWhiteSpace(s) || o.Equals(0)) {
7676
continue;
7777
}
7878

@@ -81,7 +81,7 @@ public virtual async Task<IFlurlResponse> GetPostsAsync(PostsRequest r)
8181
properties.Add(h);
8282
}
8383

84-
var ss = string.Join('&', properties);
84+
var ss = String.Join('&', properties);
8585

8686
return await Client.Request("/index.php?page=post&s=list", ss)
8787
.GetAsync();

SmartImage.Lib/Engines/Impl/Search/IqdbEngine.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,20 @@ private SearchResultItem ParseResult(IHtmlCollection<IElement> tr, SearchResult
172172
string[] wh = res.TextContent.Split(Strings.Constants.MUL_SIGN);
173173

174174
string wStr = wh[0].SelectOnlyDigits();
175-
w = int.Parse(wStr);
175+
w = Int32.Parse(wStr);
176176

177177
// May have NSFW caption, so remove it
178178

179179
string hStr = wh[1].SelectOnlyDigits();
180-
h = int.Parse(hStr);
180+
h = Int32.Parse(hStr);
181181
}
182182

183183
double? sim;
184184

185185
if (tr.Length >= 5) {
186186
var simNode = tr[4];
187187
string simStr = simNode.TextContent.Split('%')[0];
188-
sim = double.Parse(simStr);
188+
sim = Double.Parse(simStr);
189189
sim = Math.Round(sim.Value, 2);
190190
}
191191
else {

SmartImage.Lib/Engines/Impl/Search/SauceNaoEngine.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public sealed class SauceNaoEngine : BaseSearchEngine, IEndpointEngine, IDisposa
5151

5252
public Url EndpointUrl => URL_API;
5353

54-
public bool UsingAPI => !string.IsNullOrWhiteSpace(Authentication);
54+
public bool UsingAPI => !String.IsNullOrWhiteSpace(Authentication);
5555

5656
public string Authentication { get; set; }
5757

@@ -147,7 +147,7 @@ private async ValueTask GetWebResultsAsync(SearchQuery query, SearchResult sr)
147147
.WithTimeout(Timeout)
148148
.PostMultipartAsync(m =>
149149
{
150-
m.AddString("url", query.Source.IsUri ? query.Source.ValueString : string.Empty);
150+
m.AddString("url", query.Source.IsUri ? query.Source.ValueString : String.Empty);
151151
string s;
152152

153153
if (query.Source.IsUri) { }
@@ -274,15 +274,15 @@ private async ValueTask GetAPIResultsAsync(SearchQuery url, SearchResult sr)
274274

275275
foreach (JsonNode t in resultArray) {
276276
var result = t.AsObject();
277-
float similarity = float.Parse(result[KeySimilarity].AsValue().ToString());
277+
float similarity = Single.Parse(result[KeySimilarity].AsValue().ToString());
278278

279279
string[] strings = result.ContainsKey(KeyUrls)
280280
? (result[KeyUrls] as JsonArray)!
281281
.Select(j => j.ToString().CleanString())
282282
.ToArray()
283283
: null;
284284

285-
var index = (SauceNaoSiteIndex) int.Parse(result[KeyIndex].ToString());
285+
var index = (SauceNaoSiteIndex) Int32.Parse(result[KeyIndex].ToString());
286286

287287
foreach (string t1 in strings) {
288288
var item = new SearchResultItem(sr)
@@ -558,7 +558,7 @@ public static SauceNaoDataResult Parse(INode result)
558558
.Where(c => c is not (IElement { TagName: "BR" }
559559
or IElement { NodeName: "SPAN" }))
560560
.ToArray();
561-
float similarity = float.Parse(resultsimilarityinfo.TextContent.Replace("%", string.Empty));
561+
float similarity = Single.Parse(resultsimilarityinfo.TextContent.Replace("%", String.Empty));
562562

563563
// var results = new List<SearchResultItem>();
564564
var urls = links.Where(x =>

SmartImage.Lib/Engines/Impl/Search/TraceMoeEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public TraceMoeDoc()
192192
s1 = s1.Split('|')[0];
193193
}
194194

195-
return long.Parse(s1 ?? string.Empty);
195+
return Int64.Parse(s1 ?? String.Empty);
196196
}).QuickJoin(),
197197

198198
_ => String.Empty

SmartImage.Lib/Engines/Impl/Upload/BaseUploadEngine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,15 @@ protected virtual async Task<UploadResult> ProcessResultAsync(IFlurlResponse res
209209
return new UploadResult
210210
{
211211
Url = url,
212-
Size = response.Headers.TryGetFirst("Content-Length", out var cls) ? long.Parse(cls) : null,
212+
Size = response.Headers.TryGetFirst("Content-Length", out var cls) ? Int64.Parse(cls) : null,
213213
IsValid = ok,
214214
Response = response
215215
};
216216
}
217217

218218
protected void Verify(string file)
219219
{
220-
if (string.IsNullOrWhiteSpace(file)) {
220+
if (String.IsNullOrWhiteSpace(file)) {
221221
throw new ArgumentNullException(nameof(file));
222222
}
223223

SmartImage.Lib/Engines/Impl/Upload/CatboxEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public override async Task<UploadResult> UploadFileAsync(string file, Cancellati
2626
mp.AddFile("fileToUpload", file)
2727
.AddString("reqtype", "fileupload")
2828
.AddString("time", "1h")
29-
.AddString("userhash", string.Empty);
29+
.AddString("userhash", String.Empty);
3030
}, cancellationToken: ct, completionOption: HttpCompletionOption.ResponseHeadersRead);
3131

3232
return await ProcessResultAsync(response, ct).ConfigureAwait(false);

SmartImage.Lib/Utilities/SearchUtil.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,17 @@ public static bool IsError(this SearchResultStatus s)
3030
public static bool HasFlagFast(this SearchResultFlags value, SearchResultFlags status)
3131
=> (value & status) != 0;
3232

33+
[return: MN]
34+
internal static bool TryParseIndex<T>(this IList<T> col, string s, out T val)
35+
{
36+
val = default;
37+
38+
if (Int32.TryParse(s, out var i) && (i < col.Count && i >= 0)) {
39+
val = col[i];
40+
return true;
41+
}
42+
43+
return false;
44+
}
45+
3346
}

0 commit comments

Comments
 (0)