From 1105c9c170be9f4e3e4eea526f3b06b3bbec144e Mon Sep 17 00:00:00 2001 From: 4pr0n Date: Sat, 16 Apr 2016 21:26:27 -0700 Subject: [PATCH] 1.2.11 - DeviantArt fav subfolders, Reddituploads support Allows ripping deviantart subfolders. Closes #314 Support i.reddituploads.com in RedditRipper Closes #308 --- pom.xml | 2 +- .../ripme/ripper/rippers/DeviantartRipper.java | 17 +++++++++++++---- .../ripme/ripper/rippers/RedditRipper.java | 14 +++++++++++++- .../com/rarchives/ripme/ui/UpdateUtils.java | 2 +- .../com/rarchives/ripme/utils/RipUtils.java | 16 ++++++++++++++-- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 8ac24b14..4e5b550f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.rarchives.ripme ripme jar - 1.2.10 + 1.2.11 ripme http://rip.rarchives.com diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java index 24155aa8..b170c2e7 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java @@ -62,11 +62,15 @@ public class DeviantartRipper extends AbstractHTMLRipper { u += "gallery/?"; } - String subdir = "/"; - if (u.contains("catpath=scraps")) { - subdir = "scraps"; + Pattern p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{1,})\\.deviantart\\.com/favou?rites/([0-9]+)/*?$"); + Matcher m = p.matcher(url.toExternalForm()); + if (!m.matches()) { + String subdir = "/"; + if (u.contains("catpath=scraps")) { + subdir = "scraps"; + } + u = u.replaceAll("\\?.*", "?catpath=" + subdir); } - u = u.replaceAll("\\?.*", "?catpath=" + subdir); return new URL(u); } @@ -89,6 +93,11 @@ public class DeviantartRipper extends AbstractHTMLRipper { // Subgallery return m.group(1) + "_" + m.group(2); } + p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{1,})\\.deviantart\\.com/favou?rites/([0-9]+)/.*?$"); + m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return m.group(1) + "_faves_" + m.group(2); + } p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{1,})\\.deviantart\\.com/favou?rites/?$"); m = p.matcher(url.toExternalForm()); if (m.matches()) { diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java index bfff9cbe..067e7866 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java @@ -1,5 +1,6 @@ package com.rarchives.ripme.ripper.rippers; +import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -188,7 +189,18 @@ public class RedditRipper extends AlbumRipper { List urls = RipUtils.getFilesFromURL(originalURL); if (urls.size() == 1) { - addURLToDownload(urls.get(0), id + "-", "", theUrl, null); + String url = urls.get(0).toExternalForm(); + Pattern p = Pattern.compile("https?://i.reddituploads.com/([a-zA-Z0-9]+)\\?.*"); + Matcher m = p.matcher(url); + if (m.matches()) { + // It's from reddituploads. Assume .jpg extension. + String savePath = this.workingDir + File.separator; + savePath += id + "-" + m.group(1) + ".jpg"; + addURLToDownload(urls.get(0), new File(savePath)); + } + else { + addURLToDownload(urls.get(0), id + "-", "", theUrl, null); + } } else if (urls.size() > 1) { for (int i = 0; i < urls.size(); i++) { String prefix = id + "-"; diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index 8f7a4c1f..01bb99cd 100644 --- a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java +++ b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java @@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils; public class UpdateUtils { private static final Logger logger = Logger.getLogger(UpdateUtils.class); - private static final String DEFAULT_VERSION = "1.2.10"; + private static final String DEFAULT_VERSION = "1.2.11"; private static final String updateJsonURL = "http://rarchives.com/ripme.json"; private static final String updateJarURL = "http://rarchives.com/ripme.jar"; private static final String mainFileName = "ripme.jar"; diff --git a/src/main/java/com/rarchives/ripme/utils/RipUtils.java b/src/main/java/com/rarchives/ripme/utils/RipUtils.java index 65dc8a75..f21fb6cd 100644 --- a/src/main/java/com/rarchives/ripme/utils/RipUtils.java +++ b/src/main/java/com/rarchives/ripme/utils/RipUtils.java @@ -79,10 +79,22 @@ public class RipUtils { } return result; } + + Pattern p = Pattern.compile("https?://i.reddituploads.com/([a-zA-Z0-9]+)\\?.*"); + Matcher m = p.matcher(url.toExternalForm()); + if (m.matches()) { + System.out.println("URL: " + url.toExternalForm()); + String u = url.toExternalForm().replaceAll("&", "&"); + try { + result.add(new URL(u)); + } catch (MalformedURLException e) { + } + return result; + } // Direct link to image - Pattern p = Pattern.compile("(https?://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(/\\S*)\\.(jpg|jpeg|gif|png|mp4)(\\?.*)?)"); - Matcher m = p.matcher(url.toExternalForm()); + p = Pattern.compile("(https?://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(/\\S*)\\.(jpg|jpeg|gif|png|mp4)(\\?.*)?)"); + m = p.matcher(url.toExternalForm()); if (m.matches()) { try { URL singleURL = new URL(m.group(1));