From 5c6b68a42895d82f51e6369dcb4913c8498e60f9 Mon Sep 17 00:00:00 2001 From: Gaboso Date: Thu, 31 May 2018 09:21:44 -0400 Subject: [PATCH] Replaced the if-else statement by a single return statement. Replaced use of Collection.size () by Collection.isEmpty () in ViddmeRipper. --- .../com/rarchives/ripme/ripper/rippers/BatoRipper.java | 10 ++-------- .../rarchives/ripme/ripper/rippers/NhentaiRipper.java | 5 +---- .../ripme/ripper/rippers/PichunterRipper.java | 5 +---- .../rarchives/ripme/ripper/rippers/Rule34Ripper.java | 5 +---- .../rarchives/ripme/ripper/rippers/WebtoonsRipper.java | 5 +---- .../rarchives/ripme/ripper/rippers/XhamsterRipper.java | 5 +---- .../ripme/ripper/rippers/video/ViddmeRipper.java | 2 +- 7 files changed, 8 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/BatoRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/BatoRipper.java index a3350e68..5978bff5 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/BatoRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/BatoRipper.java @@ -57,10 +57,7 @@ public class BatoRipper extends AbstractHTMLRipper { public boolean pageContainsAlbums(URL url) { Pattern p = Pattern.compile("https?://bato.to/series/([\\d]+)/?"); Matcher m = p.matcher(url.toExternalForm()); - if (m.matches()) { - return true; - } - return false; + return m.matches(); } @Override @@ -94,10 +91,7 @@ public class BatoRipper extends AbstractHTMLRipper { p = Pattern.compile("https?://bato.to/chapter/([\\d]+)/?"); m = p.matcher(url.toExternalForm()); - if (m.matches()) { - return true; - } - return false; + return m.matches(); } @Override diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/NhentaiRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/NhentaiRipper.java index 5dc3fd93..7752f18c 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/NhentaiRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/NhentaiRipper.java @@ -35,10 +35,7 @@ public class NhentaiRipper extends AbstractHTMLRipper { public boolean pageContainsAlbums(URL url) { Pattern pa = Pattern.compile("^https?://nhentai\\.net/tag/([a-zA-Z0-9_\\-]+)/?"); Matcher ma = pa.matcher(url.toExternalForm()); - if (ma.matches()) { - return true; - } - return false; + return ma.matches(); } @Override diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java index d9f63626..e6c5d110 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/PichunterRipper.java @@ -60,10 +60,7 @@ public class PichunterRipper extends AbstractHTMLRipper { private boolean isPhotoSet(URL url) { Pattern p = Pattern.compile("https?://www.pichunter.com/gallery/\\d+/(\\S*)/?"); Matcher m = p.matcher(url.toExternalForm()); - if (m.matches()) { - return true; - } - return false; + return m.matches(); } @Override diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/Rule34Ripper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/Rule34Ripper.java index b7e0f7b0..681738fa 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/Rule34Ripper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/Rule34Ripper.java @@ -37,10 +37,7 @@ public class Rule34Ripper extends AbstractHTMLRipper { public boolean canRip(URL url){ Pattern p = Pattern.compile("https?://rule34.xxx/index.php\\?page=post&s=list&tags=([\\S]+)"); Matcher m = p.matcher(url.toExternalForm()); - if (m.matches()) { - return true; - } - return false; + return m.matches(); } @Override diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/WebtoonsRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/WebtoonsRipper.java index de785a44..ded3ce2c 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/WebtoonsRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/WebtoonsRipper.java @@ -38,10 +38,7 @@ public class WebtoonsRipper extends AbstractHTMLRipper { public boolean canRip(URL url) { Pattern pat = Pattern.compile("https?://www.webtoons.com/[a-zA-Z-_]+/[a-zA-Z_-]+/([a-zA-Z0-9_-]*)/[a-zA-Z0-9_-]+/\\S*"); Matcher mat = pat.matcher(url.toExternalForm()); - if (mat.matches()) { - return true; - } - return false; + return mat.matches(); } diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java index b92aa9dd..ce01f1cf 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java @@ -64,10 +64,7 @@ public class XhamsterRipper extends AbstractHTMLRipper { public boolean canRip(URL url) { Pattern p = Pattern.compile("^https?://[wmde.]*xhamster\\.com/photos/gallery/.*?(\\d+)$"); Matcher m = p.matcher(url.toExternalForm()); - if (m.matches()) { - return true; - } - return false; + return m.matches(); } @Override diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/video/ViddmeRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/video/ViddmeRipper.java index 6084607a..f36d7ce4 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/video/ViddmeRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/video/ViddmeRipper.java @@ -56,7 +56,7 @@ public class ViddmeRipper extends VideoRipper { logger.info(" Retrieving " + this.url.toExternalForm()); Document doc = Http.url(this.url).get(); Elements videos = doc.select("meta[name=twitter:player:stream]"); - if (videos.size() == 0) { + if (videos.isEmpty()) { throw new IOException("Could not find twitter:player:stream at " + url); } String vidUrl = videos.first().attr("content");