Changed imgur title grabbing to be less reliant on site style (#477)
This commit is contained in:
parent
a3d8e87639
commit
2ff45e8696
@ -28,7 +28,7 @@ public class ImgurRipper extends AlbumRipper {
|
|||||||
HOST = "imgur";
|
HOST = "imgur";
|
||||||
|
|
||||||
private final int SLEEP_BETWEEN_ALBUMS;
|
private final int SLEEP_BETWEEN_ALBUMS;
|
||||||
|
|
||||||
private Document albumDoc;
|
private Document albumDoc;
|
||||||
|
|
||||||
static enum ALBUM_TYPE {
|
static enum ALBUM_TYPE {
|
||||||
@ -104,12 +104,10 @@ public class ImgurRipper extends AlbumRipper {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
String title = null;
|
String title = null;
|
||||||
elems = albumDoc.select(".post-title");
|
logger.info("Trying to get album title");
|
||||||
if (elems.size() > 0) {
|
elems = albumDoc.select("meta[property=og:title]");
|
||||||
Element postTitle = elems.get(0);
|
if (elems!=null) {
|
||||||
if (postTitle != null) {
|
title = elems.attr("content");
|
||||||
title = postTitle.text();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String albumTitle = "imgur_";
|
String albumTitle = "imgur_";
|
||||||
@ -138,18 +136,25 @@ public class ImgurRipper extends AlbumRipper {
|
|||||||
case ALBUM:
|
case ALBUM:
|
||||||
// Fall-through
|
// Fall-through
|
||||||
case USER_ALBUM:
|
case USER_ALBUM:
|
||||||
|
logger.info("Album type is USER_ALBUM");
|
||||||
|
// Don't call getAlbumTitle(this.url) with this
|
||||||
|
// as it seems to cause the album to be downloaded to a subdir.
|
||||||
ripAlbum(this.url);
|
ripAlbum(this.url);
|
||||||
break;
|
break;
|
||||||
case SERIES_OF_IMAGES:
|
case SERIES_OF_IMAGES:
|
||||||
|
logger.info("Album type is SERIES_OF_IMAGES");
|
||||||
ripAlbum(this.url);
|
ripAlbum(this.url);
|
||||||
break;
|
break;
|
||||||
case USER:
|
case USER:
|
||||||
|
logger.info("Album type is USER");
|
||||||
ripUserAccount(url);
|
ripUserAccount(url);
|
||||||
break;
|
break;
|
||||||
case SUBREDDIT:
|
case SUBREDDIT:
|
||||||
|
logger.info("Album type is SUBREDDIT");
|
||||||
ripSubreddit(url);
|
ripSubreddit(url);
|
||||||
break;
|
break;
|
||||||
case USER_IMAGES:
|
case USER_IMAGES:
|
||||||
|
logger.info("Album type is USER_IMAGES");
|
||||||
ripUserImages(url);
|
ripUserImages(url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -338,7 +343,7 @@ public class ImgurRipper extends AlbumRipper {
|
|||||||
}
|
}
|
||||||
return imgurAlbum;
|
return imgurAlbum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rips all albums in an imgur user's account.
|
* Rips all albums in an imgur user's account.
|
||||||
* @param url
|
* @param url
|
||||||
@ -366,7 +371,7 @@ public class ImgurRipper extends AlbumRipper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ripUserImages(URL url) throws IOException {
|
private void ripUserImages(URL url) throws IOException {
|
||||||
int page = 0; int imagesFound = 0; int imagesTotal = 0;
|
int page = 0; int imagesFound = 0; int imagesTotal = 0;
|
||||||
String jsonUrl = url.toExternalForm().replace("/all", "/ajax/images");
|
String jsonUrl = url.toExternalForm().replace("/all", "/ajax/images");
|
||||||
@ -404,7 +409,7 @@ public class ImgurRipper extends AlbumRipper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ripSubreddit(URL url) throws IOException {
|
private void ripSubreddit(URL url) throws IOException {
|
||||||
int page = 0;
|
int page = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
Loading…
Reference in New Issue
Block a user