Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package se.proxus;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.InputStreamReader;
- import java.io.PrintWriter;
- import java.util.ArrayList;
- import java.util.List;
- import org.apache.commons.io.FileUtils;
- import se.proxus.models.PageModel;
- public class Main {
- public static void main(String[] args) {
- System.out.println("dank");
- try {
- BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));
- String[] inputMeme = inputReader.readLine().split(" § ");
- String url = inputMeme[1];
- PageModel page = new PageModel(url);
- String titleOne = page.getTitle().split(" - ")[0];
- String description = page.getElements("#editdescription").html();
- description = description.replace("<p>", "");
- description = description.replace("</p>", "");
- String names = page.getElements("#editassociated").html();
- names = names.replace("<br></br>", "");
- names = names.replace("<br />", ", ");
- names = names.replace("\n", "");
- names = titleOne + ", " + names;
- // System.out.println(names);
- /*
- * for (String harambe : names.split("\n")) { if (harambe.isEmpty())
- * { continue; } harambe.replace("\n", "");
- * System.out.println("XD: " + harambe); names += harambe;
- * System.out.println("DX: " + names); }
- */
- String type = page.getElements("#showtype").text();
- String genre = "";
- String[] genreArray = page.getElements("#seriesgenre").html().split("<a");
- for (String dank : genreArray) {
- if (dank.isEmpty()) {
- continue;
- }
- genre += dank.substring(dank.indexOf(">") + 1, dank.indexOf("<")) + ", ";
- }
- genre = genre.substring(0, genre.length() - 2);
- // meme
- String authors = "";
- String[] authorsArray = page.getElements("#showauthors").html().split("<a");
- for (String fuccboi : authorsArray) {
- if (fuccboi.isEmpty()) {
- continue;
- }
- authors += fuccboi.substring(fuccboi.indexOf(">") + 1, fuccboi.indexOf("<")) + ", ";
- }
- authors = authors.substring(0, authors.length() - 2);
- // hail satan
- String artists = "";
- String[] artistsArray = page.getElements("#showartists").html().split("<a");
- for (String joniboi : artistsArray) {
- if (joniboi.isEmpty()) {
- continue;
- }
- artists += joniboi.substring(joniboi.indexOf(">") + 1, joniboi.indexOf("<")) + ", ";
- }
- artists = artists.substring(0, artists.length() - 2);
- // System.out.println(genre);
- // genre = genre.substring(genre.indexOf(">"));
- // System.out.println(type);
- /*
- * System.out.println("Associated Names:\n" + names + "\n");
- * System.out.println("Author:\n" + authors + "\n");
- * System.out.println("Illustrator:\n" + artists + "\n");
- * System.out.println("Type:\n" + type + "\n");
- * System.out.println("Genres:\n" + genre + "\n");
- * System.out.println("Description:\n" + description);
- */
- // System.out.println(fullText);
- String directory = inputMeme[0];
- File directoryFile = new File(directory);
- File infoText = new File(directoryFile, directoryFile.getName() + " Info.txt");
- File placeholderFile = new File(directoryFile, "PLACEHOLDER Info.txt");
- infoText.createNewFile();
- // FileUtils.writeStringToFile(infoText, fullText, "UTF-8");
- /*
- * FileUtils.writeStringToFile(infoText, "Associated Names:\n" +
- * names + "\n", "UTF-8", true);
- * FileUtils.writeStringToFile(infoText, " ", "UTF-8", true);
- * FileUtils.writeStringToFile(infoText, "Author:\n" + authors +
- * "\n", "UTF-8", true); FileUtils.writeStringToFile(infoText,
- * "Illustrator:\n" + artists + "\n", "UTF-8", true);
- */
- List<String> infoLines = new ArrayList<String>();
- infoLines.add("Associated Names:");
- infoLines.add(names);
- infoLines.add("Author:");
- infoLines.add(authors);
- infoLines.add("Illustrator:");
- infoLines.add(artists);
- infoLines.add("Type:");
- infoLines.add(type);
- infoLines.add("Genres:");
- infoLines.add(genre);
- infoLines.add("Description:");
- infoLines.add(description);
- PrintWriter writer = new PrintWriter(infoText);
- for (String lines : infoLines) {
- writer.println(lines + "\n");
- if (!isEven(infoLines.indexOf(lines))) {
- writer.println("\n");
- }
- }
- writer.close();
- FileUtils.deleteQuietly(placeholderFile);
- System.out.println("Done!");
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- }
- public static boolean isEven(final int number) {
- return number % 2 == 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement