Merge pull request #764 from rephormat/xhamsterPretty

Xhamster Descriptive Folder Naming
This commit is contained in:
cyian-1756 2018-07-04 00:07:04 -04:00 committed by GitHub
commit 7f118c6164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,4 +100,23 @@ public class XhamsterRipper extends AbstractHTMLRipper {
public void downloadURL(URL url, int index) { public void downloadURL(URL url, int index) {
addURLToDownload(url, getPrefix(index)); addURLToDownload(url, getPrefix(index));
} }
@Override
public String getAlbumTitle(URL url) throws MalformedURLException {
try {
// Attempt to use album title and username as GID
Document doc = getFirstPage();
Element user = doc.select("a.author").first();
String username = user.text();
String path = url.getPath();
Pattern p = Pattern.compile("^/photos/gallery/(.*)$");
Matcher m = p.matcher(path);
if (m.matches() && !username.isEmpty()) {
return getHost() + "_" + username + "_" + m.group(1);
}
} catch (IOException e) {
// Fall back to default album naming convention
}
return super.getAlbumTitle(url);
}
} }