private static void updateFromUtorrent( String logFilePath, String label, String title, String secret) { XBMCUpdate updateServer = new XBMCUpdate("xbmc", "xbmc", "10.0.0.5", "8081"); updateServer.sendUpdateRequest(); DownloadLog log = new DownloadLog(label, title); String toEmail = null; String password = null; ReadUserXML reader; try { reader = new ReadUserXML(USER_XML_PATH); reader.parseXML(); EncryptText encrypter = new EncryptText(secret); toEmail = encrypter.decryptString(reader.getUsername()); password = encrypter.decryptString(reader.getPassword()); } catch (FileNotFoundException | XMLStreamException e) { logger.error(e); } Emailer emailer = new Emailer(); emailer.setCredentials(toEmail, password); String fromEmail = "*****@*****.**"; emailer.setToAddress(toEmail); emailer.setFromAddress(fromEmail); emailer.setMessageSubject("New Torrent Downloaded"); emailer.setMessageBody(log.toString()); emailer.sendEmail("true", "smtp.gmail.com", "587", false); File logFile = new File(logFilePath); if (logFile.exists()) { try (FileWriter writer = new FileWriter(logFile, true)) { writer.write(log.toString()); writer.write("\n"); System.out.println("Added to log: \n\t" + log.toString()); } catch (IOException e) { logger.info("logFilePath invalid"); logger.error("Could not find log file", e); } } else { System.out.printf("Directory %s does not exist%n", logFile.getAbsolutePath()); } }
private static void updateXBMC(String username, String password, String host, String port) { XBMCUpdate update = new XBMCUpdate(username, password, host, port); System.out.printf("Updating: %s %n", update.getURL()); update.sendUpdateRequest(); }