Beispiel #1
0
  private static void login(Client httpclient) {
    if (loggedin) return;
    log.debug("Attempting login");
    try {
      HttpResponse response = httpclient.get(loginUri);
      EntityUtils.consume(response.getEntity());
      log.debug(response);

      ClientParam[] nvps =
          new ClientParam[] {
            new StringParam("action", "login"),
            new StringParam("retard_protection", "1"),
            new StringParam("name", props.getProperty("user")),
            new StringParam("pass", props.getProperty("pass")),
            new StringParam("login", "Login to FurAffinity")
          };

      response =
          httpclient.post(loginPostUri, loginHeaders, nvps, Client.PostDataType.UrlEncoded, null);
      HttpEntity entity = response.getEntity();
      EntityUtils.consume(entity);
    } catch (Exception e) {
      log.error("Could not log in", e);
    }
  }
Beispiel #2
0
 @Override
 public boolean canHandle(Uri link, Page page, String mime) {
   log.debug("CanHandle", link);
   if (link.getDomain().equalsIgnoreCase("furaffinity.net") && "text/html".equals(mime)) {
     return true;
   }
   return false;
 }
Beispiel #3
0
  static {
    try (FileInputStream in = new FileInputStream("furaffinity_parser.conf")) {
      props.load(in);
    } catch (FileNotFoundException e) {

    } catch (IOException e) {
      log.error("Failed to load options", e);
    }
    optionPanel.setItemValue("username", props.getProperty("user"));
    optionPanel.setItemValue("password", props.getProperty("pass"));
  }
Beispiel #4
0
 @Override
 public boolean saveOptions() {
   props.setProperty("user", optionPanel.getItemValue("username"));
   props.setProperty("pass", optionPanel.getItemValue("password"));
   File f = new File("furaffinity_parser.conf");
   if (!f.exists()) {
     try {
       if (!f.createNewFile()) {
         log.error("Failed to create options file.");
         return false;
       }
     } catch (IOException e) {
       log.error("Failed to create options file.", e);
       return false;
     }
   }
   try (FileOutputStream out = new FileOutputStream(f)) {
     props.store(out, "");
   } catch (IOException e) {
     log.error("Failed to save options file.", e);
     return false;
   }
   return true;
 }