1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-24 14:33:17 +02:00

Fixes for gfycat thumbs urls.

This commit is contained in:
rtsketo
2019-08-22 06:00:47 +03:00
parent 0150c5fa37
commit 1c555c01f1

View File

@@ -29,7 +29,7 @@ public class GfycatRipper extends AbstractHTMLRipper {
public GfycatRipper(URL url) throws IOException { public GfycatRipper(URL url) throws IOException {
super(url); super(new URL(url.toExternalForm().split("-")[0].replace("thumbs.", "")));
} }
@Override @Override
@@ -76,15 +76,16 @@ public class GfycatRipper extends AbstractHTMLRipper {
@Override @Override
public String getGID(URL url) throws MalformedURLException { public String getGID(URL url) throws MalformedURLException {
Pattern p = Pattern.compile("^https?://[wm.]*gfycat\\.com/@?([a-zA-Z0-9]+).*$"); Pattern p = Pattern.compile("^https?://(thumbs\\.|[wm\\.]*)gfycat\\.com/@?([a-zA-Z0-9]+).*$");
Matcher m = p.matcher(url.toExternalForm()); Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) {
return m.group(1); if (m.matches())
} return m.group(2);
throw new MalformedURLException( throw new MalformedURLException(
"Expected gfycat.com format:" "Expected gfycat.com format: "
+ "gfycat.com/id" + "gfycat.com/id or "
+ "thumbs.gfycat.com/id.gif"
+ " Got: " + url); + " Got: " + url);
} }
@@ -92,7 +93,7 @@ public class GfycatRipper extends AbstractHTMLRipper {
t = t.replaceAll("<html>\n" + t = t.replaceAll("<html>\n" +
" <head></head>\n" + " <head></head>\n" +
" <body>", ""); " <body>", "");
t.replaceAll("</body>\n" + t = t.replaceAll("</body>\n" +
"</html>", ""); "</html>", "");
t = t.replaceAll("\n", ""); t = t.replaceAll("\n", "");
t = t.replaceAll("=\"\"", ""); t = t.replaceAll("=\"\"", "");