1.2.11 - DeviantArt fav subfolders, Reddituploads support

Allows ripping deviantart subfolders.
Closes #314

Support i.reddituploads.com in RedditRipper
Closes #308
This commit is contained in:
4pr0n 2016-04-16 21:26:27 -07:00
parent 23b2a398fb
commit 1105c9c170
5 changed files with 42 additions and 9 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.rarchives.ripme</groupId> <groupId>com.rarchives.ripme</groupId>
<artifactId>ripme</artifactId> <artifactId>ripme</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.2.10</version> <version>1.2.11</version>
<name>ripme</name> <name>ripme</name>
<url>http://rip.rarchives.com</url> <url>http://rip.rarchives.com</url>
<properties> <properties>

View File

@ -62,11 +62,15 @@ public class DeviantartRipper extends AbstractHTMLRipper {
u += "gallery/?"; u += "gallery/?";
} }
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 = "/"; String subdir = "/";
if (u.contains("catpath=scraps")) { if (u.contains("catpath=scraps")) {
subdir = "scraps"; subdir = "scraps";
} }
u = u.replaceAll("\\?.*", "?catpath=" + subdir); u = u.replaceAll("\\?.*", "?catpath=" + subdir);
}
return new URL(u); return new URL(u);
} }
@ -89,6 +93,11 @@ public class DeviantartRipper extends AbstractHTMLRipper {
// Subgallery // Subgallery
return m.group(1) + "_" + m.group(2); 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/?$"); p = Pattern.compile("^https?://([a-zA-Z0-9\\-]{1,})\\.deviantart\\.com/favou?rites/?$");
m = p.matcher(url.toExternalForm()); m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {

View File

@ -1,5 +1,6 @@
package com.rarchives.ripme.ripper.rippers; package com.rarchives.ripme.ripper.rippers;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
@ -188,7 +189,18 @@ public class RedditRipper extends AlbumRipper {
List<URL> urls = RipUtils.getFilesFromURL(originalURL); List<URL> urls = RipUtils.getFilesFromURL(originalURL);
if (urls.size() == 1) { if (urls.size() == 1) {
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); addURLToDownload(urls.get(0), id + "-", "", theUrl, null);
}
} else if (urls.size() > 1) { } else if (urls.size() > 1) {
for (int i = 0; i < urls.size(); i++) { for (int i = 0; i < urls.size(); i++) {
String prefix = id + "-"; String prefix = id + "-";

View File

@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils;
public class UpdateUtils { public class UpdateUtils {
private static final Logger logger = Logger.getLogger(UpdateUtils.class); 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 updateJsonURL = "http://rarchives.com/ripme.json";
private static final String updateJarURL = "http://rarchives.com/ripme.jar"; private static final String updateJarURL = "http://rarchives.com/ripme.jar";
private static final String mainFileName = "ripme.jar"; private static final String mainFileName = "ripme.jar";

View File

@ -80,9 +80,21 @@ public class RipUtils {
return result; return result;
} }
// Direct link to image Pattern p = Pattern.compile("https?://i.reddituploads.com/([a-zA-Z0-9]+)\\?.*");
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()); Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) {
System.out.println("URL: " + url.toExternalForm());
String u = url.toExternalForm().replaceAll("&amp;", "&");
try {
result.add(new URL(u));
} catch (MalformedURLException e) {
}
return result;
}
// Direct link to image
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()) { if (m.matches()) {
try { try {
URL singleURL = new URL(m.group(1)); URL singleURL = new URL(m.group(1));