1.0.62 - Imgur album directories named after album #49

This commit is contained in:
4pr0n 2014-06-12 00:23:22 -07:00
parent 848a0757fa
commit 8b2d30496d
3 changed files with 31 additions and 4 deletions

View File

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

View File

@ -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) {

View File

@ -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";