Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

37
LINES

< > BotCompany Repo | #1007141 // Test Google Image Search v2

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 616K of libraries. Click here for Pure Java version (8963L/64K/221K).

1  
!7
2  
3  
p {
4  
  makeBot("Google Image Search.");
5  
  centerBigConsole();
6  
  clearConsole();
7  
  renameConsole(programName());
8  
  print("Type what you want to see!");
9  
}
10  
11  
static ImageSurface imageSurface;
12  
13  
static S answer(final S s) {
14  
  print("Searching " + quote(s) + "...");
15  
  final L<S> urls = googleImageSearch_multi(s);
16  
  print("Done - got " + n(urls, "URL"));
17  
  int idx = randomIndex(urls);
18  
  printWithMSTime("Choosing URL " + (idx+1));
19  
  final S url = get(urls, idx);
20  
  if (nempty(url)) {
21  
    final BufferedImage img = loadImage2(url);
22  
    printWithMSTime("Loaded image");
23  
    awt {
24  
      disposeFrame(imageSurface);
25  
      imageSurface = showImage(quote(s), img);
26  
      addToWindowAndPack(imageSurface, jbutton("Upload to Database", r-thread {
27  
        print("Uploading...");
28  
        loading {
29  
          S imageURL = uploadToImageServer(img, s + " [Google]");
30  
          print("Image Uploaded! => " + imageURL);
31  
        }
32  
      }));
33  
      magiclyFocusConsole();
34  
    }
35  
  }
36  
  ret url;
37  
}

Author comment

Began life as a copy of #1005000

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007141
Snippet name: Test Google Image Search v2
Eternal ID of this version: #1007141/7
Text MD5: f2629ef66beae16a64774cef506c9d97
Transpilation MD5: 023d9786bd288ba93400db66449913d3
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-07 20:09:10
Source code size: 1011 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 468 / 599
Version history: 6 change(s)
Referenced in: [show references]