Skip to content

Commit 3014b5c

Browse files
committed
bump to 2.1.8
1 parent 4a26bda commit 3014b5c

File tree

8 files changed

+26
-47
lines changed

8 files changed

+26
-47
lines changed

SmartImage.Lib/Engines/Impl/TidderEngine.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ protected override SearchResult Process(object obj, SearchResult sr)
5353
var authorNode = sub[5];
5454
var subredditNode = sub[6];
5555

56-
5756
//string? dist = distNode.InnerText;
5857
//string? score = scoreNode.InnerText;
5958
string posted = postedNode.TextContent;
@@ -73,17 +72,14 @@ protected override SearchResult Process(object obj, SearchResult sr)
7372
Date = DateTime.Parse(posted)
7473
};
7574

76-
7775
list.Add(bsr);
7876
}
7977

8078
var best = list[0];
8179

8280
sr.PrimaryResult.UpdateFrom(best);
83-
8481
sr.OtherResults.AddRange(list);
8582

86-
8783
return sr;
8884
}
8985
}

SmartImage.Lib/Engines/Impl/TraceMoeEngine.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ protected override SearchResult Process(object obj, SearchResult r)
9090
r.ErrorMessage = $"{re.ErrorMessage} {re.StatusCode}";
9191
}
9292

93-
9493
ret:
9594

9695
r.PrimaryResult.Quality = r.PrimaryResult.Similarity switch
@@ -102,7 +101,6 @@ protected override SearchResult Process(object obj, SearchResult r)
102101
return r;
103102
}
104103

105-
106104
private IEnumerable<ImageResult> ConvertResults(TraceMoeRootObject obj)
107105
{
108106
var docs = obj.result;

SmartImage.Lib/Engines/Impl/YandexEngine.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ public YandexEngine() : base("https://yandex.com/images/search?rpt=imageview&url
6363

6464
static ImageResult Parse(INode siz)
6565
{
66-
string link = siz.FirstChild.TryGetAttribute("href");
67-
66+
string link = siz.FirstChild.TryGetAttribute("href");
6867
string resText = siz.FirstChild.ChildNodes[1].FirstChild.TextContent;
6968

70-
7169
//other-sites__snippet
7270

7371
var snippet = siz.ChildNodes[1];
@@ -102,23 +100,18 @@ private static (int? w, int? h) ParseResolution(string resText)
102100
if (resText.Contains(TIMES_DELIM)) {
103101
resFull = resText.Split(TIMES_DELIM);
104102
}
105-
106-
107103
}
108104

109105
if (resFull.Length == 2) {
110106
w = Int32.Parse(resFull[0]);
111107
h = Int32.Parse(resFull[1]);
112108
}
113109

114-
115110
return (w, h);
116111
}
117112

118113
private static List<ImageResult> GetImages(IDocument doc)
119114
{
120-
121-
122115
var tagsItem = doc.Body.SelectNodes("//a[contains(@class, 'Tags-Item')]");
123116
var images = new List<ImageResult>();
124117

@@ -173,7 +166,7 @@ protected override SearchResult Process(object obj, SearchResult sr)
173166
// Automation detected
174167
const string AUTOMATION_ERROR_MSG = "Please confirm that you and not a robot are sending requests";
175168

176-
if (((IDocument) doc).Body.TextContent.Contains(AUTOMATION_ERROR_MSG)) {
169+
if (doc.Body.TextContent.Contains(AUTOMATION_ERROR_MSG)) {
177170
sr.Status = ResultStatus.Cooldown;
178171
return sr;
179172
}
@@ -209,10 +202,6 @@ protected override SearchResult Process(object obj, SearchResult sr)
209202

210203

211204
if (looksLike != null) {
212-
//todo
213-
214-
// sr.PrimaryResult.Description = Encoding.UTF8.GetString(
215-
// Encoding.Convert(Encoding.Unicode, Encoding.UTF8, Encoding.Unicode.GetBytes(looksLike)));
216205
sr.PrimaryResult.Description = looksLike;
217206
}
218207

SmartImage.Lib/SearchClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.Linq;
5+
using System.Threading;
56
using System.Threading.Tasks;
67
using JetBrains.Annotations;
78
using Novus.Utilities;
@@ -103,7 +104,7 @@ public async Task RunSearchAsync()
103104
}
104105

105106
var tasks = new List<Task<SearchResult>>(Engines.Select(e => e.GetResultAsync(Config.Query)));
106-
107+
107108
Pending = tasks.Count;
108109

109110
while (!IsComplete) {

SmartImage/Program.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ public static class Program
105105

106106
ResultDialog.Options.Add(_orig);
107107

108-
foreach (ConsoleOption option in buffer.Select(NConsoleFactory.CreateResultOption)) {
108+
foreach (ConsoleOption option in buffer.Select(ConsoleUIFactory.CreateResultOption)) {
109109
ResultDialog.Options.Add(option);
110110
}
111111

112112
_isFilteredShown = !_isFilteredShown;
113113

114-
ConsoleManager.Refresh();
114+
ConsoleDialog.Refresh();
115115
},
116116
[ConsoleKey.F2] = async () =>
117117
{
@@ -129,7 +129,7 @@ public static class Program
129129
ConsoleManager.WaitForSecond();
130130
}
131131

132-
ConsoleManager.Refresh();
132+
ConsoleDialog.Refresh();
133133
},
134134
}
135135
};
@@ -201,18 +201,18 @@ private static async Task Main(string[] args)
201201
}
202202
};
203203

204-
ConsoleProgressIndicator.Queue(_cancellationToken);
204+
ConsoleProgressIndicator.Start(_cancellationToken);
205205

206206
// Show results
207207
var searchTask = Client.RunSearchAsync();
208208

209-
_orig = NConsoleFactory.CreateResultOption(Config.Query.GetImageResult(), "(Original image)",
209+
_orig = ConsoleUIFactory.CreateResultOption(Config.Query.GetImageResult(), "(Original image)",
210210
AppInterface.Elements.ColorMain, -0.1f);
211211

212212
// Add original image
213213
ResultDialog.Options.Add(_orig);
214214

215-
await ResultDialog.ReadAsync();
215+
await ResultDialog.ReadInputAsync();
216216

217217
await searchTask;
218218
}
@@ -225,7 +225,7 @@ private static async Task<bool> HandleArguments()
225225
args = args.Skip(1).ToArray();
226226

227227
if (!args.Any()) {
228-
var options = await AppInterface.MainMenuDialog.ReadAsync();
228+
var options = await AppInterface.MainMenuDialog.ReadInputAsync();
229229

230230
var file = options.DragAndDrop;
231231

@@ -281,7 +281,7 @@ private static void OnSearchCompleted(object sender, SearchCompletedEventArgs ev
281281
cts.Dispose();
282282

283283
SystemSounds.Exclamation.Play();
284-
ConsoleManager.Refresh();
284+
ConsoleDialog.Refresh();
285285

286286
if (Config.PriorityEngines == SearchEngineOptions.Auto) {
287287
var m = Client.Results.OrderByDescending(x => x.PrimaryResult.Similarity);
@@ -296,7 +296,7 @@ private static void OnResultCompleted(object sender, ResultCompletedEventArgs ev
296296
{
297297
var result = eventArgs.Result;
298298

299-
var option = NConsoleFactory.CreateResultOption(result);
299+
var option = ConsoleUIFactory.CreateResultOption(result);
300300

301301
bool? isFiltered = eventArgs.IsFiltered;
302302

SmartImage/UI/AppInterface.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
using static Novus.Utilities.ReflectionOperatorHelpers;
2020
using static Kantan.Diagnostics.LogCategories;
2121
using static SmartImage.Program;
22-
using static SmartImage.UI.NConsoleFactory;
22+
using static SmartImage.UI.ConsoleUIFactory;
2323

2424
// ReSharper disable AssignNullToNotNullAttribute
2525

SmartImage/UI/NConsoleFactory.cs renamed to SmartImage/UI/ConsoleUIFactory.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
using SmartImage.Lib.Utilities;
2020
using static Kantan.Cli.Controls.ConsoleOption;
2121

22+
// ReSharper disable InconsistentNaming
23+
2224
// ReSharper disable PossibleNullReferenceException
2325

2426
namespace SmartImage.UI
2527
{
26-
internal static class NConsoleFactory
28+
internal static class ConsoleUIFactory
2729
{
2830
/*
2931
* todo: this is all glue code :(
@@ -39,11 +41,11 @@ internal static ConsoleOption CreateConfigOption(string f, string name)
3941
{
4042
var enumOptions = FromEnum<SearchEngineOptions>();
4143

42-
var selected = ConsoleManager.ReadInput(new ConsoleDialog
44+
var selected = (new ConsoleDialog
4345
{
4446
Options = enumOptions,
4547
SelectMultiple = true
46-
});
48+
}).ReadInput();
4749

4850
var enumValue = EnumHelper.ReadFromSet<SearchEngineOptions>(selected.Output);
4951
var field = Program.Config.GetType().GetAnyResolvedField(f);
@@ -132,10 +134,10 @@ internal static ConsoleOption CreateResultOption(SearchResult result)
132134

133135
var options = CreateResultOptions(result.OtherResults, $"Other result");
134136

135-
ConsoleManager.ReadInput(new ConsoleDialog
137+
(new ConsoleDialog
136138
{
137139
Options = options
138-
});
140+
}).ReadInput();
139141
}
140142

141143
return null;
@@ -158,7 +160,7 @@ internal static ConsoleOption CreateResultOption(SearchResult result)
158160
{
159161
var cts = new CancellationTokenSource();
160162

161-
ConsoleProgressIndicator.Queue(cts);
163+
ConsoleProgressIndicator.Start(cts);
162164

163165
result.OtherResults.AsParallel().ForAll(f => f.FindDirectImages());
164166

@@ -178,7 +180,7 @@ internal static ConsoleOption CreateResultOption(SearchResult result)
178180

179181
[StringFormatMethod("n")]
180182
internal static ConsoleOption[] CreateResultOptions(IEnumerable<ImageResult> result, string n,
181-
Color c = default)
183+
Color c = default)
182184
{
183185
if (c == default) {
184186
c = AppInterface.Elements.ColorOther;
@@ -189,7 +191,7 @@ internal static ConsoleOption[] CreateResultOptions(IEnumerable<ImageResult> res
189191
}
190192

191193
internal static ConsoleOption CreateResultOption(ImageResult result, string n, Color c,
192-
float correction = -.3f)
194+
float correction = -.3f)
193195
{
194196
var option = new ConsoleOption
195197
{

SmartImage/Utilities/ReleaseInfo.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,16 @@ public ReleaseInfo(string tagName, string htmlUrl, string publishedAt, string as
1919
// TODO: fails if tag contains non-numeric values!
2020

2121
TagName = tagName;
22-
2322
HtmlUrl = htmlUrl;
2423

25-
2624
var utc = DateTime.Parse(publishedAt, null, DateTimeStyles.AdjustToUniversal);
2725

2826
PublishedAt = TimeZoneInfo.ConvertTimeFromUtc(utc, TimeZoneInfo.Local);
2927

30-
3128
// Parse version
3229

33-
string[] versionStrSplit = tagName
34-
.Replace("v", String.Empty)
35-
.Split(".");
36-
30+
string[] versionStrSplit = tagName.Replace("v", String.Empty)
31+
.Split(".");
3732

3833
int major = Int32.Parse(versionStrSplit[0]);
3934
int minor = Int32.Parse(versionStrSplit[1]);
@@ -48,7 +43,6 @@ public ReleaseInfo(string tagName, string htmlUrl, string publishedAt, string as
4843
rev = Int32.Parse(versionStrSplit[3]);
4944
}
5045

51-
5246
Version = new Version(major, minor, build, rev);
5347

5448
AssetUrl = asset;
@@ -77,7 +71,6 @@ public static ReleaseInfo GetLatestRelease()
7771
var url = first["html_url"];
7872
var publish = first["published_at"];
7973

80-
8174
var assets = first["assets"];
8275
var dlUrl = assets[0]["browser_download_url"];
8376

0 commit comments

Comments
 (0)