diff --git a/pom.xml b/pom.xml index a3595b53..4f707789 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.rarchives.ripme ripme jar - 1.0.61 + 1.0.62 ripme http://rip.rarchives.com diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java index 42ff8bee..1064f493 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java @@ -27,6 +27,8 @@ public class ImgurRipper extends AlbumRipper { HOST = "imgur"; private final int SLEEP_BETWEEN_ALBUMS; + + private Document albumDoc; static enum ALBUM_TYPE { ALBUM, @@ -75,6 +77,32 @@ public class ImgurRipper extends AlbumRipper { return new URL(u); } + public String getAlbumTitle(URL url) throws MalformedURLException { + String gid = getGID(url); + if (this.albumType == ALBUM_TYPE.ALBUM) { + try { + // Attempt to use album title as GID + if (albumDoc == null) { + albumDoc = Jsoup.connect(url.toExternalForm()) + .userAgent(USER_AGENT) + .timeout(10 * 1000) + .maxBodySize(0) + .get(); + } + String title = albumDoc.title(); + if (!title.contains(" - Imgur") + || title.contains("'s albums")) { + throw new IOException("No title found"); + } + title = title.replaceAll(" - Imgur.*", ""); + return "imgur_" + gid + " (" + title + ")"; + } catch (IOException e) { + // Fall back to default album naming convention + } + } + return getHost() + "_" + gid; + } + @Override public void rip() throws IOException { switch (albumType) { @@ -83,11 +111,9 @@ public class ImgurRipper extends AlbumRipper { case USER_ALBUM: ripAlbum(this.url); break; - case SERIES_OF_IMAGES: ripAlbum(this.url); break; - case USER: ripUserAccount(url); break; @@ -309,6 +335,7 @@ public class ImgurRipper extends AlbumRipper { logger.info(" Retrieving " + pageURL); Document doc = Jsoup.connect(pageURL) .userAgent(USER_AGENT) + .timeout(10 * 1000) .get(); Elements imgs = doc.select(".post img"); for (Element img : imgs) { diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index e25bfe18..f96531fa 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.61"; + private static final String DEFAULT_VERSION = "1.0.62"; 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";