-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/main/java/com/rarchives/ripme/ripper/rippers/KinkyshareRipper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.rarchives.ripme.ripper.rippers; | ||
|
||
import java.io.IOException; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.jsoup.Jsoup; | ||
import org.jsoup.nodes.Document; | ||
import org.jsoup.nodes.Element; | ||
|
||
import com.rarchives.ripme.ripper.AbstractRipper; | ||
|
||
public class KinkyshareRipper extends AbstractRipper { | ||
|
||
private static final String HOST = "kinkyshare"; | ||
private static final Logger logger = Logger.getLogger(KinkyshareRipper.class); | ||
|
||
public KinkyshareRipper(URL url) throws IOException { | ||
super(url); | ||
} | ||
|
||
@Override | ||
public String getHost() { | ||
return HOST; | ||
} | ||
|
||
/** | ||
* Reformat given URL into the desired format (all images on single page) | ||
*/ | ||
public URL sanitizeURL(URL url) throws MalformedURLException { | ||
return url; | ||
} | ||
|
||
@Override | ||
public String getGID(URL url) throws MalformedURLException { | ||
Pattern p; Matcher m; | ||
|
||
p = Pattern.compile("^.*kinkyshare.com/c/([0-9]+)/?.*$"); | ||
m = p.matcher(url.toExternalForm()); | ||
if (m.matches()) { | ||
return m.group(1); | ||
} | ||
|
||
throw new MalformedURLException( | ||
"Expected imagefap.com gallery formats: " | ||
+ "imagefap.com/gallery.php?gid=####... or " | ||
+ "imagefap.com/pictures/####..." | ||
+ " Got: " + url); | ||
} | ||
|
||
@Override | ||
public void rip() throws IOException { | ||
int index = 0; | ||
logger.info(" Retrieving " + this.url.toExternalForm()); | ||
Document albumDoc = Jsoup.connect(this.url.toExternalForm()).get(); | ||
for (Element thumb : albumDoc.select(".thumbnail > a > img")) { | ||
if (!thumb.hasAttr("src")) { | ||
continue; | ||
} | ||
String image = thumb.attr("src"); | ||
image = image.replaceAll( | ||
"/thumbs/", | ||
"/images/"); | ||
if (image.startsWith("/")) { | ||
image = "http://kinkyshare.com" + image; | ||
} | ||
index += 1; | ||
addURLToDownload(new URL(image), String.format("%03d_", index)); | ||
} | ||
waitForThreads(); | ||
} | ||
|
||
public boolean canRip(URL url) { | ||
if (!url.toExternalForm().contains("kinkyshare.com/c/")) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters