From ee949ed487e70a2be9839cf56875963affd44aad Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Thu, 23 Mar 2017 19:23:03 -0400 Subject: [PATCH] improved file naming --- .../ripper/rippers/FuraffinityRipper.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/FuraffinityRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/FuraffinityRipper.java index 9dfbc7a5..87ed5634 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/FuraffinityRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/FuraffinityRipper.java @@ -157,12 +157,8 @@ public class FuraffinityRipper extends AbstractHTMLRipper { ele.select("p").prepend("\\n\\n"); logger.debug("Returning description at " + page); String tempPage = Jsoup.clean(ele.html().replaceAll("\\\\n", System.getProperty("line.separator")), "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)); - Elements titles = documentz.select("meta[property=og:title]"); - if (titles.size() == 0) { - throw new IOException("No title found"); - } - Element title = titles.get(0); - String tempText = title.text(); + String title = documentz.select("meta[property=og:title]").attr("content"); + String tempText = title; return tempText + "\n" + tempPage; // Overridden saveText takes first line and makes it the file name. } catch (IOException ioe) { logger.info("Failed to get description " + page + " : '" + ioe.getMessage() + "'"); @@ -196,10 +192,7 @@ public class FuraffinityRipper extends AbstractHTMLRipper { workingDir.getCanonicalPath() + subdirectory + File.separator - + getPrefix(index) + saveAs - + " " - + test + ".txt"); // Write the file FileOutputStream out = (new FileOutputStream(saveFileAs)); @@ -255,7 +248,15 @@ public class FuraffinityRipper extends AbstractHTMLRipper { } String link = "http:" + donwloadLink.first().attr("href"); logger.info("Found URL " + link); - addURLToDownload(new URL(link),"","",url.toExternalForm(),cookies); + String[] fileNameSplit = link.split("/"); + String fileName = fileNameSplit[fileNameSplit.length -1]; + File saveAS; + saveAS = new File( + workingDir.getCanonicalPath() + + File.separator + + fileName); + fileName = fileName.replace("[0-9]*\\.", ""); + addURLToDownload(new URL(link),saveAS,"",cookies); } catch (IOException e) { logger.error("[!] Exception while loading/parsing " + this.url, e); }