mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-13 01:14:14 +02:00
Replaced fuzzyExists and Fixed regex in redgifs user and search
- Added a dot in redgifs regex to account for them in usernames and search queries - Replaced fuzzyExists with better library efficient call that check the folder for existing file
This commit is contained in:
@@ -5,6 +5,7 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -79,7 +80,7 @@ class DownloadFileThread extends Thread {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (saveAs.exists() && !observer.tryResumeDownload() && !getFileExtFromMIME
|
if (saveAs.exists() && !observer.tryResumeDownload() && !getFileExtFromMIME
|
||||||
|| Utils.fuzzyExists(new File(saveAs.getParent()), saveAs.getName()) && getFileExtFromMIME
|
|| Utils.fuzzyExistsBetter(Paths.get(saveAs.getParent()), saveAs.getName()) && getFileExtFromMIME
|
||||||
&& !observer.tryResumeDownload()) {
|
&& !observer.tryResumeDownload()) {
|
||||||
if (Utils.getConfigBoolean("file.overwrite", false)) {
|
if (Utils.getConfigBoolean("file.overwrite", false)) {
|
||||||
logger.info("[!] " + Utils.getLocalizedString("deleting.existing.file") + prettySaveAs);
|
logger.info("[!] " + Utils.getLocalizedString("deleting.existing.file") + prettySaveAs);
|
||||||
|
@@ -55,12 +55,12 @@ public class RedgifsRipper extends AbstractHTMLRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Matcher isProfile() {
|
public Matcher isProfile() {
|
||||||
Pattern p = Pattern.compile("^https?://[wm.]*redgifs\\.com/users/([a-zA-Z0-9_-]+).*$");
|
Pattern p = Pattern.compile("^https?://[wm.]*redgifs\\.com/users/([a-zA-Z0-9_.-]+).*$");
|
||||||
return p.matcher(url.toExternalForm());
|
return p.matcher(url.toExternalForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Matcher isSearch() {
|
public Matcher isSearch() {
|
||||||
Pattern p = Pattern.compile("^https?://[wm.]*redgifs\\.com/gifs/browse/([a-zA-Z0-9_-]+).*$");
|
Pattern p = Pattern.compile("^https?://[wm.]*redgifs\\.com/gifs/browse/([a-zA-Z0-9_.-]+).*$");
|
||||||
return p.matcher(url.toExternalForm());
|
return p.matcher(url.toExternalForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ public class RedgifsRipper extends AbstractHTMLRipper {
|
|||||||
.ignoreContentType().get();
|
.ignoreContentType().get();
|
||||||
return (hasURLs(d).isEmpty()) ? null : d;
|
return (hasURLs(d).isEmpty()) ? null : d;
|
||||||
} else {
|
} else {
|
||||||
if (cursor.equals("")) {
|
if (cursor.equals("") || cursor.equals("null")) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
Document d = Http.url(new URL("https://napi.redgifs.com/v1/users/" + username + "/gfycats?count=" + count + "&cursor=" + cursor)).ignoreContentType().get();
|
Document d = Http.url(new URL("https://napi.redgifs.com/v1/users/" + username + "/gfycats?count=" + count + "&cursor=" + cursor)).ignoreContentType().get();
|
||||||
@@ -170,7 +170,7 @@ public class RedgifsRipper extends AbstractHTMLRipper {
|
|||||||
for (int i = 0; i < content.length(); i++) {
|
for (int i = 0; i < content.length(); i++) {
|
||||||
result.add(content.getJSONObject(i).getString("mp4Url"));
|
result.add(content.getJSONObject(i).getString("mp4Url"));
|
||||||
}
|
}
|
||||||
cursor = page.getString("cursor");
|
cursor = page.get("cursor").toString();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -880,6 +880,10 @@ public class Utils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean fuzzyExistsBetter(Path folder, String filename) {
|
||||||
|
return Files.exists(folder.resolve(filename));
|
||||||
|
}
|
||||||
|
|
||||||
public static String sanitizeSaveAs(String fileNameToSan) {
|
public static String sanitizeSaveAs(String fileNameToSan) {
|
||||||
return fileNameToSan.replaceAll("[\\\\/:*?\"<>|]", "_");
|
return fileNameToSan.replaceAll("[\\\\/:*?\"<>|]", "_");
|
||||||
}
|
}
|
||||||
|
@@ -60,6 +60,17 @@ public class RedditRipperTest extends RippersTest {
|
|||||||
testRipper(ripper);
|
testRipper(ripper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GFYCAT TEST Tests a gfycat URL with the gifdeliverynetwork/redgifs hosted video
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testRedditGfycatRedirectURL() throws IOException {
|
||||||
|
RedditRipper ripper = new RedditRipper(
|
||||||
|
new URL("https://www.reddit.com/r/NSFW_GIF/comments/ennwsa/gorgeous_tits/"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Tag("flaky")
|
@Tag("flaky")
|
||||||
public void testRedditGallery() throws IOException{
|
public void testRedditGallery() throws IOException{
|
||||||
|
Reference in New Issue
Block a user