From 29b1afea065ff05b193e7b830238044b8e05b348 Mon Sep 17 00:00:00 2001 From: 4pr0n Date: Tue, 13 May 2014 23:16:37 -0700 Subject: [PATCH] 1.0.40 - Flickr groups support, thread bug fix for #32 --- pom.xml | 2 +- .../ripme/ripper/rippers/FlickrRipper.java | 25 ++++++++++++++++--- .../com/rarchives/ripme/ui/UpdateUtils.java | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index d0223de5..b371e3d8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.rarchives.ripme ripme jar - 1.0.39 + 1.0.40 ripme http://rip.rarchives.com diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/FlickrRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/FlickrRipper.java index 7ddc8e16..3136ddc5 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/FlickrRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/FlickrRipper.java @@ -43,7 +43,15 @@ public class FlickrRipper extends AlbumRipper { } public URL sanitizeURL(URL url) throws MalformedURLException { - return url; + String sUrl = url.toExternalForm(); + sUrl = sUrl.replace("secure.flickr.com", "flickr.com"); + if (sUrl.contains("flickr.com/groups/") && !sUrl.contains("/pool")) { + if (!sUrl.endsWith("/")) { + sUrl += "/"; + } + sUrl += "pool"; + } + return new URL(sUrl); } public String getAlbumTitle(URL url) throws MalformedURLException { @@ -75,21 +83,28 @@ public class FlickrRipper extends AlbumRipper { // Root: https://www.flickr.com/photos/115858035@N04/ // Album: https://www.flickr.com/photos/115858035@N04/sets/72157644042355643/ + final String domainRegex = "https?://[wm.]*flickr.com"; final String userRegex = "[a-zA-Z0-9@]+"; // Album - p = Pattern.compile("^https?://[wm.]*flickr.com/photos/(" + userRegex + ")/sets/([0-9]+)/?.*$"); + p = Pattern.compile("^" + domainRegex + "/photos/(" + userRegex + ")/sets/([0-9]+)/?.*$"); m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(1) + "_" + m.group(2); } // User page - p = Pattern.compile("^https?://[wm.]*flickr.com/photos/(" + userRegex + ").*$"); + p = Pattern.compile("^" + domainRegex + "/photos/(" + userRegex + ").*$"); m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(1); } + // Groups page + p = Pattern.compile("^" + domainRegex + "/groups/(" + userRegex + ").*$"); + m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return "groups-" + m.group(1); + } throw new MalformedURLException( "Expected flickr.com URL formats: " + "flickr.com/photos/username or " @@ -230,7 +245,9 @@ public class FlickrRipper extends AlbumRipper { } else { String prefix = String.format("%03d_%s_", index, Utils.filesystemSafe(title)); - addURLToDownload(new URL(fullsizeImages.get(0).attr("src")), prefix); + synchronized (flickrThreadPool) { + addURLToDownload(new URL(fullsizeImages.get(0).attr("src")), prefix); + } } } catch (IOException e) { logger.error("[!] Exception while loading/parsing " + this.url, e); diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index ad7ec370..2babd990 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.0.39"; + private static final String DEFAULT_VERSION = "1.0.40"; 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";