3030using SmartImage . Lib . Utilities ;
3131using SmartImage . Utilities ;
3232
33+ // ReSharper disable AssignNullToNotNullAttribute
34+
3335// ReSharper disable ConvertSwitchStatementToSwitchExpression
3436
3537// ReSharper disable UnusedParameter.Local
@@ -53,7 +55,7 @@ private static async Task Main(string[] args)
5355 {
5456#if DEBUG
5557 if ( ! args . Any ( ) ) {
56- // args = new[] {""};
58+ args = new [ ] { "find-direct" , "https://danbooru.donmai.us/posts/3987008 "} ;
5759 }
5860
5961
@@ -105,7 +107,42 @@ private static async Task Main(string[] args)
105107 object ? arg = enumerator . Current ;
106108
107109 switch ( arg ) {
110+ case "find-direct" :
111+ enumerator . MoveNext ( ) ;
112+ var argValue = ( string ) enumerator . Current ;
113+
114+ var directImages = ImageHelper . FindDirectImages ( argValue , out var im ) ;
115+ var imageResults = new List < ImageResult > ( ) ;
116+
117+ for ( int i = 0 ; i < directImages . Count ; i ++ ) {
118+ string directUrl = directImages [ i ] ;
119+
120+ var ir = new ImageResult
121+ {
122+ Image = im [ i ] ,
123+ Url = new Uri ( directUrl ) ,
124+ Direct = new Uri ( directUrl )
125+ } ;
126+
127+ ir . UpdateImageData ( ) ;
128+
129+ imageResults . Add ( ir ) ;
130+ }
131+
132+ int i2 = 0 ;
133+
134+ var options = imageResults
135+ . Select ( r => NConsoleFactory . Create ( r , i2 ++ , MainDialog . ColorOther ) )
136+ . ToArray ( ) ;
137+
138+
139+ NConsole . ReadOptions ( new NConsoleDialog
140+ {
141+ Options = options ,
142+ Description = MainDialog . Description
143+ } ) ;
108144
145+ return ;
109146 default :
110147 Config . Query = args [ 0 ] ;
111148 break ;
@@ -179,9 +216,8 @@ private static void OnResultCompleted(object? sender, SearchResultEventArgs even
179216
180217 public static readonly NConsoleDialog ResultDialog = new ( )
181218 {
182- Options = new List < NConsoleOption > ( ) ,
183- Description = "Press the result number to open in browser\n " +
184- "Ctrl: Load direct | Alt: Show other | Shift: Open raw | Alt+Ctrl: Download"
219+ Options = new List < NConsoleOption > ( ) ,
220+ Description = MainDialog . Description
185221 } ;
186222
187223 public static readonly SearchConfig Config = new ( ) ;
0 commit comments