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).

!7

p {
  makeBot("Google Image Search.");
  centerBigConsole();
  clearConsole();
  renameConsole(programName());
  print("Type what you want to see!");
}

static ImageSurface imageSurface;

static S answer(final S s) {
  print("Searching " + quote(s) + "...");
  final L<S> urls = googleImageSearch_multi(s);
  print("Done - got " + n(urls, "URL"));
  int idx = randomIndex(urls);
  printWithMSTime("Choosing URL " + (idx+1));
  final S url = get(urls, idx);
  if (nempty(url)) {
    final BufferedImage img = loadImage2(url);
    printWithMSTime("Loaded image");
    awt {
      disposeFrame(imageSurface);
      imageSurface = showImage(quote(s), img);
      addToWindowAndPack(imageSurface, jbutton("Upload to Database", r-thread {
        print("Uploading...");
        loading {
          S imageURL = uploadToImageServer(img, s + " [Google]");
          print("Image Uploaded! => " + imageURL);
        }
      }));
      magiclyFocusConsole();
    }
  }
  ret url;
}

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: 467 / 597
Version history: 6 change(s)
Referenced in: [show references]