mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-18 11:41:21 +02:00
Added Soundgasm Ripper
- Created new ripper to scrape soundgasm.net urls and obtain their audio - Added ripper to RipUtils so its deteced in the reddit ripper - Created test for basic and reddit urls and both passed
This commit is contained in:
@@ -0,0 +1,68 @@
|
|||||||
|
package com.rarchives.ripme.ripper.rippers;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
||||||
|
import com.rarchives.ripme.utils.Http;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
import org.jsoup.nodes.Element;
|
||||||
|
import org.jsoup.select.Elements;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class SoundgasmRipper extends AbstractHTMLRipper {
|
||||||
|
|
||||||
|
private static final String HOST = "soundgasm.net";
|
||||||
|
|
||||||
|
public SoundgasmRipper(URL url) throws IOException {
|
||||||
|
super(new URL(url.toExternalForm()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getDomain() { return "soundgasm.net"; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHost() { return "soundgasm"; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGID(URL url) throws MalformedURLException {
|
||||||
|
Pattern p = Pattern.compile("^/u/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).*$");
|
||||||
|
Matcher m = p.matcher(url.getFile());
|
||||||
|
if (m.find()) {
|
||||||
|
return m.group(m.groupCount());
|
||||||
|
}
|
||||||
|
throw new MalformedURLException(
|
||||||
|
"Expected soundgasm.net format: "
|
||||||
|
+ "soundgasm.net/u/username/id or "
|
||||||
|
+ " Got: " + url);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document getFirstPage() throws IOException {
|
||||||
|
return Http.url(url).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getURLsFromPage(Document page) {
|
||||||
|
List<String> res = new ArrayList<>();
|
||||||
|
|
||||||
|
Elements script = page.select("script");
|
||||||
|
Pattern p = Pattern.compile("m4a\\:\\s\"(https?:.*)\\\"");
|
||||||
|
|
||||||
|
for (Element e: script) {
|
||||||
|
Matcher m = p.matcher(e.data());
|
||||||
|
if (m.find()) { res.add(m.group(1)); }
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downloadURL(URL url, int index) {
|
||||||
|
addURLToDownload(url, getPrefix(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -14,6 +14,7 @@ import com.rarchives.ripme.ripper.rippers.ImgurRipper;
|
|||||||
import com.rarchives.ripme.ripper.rippers.RedgifsRipper;
|
import com.rarchives.ripme.ripper.rippers.RedgifsRipper;
|
||||||
import com.rarchives.ripme.ripper.rippers.VidbleRipper;
|
import com.rarchives.ripme.ripper.rippers.VidbleRipper;
|
||||||
import com.rarchives.ripme.ripper.rippers.GfycatRipper;
|
import com.rarchives.ripme.ripper.rippers.GfycatRipper;
|
||||||
|
import com.rarchives.ripme.ripper.rippers.SoundgasmRipper;
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
@@ -127,6 +128,20 @@ public class RipUtils {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
else if (url.toExternalForm().contains("soundgasm.net")) {
|
||||||
|
try {
|
||||||
|
logger.info("Getting soundgasm page " + url);
|
||||||
|
SoundgasmRipper r = new SoundgasmRipper(url);
|
||||||
|
Document tempDoc = r.getFirstPage();
|
||||||
|
for (String u : r.getURLsFromPage(tempDoc)) {
|
||||||
|
result.add(new URL(u));
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Do nothing
|
||||||
|
logger.warn("Exception while retrieving soundgasm page:", e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Pattern p = Pattern.compile("https?://i.reddituploads.com/([a-zA-Z0-9]+)\\?.*");
|
Pattern p = Pattern.compile("https?://i.reddituploads.com/([a-zA-Z0-9]+)\\?.*");
|
||||||
Matcher m = p.matcher(url.toExternalForm());
|
Matcher m = p.matcher(url.toExternalForm());
|
||||||
|
@@ -0,0 +1,23 @@
|
|||||||
|
package com.rarchives.ripme.tst.ripper.rippers;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.ripper.rippers.RedditRipper;
|
||||||
|
import org.junit.Test;
|
||||||
|
import com.rarchives.ripme.ripper.rippers.SoundgasmRipper;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class SoundgasmRipperTest extends RippersTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSoundgasmURLs() throws IOException {
|
||||||
|
SoundgasmRipper ripper = new SoundgasmRipper(new URL("https://soundgasm.net/u/_Firefly_xoxo/Rambles-with-my-Lovense"));
|
||||||
|
testRipper(ripper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRedditSoundgasmURL() throws IOException {
|
||||||
|
RedditRipper ripper = new RedditRipper(new URL("https://www.reddit.com/r/gonewildaudio/comments/kn1bvj/f4m_mistress_controlled_my_lovense_while_i_tried/"));
|
||||||
|
testRipper(ripper);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user