From 3414364ce6e90a299df2521b8ab91ffa7b4bc50d Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Tue, 13 Aug 2019 19:41:16 -0400 Subject: [PATCH 01/21] Fixed Xhamster ripper; Added support xhamster2.com and xhamster.desi --- .../ripme/ripper/rippers/XhamsterRipper.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) 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 2eaa5c9e6..9faf5c095 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java @@ -17,7 +17,7 @@ // WARNING // This ripper changes all requests to use the MOBILE version of the site -// If you're chaning anything be sure to use the mobile sites html/css or you\re just wasting your time! +// If you're changing anything be sure to use the mobile sites html/css or you're just wasting your time! // WARNING public class XhamsterRipper extends AbstractHTMLRipper { @@ -45,9 +45,9 @@ public String getDomain() { @Override public URL sanitizeURL(URL url) throws MalformedURLException { String URLToReturn = url.toExternalForm(); - URLToReturn = URLToReturn.replaceAll("xhamster.one", "xhamster.com"); - URLToReturn = URLToReturn.replaceAll("m.xhamster.com", "xhamster.com"); - URLToReturn = URLToReturn.replaceAll("\\w\\w.xhamster.com", "xhamster.com"); + URLToReturn = URLToReturn.replaceAll("xhamster\\.(com|one|desi)", "xhamster.com"); + URLToReturn = URLToReturn.replaceAll("m.xhamster\\.(com|one|desi)", "xhamster.com"); + URLToReturn = URLToReturn.replaceAll("\\w\\w\\.xhamster\\.(com|one|desi)", "xhamster.com"); if (!isVideoUrl(url)) { URLToReturn = URLToReturn.replaceAll("xhamster.com", "m.xhamster.com"); } @@ -114,17 +114,17 @@ public Document getFirstPage() throws IOException { @Override public boolean canRip(URL url) { - Pattern p = Pattern.compile("^https?://([\\w\\w]*\\.)?xhamster\\.(com|one)/photos/gallery/.*?(\\d+)$"); + Pattern p = Pattern.compile("^https?://([\\w\\w]*\\.)?xhamster2?\\.(com|one|desi)/photos/gallery/.*?(\\d+)$"); Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return true; } - p = Pattern.compile("^https?://[\\w\\w.]*xhamster\\.(com|one)/users/([a-zA-Z0-9_-]+)/(photos|videos)(/\\d+)?"); + p = Pattern.compile("^https?://[\\w\\w.]*xhamster2?\\.(com|one|desi)/users/([a-zA-Z0-9_-]+)/(photos|videos)(/\\d+)?"); m = p.matcher(url.toExternalForm()); if (m.matches()) { return true; } - p = Pattern.compile("^https?://.*xhamster\\.(com|one)/(movies|videos)/.*$"); + p = Pattern.compile("^https?://.*xhamster2?\\.(com|one|desi)/(movies|videos)/.*$"); m = p.matcher(url.toExternalForm()); if (m.matches()) { return true; @@ -133,7 +133,7 @@ public boolean canRip(URL url) { } private boolean isVideoUrl(URL url) { - Pattern p = Pattern.compile("^https?://.*xhamster\\.com/(movies|videos)/.*$"); + Pattern p = Pattern.compile("^https?://.*xhamster2?\\.(com|one|desi)/(movies|videos)/.*$"); Matcher m = p.matcher(url.toExternalForm()); return m.matches(); } @@ -155,9 +155,16 @@ public List getURLsFromPage(Document doc) { List result = new ArrayList<>(); if (!isVideoUrl(url)) { for (Element page : doc.select("div.items > div.item-container > a.item")) { + // Make sure we don't waste time running the loop if the ripper has been stopped + if (isStopped()) { + break; + } String pageWithImageUrl = page.attr("href"); try { - String image = Http.url(new URL(pageWithImageUrl)).get().select("div.picture_container > a > img").attr("src"); + // This works around some redirect fuckery xhamster likes to do where visiting m.xhamster.com sends to + // the page chamster.com but displays the mobile site from m.xhamster.com + pageWithImageUrl = pageWithImageUrl.replaceAll("://xhamster\\.", "://m.xhamster."); + String image = Http.url(new URL(pageWithImageUrl)).get().select("a > img#photoCurr").attr("src"); downloadFile(image); } catch (IOException e) { LOGGER.error("Was unable to load page " + pageWithImageUrl); From 6b8f379e9de701f2dd2dd0038dd0258ea568179f Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Tue, 13 Aug 2019 19:47:10 -0400 Subject: [PATCH 02/21] Added support for xhamster2.com domain --- .../rarchives/ripme/ripper/rippers/XhamsterRipper.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 9faf5c095..2dbcec2a4 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java @@ -49,7 +49,7 @@ public URL sanitizeURL(URL url) throws MalformedURLException { URLToReturn = URLToReturn.replaceAll("m.xhamster\\.(com|one|desi)", "xhamster.com"); URLToReturn = URLToReturn.replaceAll("\\w\\w\\.xhamster\\.(com|one|desi)", "xhamster.com"); if (!isVideoUrl(url)) { - URLToReturn = URLToReturn.replaceAll("xhamster.com", "m.xhamster.com"); + URLToReturn = URLToReturn.replaceAll("xhamster2?.com", "m.xhamster.com"); } URL san_url = new URL(URLToReturn); LOGGER.info("sanitized URL is " + san_url.toExternalForm()); @@ -58,17 +58,17 @@ public URL sanitizeURL(URL url) throws MalformedURLException { @Override public String getGID(URL url) throws MalformedURLException { - Pattern p = Pattern.compile("^https?://[\\w\\w.]*xhamster\\.com/photos/gallery/.*?(\\d+)$"); + Pattern p = Pattern.compile("^https?://[\\w\\w.]*xhamster2?\\.com/photos/gallery/.*?(\\d+)$"); Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(1); } - p = Pattern.compile("^https?://[\\w\\w.]*xhamster\\.com/users/([a-zA-Z0-9_-]+)/(photos|videos)(/\\d+)?"); + p = Pattern.compile("^https?://[\\w\\w.]*xhamster2?\\.com/users/([a-zA-Z0-9_-]+)/(photos|videos)(/\\d+)?"); m = p.matcher(url.toExternalForm()); if (m.matches()) { return "user_" + m.group(1); } - p = Pattern.compile("^https?://.*xhamster\\.com/(movies|videos)/(.*)$"); + p = Pattern.compile("^https?://.*xhamster2?\\.com/(movies|videos)/(.*)$"); m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(2); @@ -164,6 +164,7 @@ public List getURLsFromPage(Document doc) { // This works around some redirect fuckery xhamster likes to do where visiting m.xhamster.com sends to // the page chamster.com but displays the mobile site from m.xhamster.com pageWithImageUrl = pageWithImageUrl.replaceAll("://xhamster\\.", "://m.xhamster."); + pageWithImageUrl = pageWithImageUrl.replaceAll("://xhamster2\\.", "://m.xhamster."); String image = Http.url(new URL(pageWithImageUrl)).get().select("a > img#photoCurr").attr("src"); downloadFile(image); } catch (IOException e) { From 6f6d1b9094486a12b4f35706e6a8343a523a1db0 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Tue, 13 Aug 2019 19:47:42 -0400 Subject: [PATCH 03/21] Marked tests as @Test and added tests for newly support domains --- .../ripper/rippers/XhamsterRipperTest.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XhamsterRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XhamsterRipperTest.java index 3ccccb49c..96a9295e4 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XhamsterRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XhamsterRipperTest.java @@ -5,24 +5,41 @@ import com.rarchives.ripme.ripper.rippers.XhamsterRipper; import org.jsoup.nodes.Document; +import org.junit.jupiter.api.Test; -public class XhamsterRipperTest extends RippersTest { +public class XhamsterRipperTest extends RippersTest { + @Test public void testXhamsterAlbum1() throws IOException { XhamsterRipper ripper = new XhamsterRipper(new URL("https://xhamster.com/photos/gallery/sexy-preggo-girls-9026608")); testRipper(ripper); } - + @Test + public void testXhamster2Album() throws IOException { + XhamsterRipper ripper = new XhamsterRipper(new URL("https://xhamster2.com/photos/gallery/sexy-preggo-girls-9026608")); + testRipper(ripper); + } + @Test public void testXhamsterAlbum2() throws IOException { XhamsterRipper ripper = new XhamsterRipper(new URL("https://xhamster.com/photos/gallery/japanese-dolls-4-asahi-mizuno-7254664")); testRipper(ripper); } - + @Test + public void testXhamsterAlbumOneDomain() throws IOException { + XhamsterRipper ripper = new XhamsterRipper(new URL("https://xhamster.one/photos/gallery/japanese-dolls-4-asahi-mizuno-7254664")); + testRipper(ripper); + } + @Test + public void testXhamsterAlbumDesiDomain() throws IOException { + XhamsterRipper ripper = new XhamsterRipper(new URL("https://xhamster.desi/photos/gallery/japanese-dolls-4-asahi-mizuno-7254664")); + testRipper(ripper); + } + @Test public void testXhamsterVideo() throws IOException { XhamsterRipper ripper = new XhamsterRipper(new URL("https://xhamster.com/videos/brazzers-busty-big-booty-milf-lisa-ann-fucks-her-masseur-1492828")); testRipper(ripper); } - + @Test public void testBrazilianXhamster() throws IOException { XhamsterRipper ripper = new XhamsterRipper(new URL("https://pt.xhamster.com/photos/gallery/silvana-7105696")); testRipper(ripper); @@ -33,7 +50,7 @@ public void testGetGID() throws IOException { XhamsterRipper ripper = new XhamsterRipper(url); assertEquals("7254664", ripper.getGID(url)); } - + @Test public void testGetNextPage() throws IOException { XhamsterRipper ripper = new XhamsterRipper(new URL("https://pt.xhamster.com/photos/gallery/mega-compil-6-10728626")); Document doc = ripper.getFirstPage(); From a2fe593e39f56e51ea2f6108f0209eafb277a79e Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Tue, 13 Aug 2019 20:57:45 -0400 Subject: [PATCH 04/21] Reenabled accidently disabled tests --- .../tst/ripper/rippers/ChanRipperTest.java | 9 +++--- .../ripper/rippers/CheveretoRipperTest.java | 4 ++- .../ripper/rippers/ComicextraRipperTest.java | 5 ++-- .../ripper/rippers/DribbbleRipperTest.java | 2 ++ .../tst/ripper/rippers/E621RipperTest.java | 5 ++-- .../tst/ripper/rippers/EhentaiRipperTest.java | 3 ++ .../ripper/rippers/EightmusesRipperTest.java | 6 ++-- .../tst/ripper/rippers/EromeRipperTest.java | 11 +++---- .../rippers/FivehundredpxRipperTest.java | 29 ++++++++++--------- .../ripper/rippers/FuraffinityRipperTest.java | 7 +++-- .../ripper/rippers/FuskatorRipperTest.java | 4 ++- .../tst/ripper/rippers/GfycatRipperTest.java | 3 ++ .../rippers/GirlsOfDesireRipperTest.java | 2 ++ .../tst/ripper/rippers/HbrowseRipperTest.java | 2 ++ .../ripper/rippers/Hentai2readRipperTest.java | 2 ++ .../ripper/rippers/HentaicafeRipperTest.java | 3 ++ .../rippers/HentaifoundryRipperTest.java | 6 ++-- .../ripper/rippers/HentaiimageRipperTest.java | 3 +- .../ripper/rippers/HqpornerRipperTest.java | 11 +++---- .../ripper/rippers/ImagearnRipperTest.java | 2 ++ .../ripper/rippers/ImagebamRipperTest.java | 2 ++ .../ripper/rippers/ImagefapRipperTest.java | 3 ++ .../tst/ripper/rippers/ImgboxRipperTest.java | 2 ++ .../ripper/rippers/InstagramRipperTest.java | 8 +++-- .../ripper/rippers/JagodibujaRipperTest.java | 2 ++ .../ripper/rippers/LusciousRipperTest.java | 4 ++- .../ripper/rippers/MotherlessRipperTest.java | 1 - .../tst/ripper/rippers/MulemaxRipperTest.java | 3 +- .../rippers/MyhentaicomicsRipperTest.java | 6 ++-- .../rippers/MyhentaigalleryRipperTest.java | 3 +- .../ripper/rippers/NewgroundsRipperTest.java | 3 +- .../ripper/rippers/NewsfilterRipperTest.java | 3 +- .../tst/ripper/rippers/NhentaiRipperTest.java | 2 ++ .../tst/ripper/rippers/PahealRipperTest.java | 2 ++ .../ripper/rippers/PicstatioRipperTest.java | 3 +- .../rippers/PorncomixDotOneRipperTest.java | 2 ++ .../tst/ripper/rippers/PornhubRipperTest.java | 3 ++ .../tst/ripper/rippers/Rule34RipperTest.java | 2 ++ .../rippers/SinnercomicsRipperTest.java | 2 ++ .../ripper/rippers/SpankBangRipperTest.java | 3 +- .../ripper/rippers/TapasticRipperTest.java | 2 ++ .../ripper/rippers/TeenplanetRipperTest.java | 2 ++ .../rippers/TheyiffgalleryRipperTest.java | 2 ++ .../tst/ripper/rippers/TsuminoRipperTest.java | 4 ++- .../tst/ripper/rippers/VidbleRipperTest.java | 2 ++ .../ripper/rippers/ViewcomicRipperTest.java | 2 ++ .../tst/ripper/rippers/VkRipperTest.java | 4 +++ .../ripper/rippers/WebtoonsRipperTest.java | 6 ++-- .../rippers/WordpressComicRipperTest.java | 18 ++++++------ .../tst/ripper/rippers/XvideosRipperTest.java | 3 +- .../tst/ripper/rippers/YoupornRipperTest.java | 2 ++ .../tst/ripper/rippers/YuvutuRipperTest.java | 5 ++-- .../tst/ripper/rippers/ZizkiRipperTest.java | 3 +- 53 files changed, 162 insertions(+), 71 deletions(-) diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ChanRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ChanRipperTest.java index 2ac29e401..229950020 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ChanRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ChanRipperTest.java @@ -11,9 +11,10 @@ import com.rarchives.ripme.ripper.rippers.ripperhelpers.ChanSite; import com.rarchives.ripme.utils.Http; import org.jsoup.nodes.Document; +import org.junit.jupiter.api.Test; public class ChanRipperTest extends RippersTest { - + @Test public void testChanURLFailures() throws IOException { List failURLs = new ArrayList<>(); // URLs that should not work @@ -26,7 +27,7 @@ public void testChanURLFailures() throws IOException { } } } - + @Test public void testChanURLPasses() throws IOException { List passURLs = new ArrayList<>(); // URLs that should work @@ -43,7 +44,7 @@ public void testChanURLPasses() throws IOException { deleteDir(ripper.getWorkingDir()); } } - + @Test public void testChanStringParsing() throws IOException { List site1 = Arrays.asList("site1.com"); List site1Cdns = Arrays.asList("cnd1.site1.com", "cdn2.site2.biz"); @@ -59,7 +60,7 @@ public void testChanStringParsing() throws IOException { assertEquals(chansFromConfig.get(1).getDomains(), site2); assertEquals(chansFromConfig.get(1).getCdns(), site2Cdns); } - + @Test public void testChanRipper() throws IOException { List contentURLs = new ArrayList<>(); contentURLs.add(new URL(getRandomThreadDesuarchive())); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/CheveretoRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/CheveretoRipperTest.java index 6fd20060b..385464da5 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/CheveretoRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/CheveretoRipperTest.java @@ -4,13 +4,15 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.CheveretoRipper; +import org.junit.jupiter.api.Test; public class CheveretoRipperTest extends RippersTest { + @Test public void testTagFox() throws IOException { CheveretoRipper ripper = new CheveretoRipper(new URL("http://tag-fox.com/album/Thjb")); testRipper(ripper); } - + @Test public void testSubdirAlbum() throws IOException { CheveretoRipper ripper = new CheveretoRipper(new URL("https://kenzato.uk/booru/album/TnEc")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ComicextraRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ComicextraRipperTest.java index a3d66d50a..ffe0f12bf 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ComicextraRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ComicextraRipperTest.java @@ -3,15 +3,16 @@ import java.io.IOException; import java.net.URL; import com.rarchives.ripme.ripper.rippers.ComicextraRipper; +import org.junit.jupiter.api.Test; public class ComicextraRipperTest extends RippersTest { - + @Test public void testComicUrl() throws IOException { URL url = new URL("https://www.comicextra.com/comic/karma-police"); ComicextraRipper ripper = new ComicextraRipper(url); testRipper(ripper); } - + @Test public void testChapterUrl() throws IOException { URL url = new URL("https://www.comicextra.com/v-for-vendetta/chapter-1"); ComicextraRipper ripper = new ComicextraRipper(url); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DribbbleRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DribbbleRipperTest.java index ba4b9ec16..36b56d6a6 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DribbbleRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DribbbleRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.DribbbleRipper; +import org.junit.jupiter.api.Test; public class DribbbleRipperTest extends RippersTest { + @Test public void testDribbbleRip() throws IOException { DribbbleRipper ripper = new DribbbleRipper(new URL("https://dribbble.com/typogriff")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/E621RipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/E621RipperTest.java index 01cb15325..5f7165b2a 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/E621RipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/E621RipperTest.java @@ -4,18 +4,19 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.E621Ripper; +import org.junit.jupiter.api.Test; public class E621RipperTest extends RippersTest { public void testRip() throws IOException { E621Ripper ripper = new E621Ripper(new URL("https://e621.net/post/index/1/beach")); testRipper(ripper); } - + @Test public void testFlashOrWebm() throws IOException { E621Ripper ripper = new E621Ripper(new URL("https://e621.net/post/index/1/gif")); testRipper(ripper); } - + @Test public void testGetNextPage() throws IOException { E621Ripper nextPageRipper = new E621Ripper(new URL("https://e621.net/post/index/1/cosmicminerals")); try { diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EhentaiRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EhentaiRipperTest.java index 8e87f8a58..78234951b 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EhentaiRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EhentaiRipperTest.java @@ -6,14 +6,17 @@ import com.rarchives.ripme.ripper.rippers.EHentaiRipper; import com.rarchives.ripme.utils.RipUtils; +import org.junit.jupiter.api.Test; public class EhentaiRipperTest extends RippersTest { + @Test public void testEHentaiAlbum() throws IOException { EHentaiRipper ripper = new EHentaiRipper(new URL("https://e-hentai.org/g/1144492/e823bdf9a5/")); testRipper(ripper); } // Test the tag black listing + @Test public void testTagBlackList() throws IOException { URL url = new URL("https://e-hentai.org/g/1228503/1a2f455f96/"); EHentaiRipper ripper = new EHentaiRipper(url); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EightmusesRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EightmusesRipperTest.java index d41330553..2cdbcb2e5 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EightmusesRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EightmusesRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.EightmusesRipper; +import org.junit.jupiter.api.Test; public class EightmusesRipperTest extends RippersTest { + @Test public void testEightmusesAlbum() throws IOException { // A simple image album EightmusesRipper ripper = new EightmusesRipper(new URL("https://www.8muses.com/comix/album/Affect3D-Comics/TheDude3DX/Lust-Unleashed-The-Urge-To-Explore")); @@ -17,12 +19,12 @@ public void testEightmusesAlbum() throws IOException { ripper = new EightmusesRipper(new URL("https://www.8muses.com/comix/album/Blacknwhitecomics_com-Comix/BlacknWhiteComics/The-Mayor")); testRipper(ripper); } - + @Test public void testGID() throws IOException { EightmusesRipper ripper = new EightmusesRipper(new URL("https://www.8muses.com/comix/album/Affect3D-Comics/TheDude3DX/Lust-Unleashed-The-Urge-To-Explore")); assertEquals("Affect3D-Comics", ripper.getGID(new URL("https://www.8muses.com/comics/album/Affect3D-Comics/TheDude3DX/Lust-Unleashed-The-Urge-To-Explore"))); } - + @Test public void testGetSubdir() throws IOException { EightmusesRipper ripper = new EightmusesRipper(new URL("https://www.8muses.com/comix/album/Affect3D-Comics/TheDude3DX/Lust-Unleashed-The-Urge-To-Explore")); assertEquals("After-Party-Issue-1", ripper.getSubdir("After Party - Issue 1")); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EromeRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EromeRipperTest.java index 38fb43e6c..4e7241af9 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EromeRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/EromeRipperTest.java @@ -5,27 +5,28 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.EromeRipper; +import org.junit.jupiter.api.Test; public class EromeRipperTest extends RippersTest { - + @Test public void testGetGIDProfilePage() throws IOException { URL url = new URL("https://www.erome.com/Jay-Jenna"); EromeRipper ripper = new EromeRipper(url); assertEquals("Jay-Jenna", ripper.getGID(url)); } - + @Test public void testGetGIDAlbum() throws IOException { URL url = new URL("https://www.erome.com/a/KbDAM1XT"); EromeRipper ripper = new EromeRipper(url); assertEquals("KbDAM1XT", ripper.getGID(url)); } - + @Test public void testGetAlbumsToQueue() throws IOException { URL url = new URL("https://www.erome.com/Jay-Jenna"); EromeRipper ripper = new EromeRipper(url); assert (2 >= ripper.getAlbumsToQueue(ripper.getFirstPage()).size()); } - + @Test public void testPageContainsAlbums() throws IOException { URL url = new URL("https://www.erome.com/Jay-Jenna"); EromeRipper ripper = new EromeRipper(url); @@ -38,7 +39,7 @@ public void testRip() throws IOException { EromeRipper ripper = new EromeRipper(url); testRipper(ripper); } - + @Test public void testGetURLsFromPage() throws IOException { URL url = new URL("https://www.erome.com/a/Tak8F2h6"); EromeRipper ripper = new EromeRipper(url); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FivehundredpxRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FivehundredpxRipperTest.java index 214220b86..0392b36ed 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FivehundredpxRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FivehundredpxRipperTest.java @@ -1,15 +1,16 @@ -//package com.rarchives.ripme.tst.ripper.rippers; -// -//import java.io.IOException; -//import java.net.URL; -// -//import com.rarchives.ripme.ripper.rippers.FivehundredpxRipper; -// -//public class FivehundredpxRipperTest extends RippersTest { -// public void test500pxAlbum() throws IOException { -// FivehundredpxRipper ripper = new FivehundredpxRipper(new URL("https://marketplace.500px.com/alexander_hurman")); -// testRipper(ripper); -// } -//} +package com.rarchives.ripme.tst.ripper.rippers; -// Ripper is broken. See https://github.com/RipMeApp/ripme/issues/438 \ No newline at end of file +import java.io.IOException; +import java.net.URL; + +import com.rarchives.ripme.ripper.rippers.FivehundredpxRipper; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +public class FivehundredpxRipperTest extends RippersTest { + @Test @Disabled("Ripper is broken. See https://github.com/RipMeApp/ripme/issues/438") + public void test500pxAlbum() throws IOException { + FivehundredpxRipper ripper = new FivehundredpxRipper(new URL("https://marketplace.500px.com/alexander_hurman")); + testRipper(ripper); + } +} \ No newline at end of file diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FuraffinityRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FuraffinityRipperTest.java index f604a7dc4..1f397bcb9 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FuraffinityRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FuraffinityRipperTest.java @@ -4,14 +4,15 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.FuraffinityRipper; +import org.junit.jupiter.api.Test; public class FuraffinityRipperTest extends RippersTest { - + @Test public void testFuraffinityAlbum() throws IOException { FuraffinityRipper ripper = new FuraffinityRipper(new URL("https://www.furaffinity.net/gallery/spencerdragon/")); testRipper(ripper); } - + @Test public void testFuraffinityScrap() throws IOException { FuraffinityRipper ripper = new FuraffinityRipper(new URL("http://www.furaffinity.net/scraps/sssonic2/")); testRipper(ripper); @@ -22,7 +23,7 @@ public void testGetGID() throws IOException { FuraffinityRipper ripper = new FuraffinityRipper(url); assertEquals("mustardgas", ripper.getGID(url)); } - + @Test public void testLogin() throws IOException { URL url = new URL("https://www.furaffinity.net/gallery/mustardgas/"); FuraffinityRipper ripper = new FuraffinityRipper(url); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FuskatorRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FuskatorRipperTest.java index ded62ad0d..334cd6ff2 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FuskatorRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/FuskatorRipperTest.java @@ -4,13 +4,15 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.FuskatorRipper; +import org.junit.jupiter.api.Test; public class FuskatorRipperTest extends RippersTest { + @Test public void testFuskatorAlbum() throws IOException { FuskatorRipper ripper = new FuskatorRipper(new URL("https://fuskator.com/thumbs/hqt6pPXAf9z/Shaved-Blonde-Babe-Katerina-Ambre.html")); testRipper(ripper); } - + @Test public void testUrlsWithTiled() throws IOException { FuskatorRipper ripper = new FuskatorRipper(new URL("https://fuskator.com/thumbs/hsrzk~UIFmJ/Blonde-Babe-Destiny-Dixon-Playing-With-Black-Dildo.html")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GfycatRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GfycatRipperTest.java index 2579d7e44..014141b18 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GfycatRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GfycatRipperTest.java @@ -1,6 +1,8 @@ package com.rarchives.ripme.tst.ripper.rippers; import com.rarchives.ripme.ripper.rippers.GfycatRipper; +import org.junit.jupiter.api.Test; + import java.io.IOException; import java.net.URL; @@ -11,6 +13,7 @@ public class GfycatRipperTest extends RippersTest { * Rips correctly formatted URL directly from Gfycat * @throws IOException */ + @Test public void testGfycatGoodURL() throws IOException{ GfycatRipper ripper = new GfycatRipper(new URL("https://gfycat.com/TemptingExcellentIchthyosaurs")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GirlsOfDesireRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GirlsOfDesireRipperTest.java index fa51a262c..07fb86161 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GirlsOfDesireRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/GirlsOfDesireRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.GirlsOfDesireRipper; +import org.junit.jupiter.api.Test; public class GirlsOfDesireRipperTest extends RippersTest { + @Test public void testGirlsofdesireAlbum() throws IOException { GirlsOfDesireRipper ripper = new GirlsOfDesireRipper(new URL("http://www.girlsofdesire.org/galleries/krillia/")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HbrowseRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HbrowseRipperTest.java index 9ae53be9d..35b8ffa69 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HbrowseRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HbrowseRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.HbrowseRipper; +import org.junit.jupiter.api.Test; public class HbrowseRipperTest extends RippersTest { + @Test public void testPahealRipper() throws IOException { HbrowseRipper ripper = new HbrowseRipper(new URL("https://www.hbrowse.com/21013/c00001")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/Hentai2readRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/Hentai2readRipperTest.java index f142635dd..f448f0def 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/Hentai2readRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/Hentai2readRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.Hentai2readRipper; +import org.junit.jupiter.api.Test; public class Hentai2readRipperTest extends RippersTest { + @Test public void testHentai2readAlbum() throws IOException { Hentai2readRipper ripper = new Hentai2readRipper(new URL("https://hentai2read.com/sm_school_memorial/1/")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaicafeRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaicafeRipperTest.java index 0be2dac8f..9c9222608 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaicafeRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaicafeRipperTest.java @@ -4,13 +4,16 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.HentaiCafeRipper; +import org.junit.jupiter.api.Test; public class HentaicafeRipperTest extends RippersTest { + @Test public void testHentaiCafeAlbum() throws IOException { HentaiCafeRipper ripper = new HentaiCafeRipper(new URL("https://hentai.cafe/kikuta-the-oni-in-the-room/")); testRipper(ripper); } // This album has a line break (
) in the url. Test it to make sure ripme can handle these invalid urls + @Test public void testAlbumWithInvalidChars() throws IOException { HentaiCafeRipper ripper = new HentaiCafeRipper(new URL("https://hentai.cafe/chobipero-club/")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaifoundryRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaifoundryRipperTest.java index 1ea63e014..d86e29044 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaifoundryRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaifoundryRipperTest.java @@ -4,19 +4,21 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.HentaifoundryRipper; +import org.junit.jupiter.api.Test; public class HentaifoundryRipperTest extends RippersTest { + @Test public void testHentaifoundryRip() throws IOException { HentaifoundryRipper ripper = new HentaifoundryRipper(new URL("https://www.hentai-foundry.com/pictures/user/personalami")); testRipper(ripper); } - + @Test public void testHentaifoundryGetGID() throws IOException { HentaifoundryRipper ripper = new HentaifoundryRipper(new URL("https://www.hentai-foundry.com/stories/user/Rakked")); testRipper(ripper); assertEquals("Rakked", ripper.getGID(new URL("https://www.hentai-foundry.com/stories/user/Rakked"))); } - + @Test public void testHentaifoundryPdfRip() throws IOException { HentaifoundryRipper ripper = new HentaifoundryRipper(new URL("https://www.hentai-foundry.com/stories/user/Rakked")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaiimageRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaiimageRipperTest.java index 9f78b0991..3fab101d6 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaiimageRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HentaiimageRipperTest.java @@ -5,9 +5,10 @@ import com.rarchives.ripme.ripper.rippers.HentaiimageRipper; import com.rarchives.ripme.utils.Utils; +import org.junit.jupiter.api.Test; public class HentaiimageRipperTest extends RippersTest { - + @Test public void testHentaifoundryRip() throws IOException { if (Utils.getConfigBoolean("test.run_flaky_tests", false)) { HentaiimageRipper ripper = new HentaiimageRipper(new URL("https://hentai-image.com/image/afrobull-gerudo-ongoing-12/")); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java index e1b730e1f..6ef21c8d5 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/HqpornerRipperTest.java @@ -2,6 +2,7 @@ import com.rarchives.ripme.ripper.rippers.HqpornerRipper; import com.rarchives.ripme.utils.Utils; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.URL; @@ -21,13 +22,13 @@ public void testGetGID() throws IOException { HqpornerRipper ripper = new HqpornerRipper(poolURL); assertEquals("84636-pool_lesson_with_a_cheating_husband", ripper.getGID(poolURL)); } - + @Test public void testGetURLsFromPage() throws IOException { URL actressUrl = new URL("https://hqporner.com/actress/kali-roses"); HqpornerRipper ripper = new HqpornerRipper(actressUrl); assert (ripper.getURLsFromPage(ripper.getFirstPage()).size() >= 2); } - + @Test public void testGetNextPage() throws IOException { URL multiPageUrl = new URL("https://hqporner.com/category/tattooed"); HqpornerRipper multiPageRipper = new HqpornerRipper(multiPageUrl); @@ -41,7 +42,7 @@ public void testGetNextPage() throws IOException { assertEquals(e.getMessage(), "No next page found."); } } - + @Test public void testMyDaddyVideoHost() throws IOException { if (Utils.getConfigBoolean("test.run_flaky_tests", false)) { URL myDaddyUrl = new URL("https://hqporner.com/hdporn/84636-pool_lesson_with_a_cheating_husband.html"); @@ -49,7 +50,7 @@ public void testMyDaddyVideoHost() throws IOException { testRipper(myDaddyRipper); } } - + @Test public void testFlyFlvVideoHost() throws IOException { if (Utils.getConfigBoolean("test.run_flaky_tests", false)) { URL flyFlvUrl = new URL( @@ -58,7 +59,7 @@ public void testFlyFlvVideoHost() throws IOException { testRipper(flyFlvRipper); } } - + @Test public void testUnknownVideoHost() throws IOException { if (Utils.getConfigBoolean("test.run_flaky_tests", false)) { URL unknownHostUrl = new URL("https://hqporner.com/hdporn/79528-Kayden_Kross_-_Serious_Masturbation.html"); // howq.cc diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagearnRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagearnRipperTest.java index b97106351..69b6d8996 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagearnRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagearnRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.ImagearnRipper; +import org.junit.jupiter.api.Test; public class ImagearnRipperTest extends RippersTest { + @Test public void testImagearnRip() throws IOException { ImagearnRipper ripper = new ImagearnRipper(new URL("http://imagearn.com//gallery.php?id=578682")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagebamRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagebamRipperTest.java index 0c3e07617..efe57b96d 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagebamRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagebamRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.ImagebamRipper; +import org.junit.jupiter.api.Test; public class ImagebamRipperTest extends RippersTest { + @Test public void testImagebamRip() throws IOException { ImagebamRipper ripper = new ImagebamRipper(new URL("http://www.imagebam.com/gallery/488cc796sllyf7o5srds8kpaz1t4m78i")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagefapRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagefapRipperTest.java index b64952cc9..533fff790 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagefapRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImagefapRipperTest.java @@ -6,8 +6,10 @@ import java.util.Map; import com.rarchives.ripme.ripper.rippers.ImagefapRipper; +import org.junit.jupiter.api.Test; public class ImagefapRipperTest extends RippersTest { + @Test public void testImagefapAlbums() throws IOException { Map testURLs = new HashMap<>(); @@ -24,6 +26,7 @@ public void testImagefapAlbums() throws IOException { testRipper(ripper); } } + @Test public void testImagefapGetAlbumTitle() throws IOException { URL url = new URL("https://www.imagefap.com/gallery.php?gid=7789753"); ImagefapRipper ripper = new ImagefapRipper(url); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImgboxRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImgboxRipperTest.java index 27ebdca2b..bb8774500 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImgboxRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ImgboxRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.ImgboxRipper; +import org.junit.jupiter.api.Test; public class ImgboxRipperTest extends RippersTest { + @Test public void testImgboxRip() throws IOException { ImgboxRipper ripper = new ImgboxRipper(new URL("https://imgbox.com/g/FJPF7t26FD")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/InstagramRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/InstagramRipperTest.java index fb8b89785..5cd0eeeb5 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/InstagramRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/InstagramRipperTest.java @@ -8,9 +8,11 @@ import java.util.Map; import com.rarchives.ripme.ripper.rippers.InstagramRipper; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class InstagramRipperTest extends RippersTest { - + @Test public void testInstagramGID() throws IOException { Map testURLs = new HashMap<>(); testURLs.put(new URL("http://instagram.com/Test_User"), "Test_User"); @@ -31,12 +33,12 @@ public void testInstagramGID() throws IOException { deleteDir(ripper.getWorkingDir()); } } - + @Test @Disabled("Fails to rip") public void testInstagramAlbums() throws IOException { List contentURLs = new ArrayList<>(); // This unit test is a bit flaky //contentURLs.add(new URL("https://www.instagram.com/Test_User/")); - contentURLs.add(new URL("https://www.instagram.com/p/BZ4egP7njW5/?hl=en")); + contentURLs.add(new URL("https://www.instagram.com/p/BaNPpaHn2zU/?hl=en")); contentURLs.add(new URL("https://www.instagram.com/p/BaNPpaHn2zU/")); for (URL url : contentURLs) { InstagramRipper ripper = new InstagramRipper(url); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/JagodibujaRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/JagodibujaRipperTest.java index a179aa90e..d41c03529 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/JagodibujaRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/JagodibujaRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.JagodibujaRipper; +import org.junit.jupiter.api.Test; public class JagodibujaRipperTest extends RippersTest { + @Test public void testJagodibujaRipper() throws IOException { // a photo set JagodibujaRipper ripper = new JagodibujaRipper(new URL("http://www.jagodibuja.com/comic-in-me/")); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/LusciousRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/LusciousRipperTest.java index f8da140c5..6536acebb 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/LusciousRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/LusciousRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.LusciousRipper; +import org.junit.jupiter.api.Test; public class LusciousRipperTest extends RippersTest { + @Test public void testPahealRipper() throws IOException { // a photo set LusciousRipper ripper = new LusciousRipper( @@ -18,7 +20,7 @@ public void testGetGID() throws IOException { LusciousRipper ripper = new LusciousRipper(url); assertEquals("h-na-alice-wa-suki-desu-ka-do-you-like-alice-when_321609", ripper.getGID(url)); } - + @Test public void testGetNextPage() throws IOException { URL multiPageAlbumUrl = new URL("https://luscious.net/albums/women-of-color_58/"); LusciousRipper multiPageRipper = new LusciousRipper(multiPageAlbumUrl); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MotherlessRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MotherlessRipperTest.java index 8a3809ea7..2739f9da1 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MotherlessRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MotherlessRipperTest.java @@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test; public class MotherlessRipperTest extends RippersTest { - // https://github.com/RipMeApp/ripme/issues/238 - MotherlessRipperTest is flaky on Travis CI @Test public void testMotherlessAlbumRip() throws IOException { MotherlessRipper ripper = new MotherlessRipper(new URL("https://motherless.com/G1168D90")); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MulemaxRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MulemaxRipperTest.java index 1e4dcdcd1..8c12a94db 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MulemaxRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MulemaxRipperTest.java @@ -4,9 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.MulemaxRipper; +import org.junit.jupiter.api.Test; public class MulemaxRipperTest extends RippersTest { - + @Test public void testMulemaxVideo() throws IOException { MulemaxRipper ripper = new MulemaxRipper(new URL("https://mulemax.com/video/1720/emma-and-her-older-sissy-are-home-for-a-holiday-break")); //pick any video from the front page testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MyhentaicomicsRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MyhentaicomicsRipperTest.java index 5e6cfc7eb..72524b067 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MyhentaicomicsRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MyhentaicomicsRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.MyhentaicomicsRipper; +import org.junit.jupiter.api.Test; public class MyhentaicomicsRipperTest extends RippersTest { + @Test public void testMyhentaicomicsAlbum() throws IOException { MyhentaicomicsRipper ripper = new MyhentaicomicsRipper(new URL("http://myhentaicomics.com/index.php/Nienna-Lost-Tales")); testRipper(ripper); @@ -21,13 +23,13 @@ public void testGetGID() throws IOException { // Test a tag assertEquals("2409", ripper.getGID(new URL("http://myhentaicomics.com/index.php/tag/2409/"))); } - + @Test public void testGetAlbumsToQueue() throws IOException { URL url = new URL("https://myhentaicomics.com/index.php/tag/3167/"); MyhentaicomicsRipper ripper = new MyhentaicomicsRipper(url); assertEquals(15, ripper.getAlbumsToQueue(ripper.getFirstPage()).size()); } - + @Test public void testPageContainsAlbums() throws IOException { URL url = new URL("https://myhentaicomics.com/index.php/tag/3167/"); URL url2 = new URL("https://myhentaicomics.com/index.php/search?q=test"); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MyhentaigalleryRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MyhentaigalleryRipperTest.java index fc150c7ec..3d126b82c 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MyhentaigalleryRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MyhentaigalleryRipperTest.java @@ -4,9 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.MyhentaigalleryRipper; +import org.junit.jupiter.api.Test; public class MyhentaigalleryRipperTest extends RippersTest { - + @Test public void testMyhentaigalleryAlbum() throws IOException { MyhentaigalleryRipper ripper = new MyhentaigalleryRipper( new URL("https://myhentaigallery.com/gallery/thumbnails/9201")); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NewgroundsRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NewgroundsRipperTest.java index 5486df15c..5815aa8f7 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NewgroundsRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NewgroundsRipperTest.java @@ -1,12 +1,13 @@ package com.rarchives.ripme.tst.ripper.rippers; import com.rarchives.ripme.ripper.rippers.NewgroundsRipper; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.URL; public class NewgroundsRipperTest extends RippersTest { - + @Test public void testNewgroundsRip() throws IOException { NewgroundsRipper ripper = new NewgroundsRipper(new URL("https://zone-sama.newgrounds.com/art")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NewsfilterRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NewsfilterRipperTest.java index c22ba9c52..8567b0ff6 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NewsfilterRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NewsfilterRipperTest.java @@ -4,9 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.NewsfilterRipper; +import org.junit.jupiter.api.Test; public class NewsfilterRipperTest extends RippersTest { - + @Test public void testNewsfilterRip() throws IOException { NewsfilterRipper ripper = new NewsfilterRipper(new URL("http://newsfilter.org/gallery/he-doubted-she-would-fuck-on-cam-happy-to-be-proven-wrong-216799")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NhentaiRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NhentaiRipperTest.java index f6418ef78..7e82adafb 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NhentaiRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/NhentaiRipperTest.java @@ -6,6 +6,7 @@ import com.rarchives.ripme.ripper.rippers.NhentaiRipper; import com.rarchives.ripme.utils.RipUtils; +import org.junit.jupiter.api.Test; public class NhentaiRipperTest extends RippersTest { public void testRip() throws IOException { @@ -19,6 +20,7 @@ public void testGetGID() throws IOException { } // Test the tag black listing + @Test public void testTagBlackList() throws IOException { URL url = new URL("https://nhentai.net/g/233295/"); NhentaiRipper ripper = new NhentaiRipper(url); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PahealRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PahealRipperTest.java index cb2b5c3bb..844030055 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PahealRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PahealRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.PahealRipper; +import org.junit.jupiter.api.Test; public class PahealRipperTest extends RippersTest { + @Test public void testPahealRipper() throws IOException { // a photo set PahealRipper ripper = new PahealRipper(new URL("http://rule34.paheal.net/post/list/bimbo/1")); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PicstatioRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PicstatioRipperTest.java index 606cd5692..1c5cf2730 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PicstatioRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PicstatioRipperTest.java @@ -4,6 +4,7 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.PicstatioRipper; +import org.junit.jupiter.api.Test; public class PicstatioRipperTest extends RippersTest { @@ -11,7 +12,7 @@ public void testRip() throws IOException { PicstatioRipper ripper = new PicstatioRipper(new URL("https://www.picstatio.com/aerial-view-wallpapers")); testRipper(ripper); } - + @Test public void testGID() throws IOException { PicstatioRipper ripper = new PicstatioRipper(new URL("https://www.picstatio.com/aerial-view-wallpapers")); assertEquals("aerial-view-wallpapers", ripper.getGID(new URL("https://www.picstatio.com/aerial-view-wallpapers"))); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PorncomixDotOneRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PorncomixDotOneRipperTest.java index 2dc92e20f..9d4df122e 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PorncomixDotOneRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PorncomixDotOneRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.PorncomixDotOneRipper; +import org.junit.jupiter.api.Test; public class PorncomixDotOneRipperTest extends RippersTest { + @Test public void testPorncomixAlbum() throws IOException { PorncomixDotOneRipper ripper = new PorncomixDotOneRipper(new URL("https://www.porncomix.one/gallery/blacknwhite-make-america-great-again")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PornhubRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PornhubRipperTest.java index 1f5219b19..84094515d 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PornhubRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/PornhubRipperTest.java @@ -7,8 +7,10 @@ import com.rarchives.ripme.utils.Http; import com.rarchives.ripme.utils.Utils; import org.jsoup.nodes.Document; +import org.junit.jupiter.api.Test; public class PornhubRipperTest extends RippersTest { + @Test public void testPornhubRip() throws IOException { if (Utils.getConfigBoolean("test.run_flaky_tests", false)) { PornhubRipper ripper = new PornhubRipper(new URL("https://www.pornhub.com/album/15680522")); @@ -25,6 +27,7 @@ public void testGetGID() throws IOException { } // alternate album, with only 2 pages: https://www.pornhub.com/album/4771891 + @Test public void testGetNextPage() throws IOException { String baseURL = "https://www.pornhub.com/album/15680522"; PornhubRipper ripper = new PornhubRipper(new URL(baseURL)); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/Rule34RipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/Rule34RipperTest.java index 4c63d66ed..129fedd57 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/Rule34RipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/Rule34RipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.Rule34Ripper; +import org.junit.jupiter.api.Test; public class Rule34RipperTest extends RippersTest { + @Test public void testShesFreakyRip() throws IOException { Rule34Ripper ripper = new Rule34Ripper(new URL("https://rule34.xxx/index.php?page=post&s=list&tags=bimbo")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/SinnercomicsRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/SinnercomicsRipperTest.java index 4d5d0b2fd..29ad8cf3b 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/SinnercomicsRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/SinnercomicsRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.SinnercomicsRipper; +import org.junit.jupiter.api.Test; public class SinnercomicsRipperTest extends RippersTest { + @Test public void testSinnercomicsAlbum() throws IOException { SinnercomicsRipper ripper; diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/SpankBangRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/SpankBangRipperTest.java index 19727e656..c73a244e4 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/SpankBangRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/SpankBangRipperTest.java @@ -4,9 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.SpankbangRipper; +import org.junit.jupiter.api.Test; public class SpankBangRipperTest extends RippersTest { - + @Test public void testSpankBangVideo() throws IOException { SpankbangRipper ripper = new SpankbangRipper(new URL("https://spankbang.com/2a7fh/video/mdb901")); //most popular video of all time on site; should stay up testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TapasticRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TapasticRipperTest.java index f9e448e63..bd4248600 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TapasticRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TapasticRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.TapasticRipper; +import org.junit.jupiter.api.Test; public class TapasticRipperTest extends RippersTest { + @Test public void testTapasticRip() throws IOException { TapasticRipper ripper = new TapasticRipper(new URL("https://tapas.io/series/tsiwbakd-comic")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TeenplanetRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TeenplanetRipperTest.java index a402ebc37..4d0887420 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TeenplanetRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TeenplanetRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.TeenplanetRipper; +import org.junit.jupiter.api.Test; public class TeenplanetRipperTest extends RippersTest { + @Test public void testTeenplanetRip() throws IOException { TeenplanetRipper ripper = new TeenplanetRipper(new URL("http://teenplanet.org/galleries/the-perfect-side-of-me-6588.html")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TheyiffgalleryRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TheyiffgalleryRipperTest.java index 91fc06172..65ebbb149 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TheyiffgalleryRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TheyiffgalleryRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.TheyiffgalleryRipper; +import org.junit.jupiter.api.Test; public class TheyiffgalleryRipperTest extends RippersTest { + @Test public void testTheyiffgallery() throws IOException { TheyiffgalleryRipper ripper = new TheyiffgalleryRipper(new URL("https://theyiffgallery.com/index?/category/4303")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TsuminoRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TsuminoRipperTest.java index 52c5900a0..b1e58adc9 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TsuminoRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/TsuminoRipperTest.java @@ -7,14 +7,16 @@ import com.rarchives.ripme.ripper.rippers.TsuminoRipper; import com.rarchives.ripme.utils.RipUtils; import org.jsoup.nodes.Document; +import org.junit.jupiter.api.Test; public class TsuminoRipperTest extends RippersTest { + @Test public void testTsuminoRipper() throws IOException { TsuminoRipper ripper = new TsuminoRipper(new URL("http://www.tsumino.com/Book/Info/43528/sore-wa-kurokute-suketeita-what-s-tight-and-black-and-sheer-all-over-")); testRipper(ripper); } - + @Test public void testTagBlackList() throws IOException { TsuminoRipper ripper = new TsuminoRipper(new URL("http://www.tsumino.com/Book/Info/43528/sore-wa-kurokute-suketeita-what-s-tight-and-black-and-sheer-all-over-")); Document doc = ripper.getFirstPage(); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/VidbleRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/VidbleRipperTest.java index 9659d6300..f76e2b258 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/VidbleRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/VidbleRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.VidbleRipper; +import org.junit.jupiter.api.Test; public class VidbleRipperTest extends RippersTest { + @Test public void testVidbleRip() throws IOException { VidbleRipper ripper = new VidbleRipper(new URL("http://www.vidble.com/album/y1oyh3zd")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ViewcomicRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ViewcomicRipperTest.java index 3d9ed3095..cc9d2409e 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ViewcomicRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ViewcomicRipperTest.java @@ -4,8 +4,10 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.ViewcomicRipper; +import org.junit.jupiter.api.Test; public class ViewcomicRipperTest extends RippersTest { + @Test public void testViewcomicRipper() throws IOException { ViewcomicRipper ripper = new ViewcomicRipper(new URL("https://view-comic.com/batman-no-mans-land-vol-1/")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/VkRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/VkRipperTest.java index cc15ff995..22ccb6411 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/VkRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/VkRipperTest.java @@ -4,6 +4,7 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.VkRipper; +import org.junit.jupiter.api.Test; public class VkRipperTest extends RippersTest { // https://github.com/RipMeApp/ripme/issues/252 @@ -14,14 +15,17 @@ public class VkRipperTest extends RippersTest { // EXAMPLE: https://vk.com/album45506334_0 (a single album - profile pictures) // EXAMPLE: https://vk.com/album45506334_00?rev=1 (a single album - wall pictures) // EXAMPLE: https://vk.com/album45506334_101886701 (a single album - custom) + @Test public void testVkAlbumHttpRip() throws IOException { VkRipper ripper = new VkRipper(new URL("http://vk.com/album45506334_0")); testRipper(ripper); } + @Test public void testVkAlbumHttpsRip() throws IOException { VkRipper ripper = new VkRipper(new URL("https://vk.com/album45506334_0")); testRipper(ripper); } + @Test public void testVkPhotosRip() throws IOException { VkRipper ripper = new VkRipper(new URL("https://vk.com/photos45506334")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/WebtoonsRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/WebtoonsRipperTest.java index 16407ad75..ad634d5f9 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/WebtoonsRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/WebtoonsRipperTest.java @@ -4,18 +4,20 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.WebtoonsRipper; +import org.junit.jupiter.api.Test; public class WebtoonsRipperTest extends RippersTest { + @Test public void testWebtoonsAlbum() throws IOException { WebtoonsRipper ripper = new WebtoonsRipper(new URL("http://www.webtoons.com/en/drama/my-boo/ep-33/viewer?title_no=1185&episode_no=33")); testRipper(ripper); } - + @Test public void testWebtoonsType() throws IOException { WebtoonsRipper ripper = new WebtoonsRipper(new URL("http://www.webtoons.com/en/drama/lookism/ep-145/viewer?title_no=1049&episode_no=145")); testRipper(ripper); } - + @Test public void testGetGID() throws IOException { URL url = new URL("http://www.webtoons.com/en/drama/my-boo/ep-33/viewer?title_no=1185&episode_no=33"); WebtoonsRipper ripper = new WebtoonsRipper(url); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/WordpressComicRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/WordpressComicRipperTest.java index d646040ba..f55e5fdc9 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/WordpressComicRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/WordpressComicRipperTest.java @@ -43,26 +43,26 @@ public void test_themonsterunderthebed() throws IOException { new URL("http://themonsterunderthebed.net/?comic=test-post")); testRipper(ripper); } - + @Test public void test_prismblush() throws IOException { WordpressComicRipper ripper = new WordpressComicRipper( new URL("http://prismblush.com/comic/hella-trap-pg-01/")); testRipper(ripper); } - + @Test public void test_konradokonski_1() throws IOException { WordpressComicRipper ripper = new WordpressComicRipper( new URL("http://www.konradokonski.com/sawdust/comic/get-up/")); testRipper(ripper); } - + @Test public void test_konradokonski_2() throws IOException { WordpressComicRipper ripper = new WordpressComicRipper( new URL("http://www.konradokonski.com/wiory/comic/08182008/")); testRipper(ripper); } - + @Test public void test_konradokonski_getAlbumTitle() throws IOException { URL url = new URL("http://www.konradokonski.com/sawdust/comic/get-up/"); WordpressComicRipper ripper = new WordpressComicRipper(url); @@ -77,31 +77,31 @@ public void test_freeadultcomix() throws IOException { new URL("http://freeadultcomix.com/finders-feepaid-in-full-sparrow/")); testRipper(ripper); } - + @Test public void test_delvecomic() throws IOException { WordpressComicRipper ripper = new WordpressComicRipper( new URL("http://thisis.delvecomic.com/NewWP/comic/in-too-deep/")); testRipper(ripper); } - + @Test public void test_Eightmuses_download() throws IOException { WordpressComicRipper ripper = new WordpressComicRipper( new URL("https://8muses.download/lustomic-playkittens-josh-samuel-porn-comics-8-muses/")); testRipper(ripper); } - + @Test public void test_Eightmuses_getAlbumTitle() throws IOException { URL url = new URL("https://8muses.download/lustomic-playkittens-josh-samuel-porn-comics-8-muses/"); WordpressComicRipper ripper = new WordpressComicRipper(url); assertEquals("8muses.download_lustomic-playkittens-josh-samuel-porn-comics-8-muses", ripper.getAlbumTitle(url)); } - + @Test public void test_spyingwithlana_download() throws IOException { WordpressComicRipper ripper = new WordpressComicRipper( new URL("http://spyingwithlana.com/comic/the-big-hookup/")); testRipper(ripper); } - + @Test public void test_spyingwithlana_getAlbumTitle() throws IOException { URL url = new URL("http://spyingwithlana.com/comic/the-big-hookup/"); WordpressComicRipper ripper = new WordpressComicRipper(url); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XvideosRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XvideosRipperTest.java index 543ad8caa..9446b6408 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XvideosRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XvideosRipperTest.java @@ -5,9 +5,10 @@ import com.rarchives.ripme.ripper.rippers.XvideosRipper; import com.rarchives.ripme.tst.ripper.rippers.RippersTest; +import org.junit.jupiter.api.Test; public class XvideosRipperTest extends RippersTest { - + @Test public void testXhamsterAlbum1() throws IOException { XvideosRipper ripper = new XvideosRipper(new URL("https://www.xvideos.com/video23515878/dee_s_pool_toys")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/YoupornRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/YoupornRipperTest.java index a3da81fc8..c8640cad0 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/YoupornRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/YoupornRipperTest.java @@ -1,6 +1,7 @@ package com.rarchives.ripme.tst.ripper.rippers; import com.rarchives.ripme.ripper.rippers.YoupornRipper; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.URL; @@ -8,6 +9,7 @@ import java.util.List; public class YoupornRipperTest extends RippersTest { + @Test public void testYoupornRipper() throws IOException { List contentURLs = new ArrayList<>(); contentURLs.add(new URL("http://www.youporn.com/watch/7669155/mrs-li-amateur-69-orgasm/?from=categ")); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/YuvutuRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/YuvutuRipperTest.java index 1a304468b..7cc3def91 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/YuvutuRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/YuvutuRipperTest.java @@ -4,14 +4,15 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.YuvutuRipper; +import org.junit.jupiter.api.Test; public class YuvutuRipperTest extends RippersTest { - + @Test public void testYuvutuAlbum1() throws IOException { YuvutuRipper ripper = new YuvutuRipper(new URL("http://www.yuvutu.com/modules.php?name=YuGallery&action=view&set_id=127013")); testRipper(ripper); } - + @Test public void testYuvutuAlbum2() throws IOException { YuvutuRipper ripper = new YuvutuRipper(new URL("http://www.yuvutu.com/modules.php?name=YuGallery&action=view&set_id=420333")); testRipper(ripper); diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ZizkiRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ZizkiRipperTest.java index 9facf4815..e12ccb5cc 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ZizkiRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ZizkiRipperTest.java @@ -4,6 +4,7 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.ZizkiRipper; +import org.junit.jupiter.api.Test; public class ZizkiRipperTest extends RippersTest { public void testRip() throws IOException { @@ -16,7 +17,7 @@ public void testGetGID() throws IOException { ZizkiRipper ripper = new ZizkiRipper(url); assertEquals("dee-chorde", ripper.getGID(url)); } - + @Test public void testAlbumTitle() throws IOException { URL url = new URL("http://zizki.com/dee-chorde/we-got-spirit"); ZizkiRipper ripper = new ZizkiRipper(url); From c11d34e397c0524cf0ac221a49fb23514b40450f Mon Sep 17 00:00:00 2001 From: Isaaku Date: Wed, 14 Aug 2019 13:00:29 -0500 Subject: [PATCH 05/21] Change the logic of locate to Utils Update use of ResourceBundle Added queue properties missing in LabelBundle Delete content of LabelsBundle_en_US.properties since the default language is English --- .../ripme/ripper/DownloadFileThread.java | 118 ++-- .../com/rarchives/ripme/ui/MainWindow.java | 552 ++++++++++-------- .../java/com/rarchives/ripme/utils/Utils.java | 17 + src/main/resources/LabelsBundle.properties | 7 +- .../resources/LabelsBundle_ar_AR.properties | 2 +- .../resources/LabelsBundle_de_DE.properties | 2 +- .../resources/LabelsBundle_en_US.properties | 58 +- .../resources/LabelsBundle_es_ES.properties | 7 +- .../resources/LabelsBundle_fi_FI.properties | 2 +- .../resources/LabelsBundle_fr_CH.properties | 2 +- .../resources/LabelsBundle_in_ID.properties | 2 +- .../resources/LabelsBundle_it_IT.properties | 8 +- .../resources/LabelsBundle_kr_KR.properties | 2 +- .../resources/LabelsBundle_nl_NL.properties | 2 +- .../resources/LabelsBundle_pl_PL.properties | 2 +- .../LabelsBundle_porrisavvo_FI.properties | 2 +- .../resources/LabelsBundle_pt_BR.properties | 2 +- .../resources/LabelsBundle_pt_PT.properties | 2 +- .../resources/LabelsBundle_ru_RU.properties | 2 +- 19 files changed, 426 insertions(+), 365 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java index 3b1e7c164..3613273e5 100644 --- a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java +++ b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java @@ -20,17 +20,14 @@ import com.rarchives.ripme.utils.Utils; /** - * Thread for downloading files. - * Includes retry logic, observer notifications, and other goodies. + * Thread for downloading files. Includes retry logic, observer notifications, + * and other goodies. */ class DownloadFileThread extends Thread { - - private ResourceBundle rb = MainWindow.rb; - private static final Logger logger = Logger.getLogger(DownloadFileThread.class); private String referrer = ""; - private Map cookies = new HashMap<>(); + private Map cookies = new HashMap<>(); private URL url; private File saveAs; @@ -55,18 +52,19 @@ public DownloadFileThread(URL url, File saveAs, AbstractRipper observer, Boolean public void setReferrer(String referrer) { this.referrer = referrer; } - public void setCookies(Map cookies) { + + public void setCookies(Map cookies) { this.cookies = cookies; } - /** - * Attempts to download the file. Retries as needed. - * Notifies observers upon completion/error/warn. + * Attempts to download the file. Retries as needed. Notifies observers upon + * completion/error/warn. */ public void run() { // First thing we make sure the file name doesn't have any illegal chars in it - saveAs = new File(saveAs.getParentFile().getAbsolutePath() + File.separator + Utils.sanitizeSaveAs(saveAs.getName())); + saveAs = new File( + saveAs.getParentFile().getAbsolutePath() + File.separator + Utils.sanitizeSaveAs(saveAs.getName())); long fileSize = 0; int bytesTotal = 0; int bytesDownloaded = 0; @@ -76,16 +74,18 @@ public void run() { try { observer.stopCheck(); } catch (IOException e) { - observer.downloadErrored(url, rb.getString("download.interrupted")); + observer.downloadErrored(url, Utils.getLocalizedString("download.interrupted")); return; } - if (saveAs.exists() && !observer.tryResumeDownload() && !getFileExtFromMIME || - Utils.fuzzyExists(new File(saveAs.getParent()), saveAs.getName()) && getFileExtFromMIME && !observer.tryResumeDownload()) { + if (saveAs.exists() && !observer.tryResumeDownload() && !getFileExtFromMIME + || Utils.fuzzyExists(new File(saveAs.getParent()), saveAs.getName()) && getFileExtFromMIME + && !observer.tryResumeDownload()) { if (Utils.getConfigBoolean("file.overwrite", false)) { - logger.info("[!] " + rb.getString("deleting.existing.file") + prettySaveAs); + logger.info("[!] " + Utils.getLocalizedString("deleting.existing.file") + prettySaveAs); saveAs.delete(); } else { - logger.info("[!] " + rb.getString("skipping") + url + " -- " + rb.getString("file.already.exists") + ": " + prettySaveAs); + logger.info("[!] " + Utils.getLocalizedString("skipping") + url + " -- " + + Utils.getLocalizedString("file.already.exists") + ": " + prettySaveAs); observer.downloadExists(url, saveAs); return; } @@ -95,7 +95,8 @@ public void run() { int tries = 0; // Number of attempts to download do { tries += 1; - InputStream bis = null; OutputStream fos = null; + InputStream bis = null; + OutputStream fos = null; try { logger.info(" Downloading file: " + urlToDownload + (tries > 0 ? " Retry #" + tries : "")); observer.sendUpdate(STATUS.DOWNLOAD_STARTED, url.toExternalForm()); @@ -104,16 +105,16 @@ public void run() { HttpURLConnection huc; if (this.url.toString().startsWith("https")) { huc = (HttpsURLConnection) urlToDownload.openConnection(); - } - else { + } else { huc = (HttpURLConnection) urlToDownload.openConnection(); } huc.setInstanceFollowRedirects(true); - // It is important to set both ConnectTimeout and ReadTimeout. If you don't then ripme will wait forever + // It is important to set both ConnectTimeout and ReadTimeout. If you don't then + // ripme will wait forever // for the server to send data after connecting. huc.setConnectTimeout(TIMEOUT); huc.setReadTimeout(TIMEOUT); - huc.setRequestProperty("accept", "*/*"); + huc.setRequestProperty("accept", "*/*"); if (!referrer.equals("")) { huc.setRequestProperty("Referer", referrer); // Sic } @@ -131,17 +132,18 @@ public void run() { huc.setRequestProperty("Range", "bytes=" + fileSize + "-"); } } - logger.debug(rb.getString("request.properties") + ": " + huc.getRequestProperties()); + logger.debug(Utils.getLocalizedString("request.properties") + ": " + huc.getRequestProperties()); huc.connect(); int statusCode = huc.getResponseCode(); logger.debug("Status code: " + statusCode); // If the server doesn't allow resuming downloads error out if (statusCode != 206 && observer.tryResumeDownload() && saveAs.exists()) { - // TODO find a better way to handle servers that don't support resuming downloads then just erroring out - throw new IOException(rb.getString("server.doesnt.support.resuming.downloads")); + // TODO find a better way to handle servers that don't support resuming + // downloads then just erroring out + throw new IOException(Utils.getLocalizedString("server.doesnt.support.resuming.downloads")); } - if (statusCode / 100 == 3) { // 3xx Redirect + if (statusCode / 100 == 3) { // 3xx Redirect if (!redirected) { // Don't increment retries on the first redirect tries--; @@ -153,14 +155,17 @@ public void run() { throw new IOException("Redirect status code " + statusCode + " - redirect to " + location); } if (statusCode / 100 == 4) { // 4xx errors - logger.error("[!] " + rb.getString("nonretriable.status.code") + " " + statusCode + " while downloading from " + url); - observer.downloadErrored(url, rb.getString("nonretriable.status.code") + " " + statusCode + " while downloading " + url.toExternalForm()); + logger.error("[!] " + Utils.getLocalizedString("nonretriable.status.code") + " " + statusCode + + " while downloading from " + url); + observer.downloadErrored(url, Utils.getLocalizedString("nonretriable.status.code") + " " + + statusCode + " while downloading " + url.toExternalForm()); return; // Not retriable, drop out. } if (statusCode / 100 == 5) { // 5xx errors - observer.downloadErrored(url, rb.getString("retriable.status.code") + " " + statusCode + " while downloading " + url.toExternalForm()); + observer.downloadErrored(url, Utils.getLocalizedString("retriable.status.code") + " " + statusCode + + " while downloading " + url.toExternalForm()); // Throw exception so download can be retried - throw new IOException(rb.getString("retriable.status.code") + " " + statusCode); + throw new IOException(Utils.getLocalizedString("retriable.status.code") + " " + statusCode); } if (huc.getContentLength() == 503 && urlToDownload.getHost().endsWith("imgur.com")) { // Imgur image with 503 bytes is "404" @@ -169,7 +174,8 @@ public void run() { return; } - // If the ripper is using the bytes progress bar set bytesTotal to huc.getContentLength() + // If the ripper is using the bytes progress bar set bytesTotal to + // huc.getContentLength() if (observer.useByteProgessBar()) { bytesTotal = huc.getContentLength(); observer.setBytesTotal(bytesTotal); @@ -190,14 +196,15 @@ public void run() { logger.error("Was unable to get content type from stream"); // Try to get the file type from the magic number byte[] magicBytes = new byte[8]; - bis.read(magicBytes,0, 5); + bis.read(magicBytes, 0, 5); bis.reset(); fileExt = Utils.getEXTFromMagic(magicBytes); if (fileExt != null) { saveAs = new File(saveAs.toString() + "." + fileExt); } else { - logger.error(rb.getString("was.unable.to.get.content.type.using.magic.number")); - logger.error(rb.getString("magic.number.was") + ": " + Arrays.toString(magicBytes)); + logger.error(Utils.getLocalizedString("was.unable.to.get.content.type.using.magic.number")); + logger.error( + Utils.getLocalizedString("magic.number.was") + ": " + Arrays.toString(magicBytes)); } } } @@ -210,21 +217,26 @@ public void run() { } catch (FileNotFoundException e) { // We do this because some filesystems have a max name length if (e.getMessage().contains("File name too long")) { - logger.error("The filename " + saveAs.getName() + " is to long to be saved on this file system."); + logger.error("The filename " + saveAs.getName() + + " is to long to be saved on this file system."); logger.info("Shortening filename"); String[] saveAsSplit = saveAs.getName().split("\\."); - // Get the file extension so when we shorten the file name we don't cut off the file extension + // Get the file extension so when we shorten the file name we don't cut off the + // file extension String fileExt = saveAsSplit[saveAsSplit.length - 1]; // The max limit for filenames on Linux with Ext3/4 is 255 bytes logger.info(saveAs.getName().substring(0, 254 - fileExt.length()) + fileExt); String filename = saveAs.getName().substring(0, 254 - fileExt.length()) + "." + fileExt; - // We can't just use the new file name as the saveAs because the file name doesn't include the + // We can't just use the new file name as the saveAs because the file name + // doesn't include the // users save path, so we get the user save path from the old saveAs saveAs = new File(saveAs.getParentFile().getAbsolutePath() + File.separator + filename); fos = new FileOutputStream(saveAs); } else if (saveAs.getAbsolutePath().length() > 259 && Utils.isWindows()) { - // This if is for when the file path has gone above 260 chars which windows does not allow - fos = new FileOutputStream(Utils.shortenSaveAsWindows(saveAs.getParentFile().getPath(), saveAs.getName())); + // This if is for when the file path has gone above 260 chars which windows does + // not allow + fos = new FileOutputStream( + Utils.shortenSaveAsWindows(saveAs.getParentFile().getPath(), saveAs.getName())); } } } @@ -239,7 +251,7 @@ public void run() { try { observer.stopCheck(); } catch (IOException e) { - observer.downloadErrored(url, rb.getString("download.interrupted")); + observer.downloadErrored(url, Utils.getLocalizedString("download.interrupted")); return; } fos.write(data, 0, bytesRead); @@ -259,27 +271,37 @@ public void run() { // Download failed, break out of loop break; } catch (HttpStatusException hse) { - logger.debug(rb.getString("http.status.exception"), hse); + logger.debug(Utils.getLocalizedString("http.status.exception"), hse); logger.error("[!] HTTP status " + hse.getStatusCode() + " while downloading from " + urlToDownload); if (hse.getStatusCode() == 404 && Utils.getConfigBoolean("errors.skip404", false)) { - observer.downloadErrored(url, "HTTP status code " + hse.getStatusCode() + " while downloading " + url.toExternalForm()); + observer.downloadErrored(url, + "HTTP status code " + hse.getStatusCode() + " while downloading " + url.toExternalForm()); return; } } catch (IOException e) { logger.debug("IOException", e); - logger.error("[!] " + rb.getString("exception.while.downloading.file") + ": " + url + " - " + e.getMessage()); + logger.error("[!] " + Utils.getLocalizedString("exception.while.downloading.file") + ": " + url + " - " + + e.getMessage()); } finally { // Close any open streams try { - if (bis != null) { bis.close(); } - } catch (IOException e) { } + if (bis != null) { + bis.close(); + } + } catch (IOException e) { + } try { - if (fos != null) { fos.close(); } - } catch (IOException e) { } + if (fos != null) { + fos.close(); + } + } catch (IOException e) { + } } if (tries > this.retries) { - logger.error("[!] " + rb.getString ("exceeded.maximum.retries") + " (" + this.retries + ") for URL " + url); - observer.downloadErrored(url, rb.getString("failed.to.download") + " " + url.toExternalForm()); + logger.error("[!] " + Utils.getLocalizedString("exceeded.maximum.retries") + " (" + this.retries + + ") for URL " + url); + observer.downloadErrored(url, + Utils.getLocalizedString("failed.to.download") + " " + url.toExternalForm()); return; } } while (true); diff --git a/src/main/java/com/rarchives/ripme/ui/MainWindow.java b/src/main/java/com/rarchives/ripme/ui/MainWindow.java index e97e915ad..2d69542c1 100644 --- a/src/main/java/com/rarchives/ripme/ui/MainWindow.java +++ b/src/main/java/com/rarchives/ripme/ui/MainWindow.java @@ -71,8 +71,7 @@ public final class MainWindow implements Runnable, RipStatusHandler { private static JFrame mainFrame; private static JTextField ripTextfield; - private static JButton ripButton, - stopButton; + private static JButton ripButton, stopButton; private static JLabel statusLabel; private static JButton openButton; @@ -93,14 +92,13 @@ public final class MainWindow implements Runnable, RipStatusHandler { private static JPanel historyPanel; private static JTable historyTable; private static AbstractTableModel historyTableModel; - private static JButton historyButtonRemove, - historyButtonClear, - historyButtonRerip; + private static JButton historyButtonRemove, historyButtonClear, historyButtonRerip; // Queue public static JButton optionQueue; private static JPanel queuePanel; - private static DefaultListModel queueListModel; + private static DefaultListModel queueListModel; + private static QueueMenuMouseListener queueMenuMouseListener; // Configuration private static JButton optionConfiguration; @@ -141,34 +139,23 @@ public final class MainWindow implements Runnable, RipStatusHandler { private static AbstractRipper ripper; - public static ResourceBundle rb = Utils.getResourceBundle(null); - // All the langs ripme has been translated into - private static String[] supportedLanges = new String[] { - "de_DE", - "ar_AR", - "en_US", - "es_ES", - "fi_FI", - "fr_CH", - "in_ID", - "it_IT", - "kr_KR", - "nl_NL", - "pl_PL", - "porrisavvo_FI", - "pt_BR", - "pt_PT", - "ru_RU"}; - - private void updateQueueLabel() { - if (queueListModel.size() > 0) { - optionQueue.setText(rb.getString("Queue") + " (" + queueListModel.size() + ")"); - } else { - optionQueue.setText(rb.getString("Queue")); - } + private static String[] supportedLanges = new String[] { "de_DE", "ar_AR", "en_US", "es_ES", "fi_FI", "fr_CH", + "in_ID", "it_IT", "kr_KR", "nl_NL", "pl_PL", "porrisavvo_FI", "pt_BR", "pt_PT", "ru_RU" }; + + private void updateQueue(DefaultListModel model) { + if (model == null) + model = queueListModel; + + Utils.setConfigList("Queue", (Enumeration) model.elements()); + + MainWindow.optionQueue.setText(String.format("%s%s", Utils.getLocalizedString("queue"), + model.size() == 0 ? "" : "(" + model.size() + ")")); } + private void updateQueue() { + updateQueue(null); + } private static void addCheckboxListener(JCheckBox checkBox, String configString) { checkBox.addActionListener(arg0 -> { @@ -185,7 +172,6 @@ private static JCheckBox addNewCheckbox(String text, String configString, Boolea return checkbox; } - public static void addUrlToQueue(String url) { queueListModel.addElement(url); } @@ -276,29 +262,32 @@ private void pack() { } private boolean isCollapsed() { - return (!logPanel.isVisible() && - !historyPanel.isVisible() && - !queuePanel.isVisible() && - !configurationPanel.isVisible() - ); + return (!logPanel.isVisible() && !historyPanel.isVisible() && !queuePanel.isVisible() + && !configurationPanel.isVisible()); } private void createUI(Container pane) { - //If creating the tray icon fails, ignore it. + // If creating the tray icon fails, ignore it. try { setupTrayIcon(); - } catch (Exception e) { } + } catch (Exception e) { + } EmptyBorder emptyBorder = new EmptyBorder(5, 5, 5, 5); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.weightx = 1; gbc.ipadx = 2; gbc.gridx = 0; - gbc.weighty = 0; gbc.ipady = 2; gbc.gridy = 0; + gbc.weightx = 1; + gbc.ipadx = 2; + gbc.gridx = 0; + gbc.weighty = 0; + gbc.ipady = 2; + gbc.gridy = 0; gbc.anchor = GridBagConstraints.PAGE_START; try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (ClassNotFoundException | InstantiationException | UnsupportedLookAndFeelException | IllegalAccessException e) { + } catch (ClassNotFoundException | InstantiationException | UnsupportedLookAndFeelException + | IllegalAccessException e) { LOGGER.error("[!] Exception setting system theme:", e); } @@ -311,31 +300,38 @@ private void createUI(Container pane) { try { Image stopIcon = ImageIO.read(getClass().getClassLoader().getResource("stop.png")); stopButton.setIcon(new ImageIcon(stopIcon)); - } catch (Exception ignored) { } + } catch (Exception ignored) { + } JPanel ripPanel = new JPanel(new GridBagLayout()); ripPanel.setBorder(emptyBorder); gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 0; - gbc.gridx = 0; ripPanel.add(new JLabel("URL:", JLabel.RIGHT), gbc); + gbc.gridx = 0; + ripPanel.add(new JLabel("URL:", JLabel.RIGHT), gbc); gbc.weightx = 1; gbc.weighty = 1; - gbc.gridx = 1; ripPanel.add(ripTextfield, gbc); + gbc.gridx = 1; + ripPanel.add(ripTextfield, gbc); gbc.weighty = 0; gbc.weightx = 0; - gbc.gridx = 2; ripPanel.add(ripButton, gbc); - gbc.gridx = 3; ripPanel.add(stopButton, gbc); + gbc.gridx = 2; + ripPanel.add(ripButton, gbc); + gbc.gridx = 3; + ripPanel.add(stopButton, gbc); gbc.weightx = 1; - statusLabel = new JLabel(rb.getString("inactive")); + statusLabel = new JLabel(Utils.getLocalizedString("inactive")); statusLabel.setHorizontalAlignment(JLabel.CENTER); openButton = new JButton(); openButton.setVisible(false); JPanel statusPanel = new JPanel(new GridBagLayout()); statusPanel.setBorder(emptyBorder); - gbc.gridx = 0; statusPanel.add(statusLabel, gbc); - gbc.gridy = 1; statusPanel.add(openButton, gbc); + gbc.gridx = 0; + statusPanel.add(statusLabel, gbc); + gbc.gridy = 1; + statusPanel.add(openButton, gbc); gbc.gridy = 0; JPanel progressPanel = new JPanel(new GridBagLayout()); @@ -345,10 +341,10 @@ private void createUI(Container pane) { JPanel optionsPanel = new JPanel(new GridBagLayout()); optionsPanel.setBorder(emptyBorder); - optionLog = new JButton(rb.getString("Log")); - optionHistory = new JButton(rb.getString("History")); - optionQueue = new JButton(rb.getString("Queue")); - optionConfiguration = new JButton(rb.getString("Configuration")); + optionLog = new JButton(Utils.getLocalizedString("Log")); + optionHistory = new JButton(Utils.getLocalizedString("History")); + optionQueue = new JButton(Utils.getLocalizedString("queue")); + optionConfiguration = new JButton(Utils.getLocalizedString("Configuration")); optionLog.setFont(optionLog.getFont().deriveFont(Font.PLAIN)); optionHistory.setFont(optionLog.getFont().deriveFont(Font.PLAIN)); optionQueue.setFont(optionLog.getFont().deriveFont(Font.PLAIN)); @@ -363,11 +359,16 @@ private void createUI(Container pane) { optionQueue.setIcon(new ImageIcon(icon)); icon = ImageIO.read(getClass().getClassLoader().getResource("gear.png")); optionConfiguration.setIcon(new ImageIcon(icon)); - } catch (Exception e) { } - gbc.gridx = 0; optionsPanel.add(optionLog, gbc); - gbc.gridx = 1; optionsPanel.add(optionHistory, gbc); - gbc.gridx = 2; optionsPanel.add(optionQueue, gbc); - gbc.gridx = 3; optionsPanel.add(optionConfiguration, gbc); + } catch (Exception e) { + } + gbc.gridx = 0; + optionsPanel.add(optionLog, gbc); + gbc.gridx = 1; + optionsPanel.add(optionHistory, gbc); + gbc.gridx = 2; + optionsPanel.add(optionQueue, gbc); + gbc.gridx = 3; + optionsPanel.add(optionConfiguration, gbc); logPanel = new JPanel(new GridBagLayout()); logPanel.setBorder(emptyBorder); @@ -389,30 +390,37 @@ private void createUI(Container pane) { historyPanel.setPreferredSize(new Dimension(300, 250)); historyTableModel = new AbstractTableModel() { private static final long serialVersionUID = 1L; + @Override public String getColumnName(int col) { return HISTORY.getColumnName(col); } + @Override public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } + @Override public Object getValueAt(int row, int col) { return HISTORY.getValueAt(row, col); } + @Override public int getRowCount() { return HISTORY.toList().size(); } + @Override public int getColumnCount() { return HISTORY.getColumnCount(); } + @Override public boolean isCellEditable(int row, int col) { return (col == 0 || col == 4); } + @Override public void setValueAt(Object value, int row, int col) { if (col == 4) { @@ -440,9 +448,9 @@ public void setValueAt(Object value, int row, int col) { historyTable.getColumnModel().getColumn(i).setPreferredWidth(width); } JScrollPane historyTableScrollPane = new JScrollPane(historyTable); - historyButtonRemove = new JButton(rb.getString("remove")); - historyButtonClear = new JButton(rb.getString("clear")); - historyButtonRerip = new JButton(rb.getString("re-rip.checked")); + historyButtonRemove = new JButton(Utils.getLocalizedString("remove")); + historyButtonClear = new JButton(Utils.getLocalizedString("clear")); + historyButtonRerip = new JButton(Utils.getLocalizedString("re-rip.checked")); gbc.gridx = 0; // History List Panel JPanel historyTablePanel = new JPanel(new GridBagLayout()); @@ -456,10 +464,14 @@ public void setValueAt(Object value, int row, int col) { JPanel historyButtonPanel = new JPanel(new GridBagLayout()); historyButtonPanel.setPreferredSize(new Dimension(300, 10)); historyButtonPanel.setBorder(emptyBorder); - gbc.gridx = 0; historyButtonPanel.add(historyButtonRemove, gbc); - gbc.gridx = 1; historyButtonPanel.add(historyButtonClear, gbc); - gbc.gridx = 2; historyButtonPanel.add(historyButtonRerip, gbc); - gbc.gridy = 1; gbc.gridx = 0; + gbc.gridx = 0; + historyButtonPanel.add(historyButtonRemove, gbc); + gbc.gridx = 1; + historyButtonPanel.add(historyButtonClear, gbc); + gbc.gridx = 2; + historyButtonPanel.add(historyButtonRerip, gbc); + gbc.gridy = 1; + gbc.gridx = 0; gbc.weighty = 0; gbc.fill = GridBagConstraints.HORIZONTAL; historyPanel.add(historyButtonPanel, gbc); @@ -468,17 +480,17 @@ public void setValueAt(Object value, int row, int col) { queuePanel.setBorder(emptyBorder); queuePanel.setVisible(false); queuePanel.setPreferredSize(new Dimension(300, 250)); - queueListModel = new DefaultListModel(); + queueListModel = new DefaultListModel(); JList queueList = new JList(queueListModel); queueList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - queueList.addMouseListener(new QueueMenuMouseListener()); - JScrollPane queueListScroll = new JScrollPane(queueList, - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + queueList.addMouseListener(queueMenuMouseListener = new QueueMenuMouseListener((model) -> updateQueue(model))); + JScrollPane queueListScroll = new JScrollPane(queueList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); for (String item : Utils.getConfigList("queue")) { queueListModel.addElement(item); } - updateQueueLabel(); + updateQueue(); + gbc.gridx = 0; JPanel queueListPanel = new JPanel(new GridBagLayout()); gbc.fill = GridBagConstraints.BOTH; @@ -493,32 +505,42 @@ public void setValueAt(Object value, int row, int col) { configurationPanel.setBorder(emptyBorder); configurationPanel.setVisible(false); // TODO Configuration components - configUpdateButton = new JButton(rb.getString("check.for.updates")); - configUpdateLabel = new JLabel( rb.getString("current.version") + ": " + UpdateUtils.getThisJarVersion(), JLabel.RIGHT); - configThreadsLabel = new JLabel(rb.getString("max.download.threads") + ":", JLabel.RIGHT); - configTimeoutLabel = new JLabel(rb.getString("timeout.mill"), JLabel.RIGHT); - configRetriesLabel = new JLabel(rb.getString("retry.download.count"), JLabel.RIGHT); + configUpdateButton = new JButton(Utils.getLocalizedString("check.for.updates")); + configUpdateLabel = new JLabel( + Utils.getLocalizedString("current.version") + ": " + UpdateUtils.getThisJarVersion(), JLabel.RIGHT); + configThreadsLabel = new JLabel(Utils.getLocalizedString("max.download.threads") + ":", JLabel.RIGHT); + configTimeoutLabel = new JLabel(Utils.getLocalizedString("timeout.mill"), JLabel.RIGHT); + configRetriesLabel = new JLabel(Utils.getLocalizedString("retry.download.count"), JLabel.RIGHT); configThreadsText = new JTextField(Integer.toString(Utils.getConfigInteger("threads.size", 3))); configTimeoutText = new JTextField(Integer.toString(Utils.getConfigInteger("download.timeout", 60000))); configRetriesText = new JTextField(Integer.toString(Utils.getConfigInteger("download.retries", 3))); - configOverwriteCheckbox = addNewCheckbox(rb.getString("overwrite.existing.files"), "file.overwrite", false); - configAutoupdateCheckbox = addNewCheckbox(rb.getString("auto.update"), "auto.update", true); - configPlaySound = addNewCheckbox(rb.getString("sound.when.rip.completes"), "play.sound", false); - configShowPopup = addNewCheckbox(rb.getString("notification.when.rip.starts"), "download.show_popup", false); - configSaveOrderCheckbox = addNewCheckbox(rb.getString("preserve.order"), "download.save_order", true); - configSaveLogs = addNewCheckbox(rb.getString("save.logs"), "log.save", false); - configSaveURLsOnly = addNewCheckbox(rb.getString("save.urls.only"), "urls_only.save", false); - configSaveAlbumTitles = addNewCheckbox(rb.getString("save.album.titles"), "album_titles.save", true); - configClipboardAutorip = addNewCheckbox(rb.getString("autorip.from.clipboard"), "clipboard.autorip", false); - configSaveDescriptions = addNewCheckbox(rb.getString("save.descriptions"), "descriptions.save", true); - configPreferMp4 = addNewCheckbox(rb.getString("prefer.mp4.over.gif"),"prefer.mp4", false); - configWindowPosition = addNewCheckbox(rb.getString("restore.window.position"), "window.position", true); - configURLHistoryCheckbox = addNewCheckbox(rb.getString("remember.url.history"), "remember.url_history", true); - configUrlFileChooserButton = new JButton(rb.getString("download.url.list")); - - configLogLevelCombobox = new JComboBox<>(new String[] {"Log level: Error", "Log level: Warn", "Log level: Info", "Log level: Debug"}); + configOverwriteCheckbox = addNewCheckbox(Utils.getLocalizedString("overwrite.existing.files"), "file.overwrite", + false); + configAutoupdateCheckbox = addNewCheckbox(Utils.getLocalizedString("auto.update"), "auto.update", true); + configPlaySound = addNewCheckbox(Utils.getLocalizedString("sound.when.rip.completes"), "play.sound", false); + configShowPopup = addNewCheckbox(Utils.getLocalizedString("notification.when.rip.starts"), + "download.show_popup", false); + configSaveOrderCheckbox = addNewCheckbox(Utils.getLocalizedString("preserve.order"), "download.save_order", + true); + configSaveLogs = addNewCheckbox(Utils.getLocalizedString("save.logs"), "log.save", false); + configSaveURLsOnly = addNewCheckbox(Utils.getLocalizedString("save.urls.only"), "urls_only.save", false); + configSaveAlbumTitles = addNewCheckbox(Utils.getLocalizedString("save.album.titles"), "album_titles.save", + true); + configClipboardAutorip = addNewCheckbox(Utils.getLocalizedString("autorip.from.clipboard"), "clipboard.autorip", + false); + configSaveDescriptions = addNewCheckbox(Utils.getLocalizedString("save.descriptions"), "descriptions.save", + true); + configPreferMp4 = addNewCheckbox(Utils.getLocalizedString("prefer.mp4.over.gif"), "prefer.mp4", false); + configWindowPosition = addNewCheckbox(Utils.getLocalizedString("restore.window.position"), "window.position", + true); + configURLHistoryCheckbox = addNewCheckbox(Utils.getLocalizedString("remember.url.history"), + "remember.url_history", true); + configUrlFileChooserButton = new JButton(Utils.getLocalizedString("download.url.list")); + + configLogLevelCombobox = new JComboBox<>( + new String[] { "Log level: Error", "Log level: Warn", "Log level: Info", "Log level: Debug" }); configSelectLangComboBox = new JComboBox<>(supportedLanges); - configSelectLangComboBox.setSelectedItem(rb.getLocale().toString()); + configSelectLangComboBox.setSelectedItem(Utils.getLanguage()); configLogLevelCombobox.setSelectedItem(Utils.getConfigString("log.level", "Log level: Debug")); setLogLevel(configLogLevelCombobox.getSelectedItem().toString()); configSaveDirLabel = new JLabel(); @@ -527,10 +549,11 @@ public void setValueAt(Object value, int row, int col) { configSaveDirLabel.setText(workingDir); configSaveDirLabel.setForeground(Color.BLUE); configSaveDirLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); - } catch (Exception e) { } + } catch (Exception e) { + } configSaveDirLabel.setToolTipText(configSaveDirLabel.getText()); configSaveDirLabel.setHorizontalAlignment(JLabel.RIGHT); - configSaveDirButton = new JButton(rb.getString("select.save.dir") + "..."); + configSaveDirButton = new JButton(Utils.getLocalizedString("select.save.dir") + "..."); addItemToConfigGridBagConstraints(gbc, 0, configUpdateLabel, configUpdateButton); addItemToConfigGridBagConstraints(gbc, 1, configAutoupdateCheckbox, configLogLevelCombobox); @@ -546,84 +569,114 @@ public void setValueAt(Object value, int row, int col) { addItemToConfigGridBagConstraints(gbc, 11, configSelectLangComboBox, configUrlFileChooserButton); addItemToConfigGridBagConstraints(gbc, 12, configSaveDirLabel, configSaveDirButton); - - - emptyPanel = new JPanel(); emptyPanel.setPreferredSize(new Dimension(0, 0)); emptyPanel.setSize(0, 0); gbc.anchor = GridBagConstraints.PAGE_START; - gbc.gridy = 0; pane.add(ripPanel, gbc); - gbc.gridy = 1; pane.add(statusPanel, gbc); - gbc.gridy = 2; pane.add(progressPanel, gbc); - gbc.gridy = 3; pane.add(optionsPanel, gbc); + gbc.gridy = 0; + pane.add(ripPanel, gbc); + gbc.gridy = 1; + pane.add(statusPanel, gbc); + gbc.gridy = 2; + pane.add(progressPanel, gbc); + gbc.gridy = 3; + pane.add(optionsPanel, gbc); gbc.weighty = 1; gbc.fill = GridBagConstraints.BOTH; - gbc.gridy = 4; pane.add(logPanel, gbc); - gbc.gridy = 5; pane.add(historyPanel, gbc); - gbc.gridy = 5; pane.add(queuePanel, gbc); - gbc.gridy = 5; pane.add(configurationPanel, gbc); - gbc.gridy = 5; pane.add(emptyPanel, gbc); + gbc.gridy = 4; + pane.add(logPanel, gbc); + gbc.gridy = 5; + pane.add(historyPanel, gbc); + gbc.gridy = 5; + pane.add(queuePanel, gbc); + gbc.gridy = 5; + pane.add(configurationPanel, gbc); + gbc.gridy = 5; + pane.add(emptyPanel, gbc); gbc.weighty = 0; gbc.fill = GridBagConstraints.HORIZONTAL; } - private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JLabel thing1ToAdd, JButton thing2ToAdd ) { - gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc); - gbc.gridx = 1; configurationPanel.add(thing2ToAdd, gbc); + private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JLabel thing1ToAdd, + JButton thing2ToAdd) { + gbc.gridy = gbcYValue; + gbc.gridx = 0; + configurationPanel.add(thing1ToAdd, gbc); + gbc.gridx = 1; + configurationPanel.add(thing2ToAdd, gbc); } - private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JLabel thing1ToAdd, JTextField thing2ToAdd ) { - gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc); - gbc.gridx = 1; configurationPanel.add(thing2ToAdd, gbc); + private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JLabel thing1ToAdd, + JTextField thing2ToAdd) { + gbc.gridy = gbcYValue; + gbc.gridx = 0; + configurationPanel.add(thing1ToAdd, gbc); + gbc.gridx = 1; + configurationPanel.add(thing2ToAdd, gbc); } - private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JCheckBox thing1ToAdd, JCheckBox thing2ToAdd ) { - gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc); - gbc.gridx = 1; configurationPanel.add(thing2ToAdd, gbc); + private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JCheckBox thing1ToAdd, + JCheckBox thing2ToAdd) { + gbc.gridy = gbcYValue; + gbc.gridx = 0; + configurationPanel.add(thing1ToAdd, gbc); + gbc.gridx = 1; + configurationPanel.add(thing2ToAdd, gbc); } - private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JCheckBox thing1ToAdd, JComboBox thing2ToAdd ) { - gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc); - gbc.gridx = 1; configurationPanel.add(thing2ToAdd, gbc); + private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JCheckBox thing1ToAdd, + JComboBox thing2ToAdd) { + gbc.gridy = gbcYValue; + gbc.gridx = 0; + configurationPanel.add(thing1ToAdd, gbc); + gbc.gridx = 1; + configurationPanel.add(thing2ToAdd, gbc); } - private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JComboBox thing1ToAdd, JButton thing2ToAdd ) { - gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc); - gbc.gridx = 1; configurationPanel.add(thing2ToAdd, gbc); + private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JComboBox thing1ToAdd, + JButton thing2ToAdd) { + gbc.gridy = gbcYValue; + gbc.gridx = 0; + configurationPanel.add(thing1ToAdd, gbc); + gbc.gridx = 1; + configurationPanel.add(thing2ToAdd, gbc); } - private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JComboBox thing1ToAdd ) { - gbc.gridy = gbcYValue; gbc.gridx = 0; configurationPanel.add(thing1ToAdd, gbc); + private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JComboBox thing1ToAdd) { + gbc.gridy = gbcYValue; + gbc.gridx = 0; + configurationPanel.add(thing1ToAdd, gbc); } private void changeLocale() { - statusLabel.setText(rb.getString("inactive")); - configUpdateButton.setText(rb.getString("check.for.updates")); - configUpdateLabel.setText(rb.getString("current.version") + ": " + UpdateUtils.getThisJarVersion()); - configThreadsLabel.setText(rb.getString("max.download.threads")); - configTimeoutLabel.setText(rb.getString("timeout.mill")); - configRetriesLabel.setText(rb.getString("retry.download.count")); - configOverwriteCheckbox.setText(rb.getString("overwrite.existing.files")); - configAutoupdateCheckbox.setText(rb.getString("auto.update")); - configPlaySound.setText(rb.getString("sound.when.rip.completes")); - configShowPopup.setText(rb.getString("notification.when.rip.starts")); - configSaveOrderCheckbox.setText(rb.getString("preserve.order")); - configSaveLogs.setText(rb.getString("save.logs")); - configSaveURLsOnly.setText(rb.getString("save.urls.only")); - configSaveAlbumTitles.setText(rb.getString("save.album.titles")); - configClipboardAutorip.setText(rb.getString("autorip.from.clipboard")); - configSaveDescriptions.setText(rb.getString("save.descriptions")); - configUrlFileChooserButton.setText(rb.getString("download.url.list")); - configSaveDirButton.setText(rb.getString("select.save.dir") + "..."); - configPreferMp4.setText(rb.getString("prefer.mp4.over.gif")); - configWindowPosition.setText(rb.getString("restore.window.position")); - configURLHistoryCheckbox.setText(rb.getString("remember.url.history")); - optionLog.setText(rb.getString("Log")); - optionHistory.setText(rb.getString("History")); - optionQueue.setText(rb.getString("Queue")); - optionConfiguration.setText(rb.getString("Configuration")); + statusLabel.setText(Utils.getLocalizedString("inactive")); + configUpdateButton.setText(Utils.getLocalizedString("check.for.updates")); + configUpdateLabel.setText(Utils.getLocalizedString("current.version") + ": " + UpdateUtils.getThisJarVersion()); + configThreadsLabel.setText(Utils.getLocalizedString("max.download.threads")); + configTimeoutLabel.setText(Utils.getLocalizedString("timeout.mill")); + configRetriesLabel.setText(Utils.getLocalizedString("retry.download.count")); + configOverwriteCheckbox.setText(Utils.getLocalizedString("overwrite.existing.files")); + configAutoupdateCheckbox.setText(Utils.getLocalizedString("auto.update")); + configPlaySound.setText(Utils.getLocalizedString("sound.when.rip.completes")); + configShowPopup.setText(Utils.getLocalizedString("notification.when.rip.starts")); + configSaveOrderCheckbox.setText(Utils.getLocalizedString("preserve.order")); + configSaveLogs.setText(Utils.getLocalizedString("save.logs")); + configSaveURLsOnly.setText(Utils.getLocalizedString("save.urls.only")); + configSaveAlbumTitles.setText(Utils.getLocalizedString("save.album.titles")); + configClipboardAutorip.setText(Utils.getLocalizedString("autorip.from.clipboard")); + configSaveDescriptions.setText(Utils.getLocalizedString("save.descriptions")); + configUrlFileChooserButton.setText(Utils.getLocalizedString("download.url.list")); + configSaveDirButton.setText(Utils.getLocalizedString("select.save.dir") + "..."); + configPreferMp4.setText(Utils.getLocalizedString("prefer.mp4.over.gif")); + configWindowPosition.setText(Utils.getLocalizedString("restore.window.position")); + configURLHistoryCheckbox.setText(Utils.getLocalizedString("remember.url.history")); + optionLog.setText(Utils.getLocalizedString("Log")); + optionHistory.setText(Utils.getLocalizedString("History")); + optionQueue.setText(Utils.getLocalizedString("queue")); + optionConfiguration.setText(Utils.getLocalizedString("Configuration")); + + queueMenuMouseListener.updateUI(); } private void setupHandlers() { @@ -634,14 +687,17 @@ private void setupHandlers() { public void removeUpdate(DocumentEvent e) { update(); } + @Override public void insertUpdate(DocumentEvent e) { update(); } + @Override public void changedUpdate(DocumentEvent e) { update(); } + private void update() { try { String urlText = ripTextfield.getText().trim(); @@ -668,7 +724,7 @@ private void update() { statusProgress.setVisible(false); pack(); statusProgress.setValue(0); - status("Ripping interrupted"); + status(Utils.getLocalizedString("ripping.interrupted")); appendLog("Ripper interrupted", Color.RED); } }); @@ -744,7 +800,8 @@ private void update() { } try { historyTableModel.fireTableDataChanged(); - } catch (Exception e) { } + } catch (Exception e) { + } saveHistory(); }); historyButtonClear.addActionListener(event -> { @@ -778,8 +835,7 @@ private void update() { } saveHistory(); }); - } - else { + } else { Utils.clearURLHistory(); HISTORY.clear(); try { @@ -793,10 +849,8 @@ private void update() { // Re-rip all history historyButtonRerip.addActionListener(event -> { if (HISTORY.isEmpty()) { - JOptionPane.showMessageDialog(null, - "There are no history entries to re-rip. Rip some albums first", - "RipMe Error", - JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(null, "There are no history entries to re-rip. Rip some albums first", + "RipMe Error", JOptionPane.ERROR_MESSAGE); return; } int added = 0; @@ -807,11 +861,9 @@ private void update() { } } if (added == 0) { - JOptionPane.showMessageDialog(null, - "No history entries have been 'Checked'\n" + - "Check an entry by clicking the checkbox to the right of the URL or Right-click a URL to check/uncheck all items", - "RipMe Error", - JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(null, "No history entries have been 'Checked'\n" + + "Check an entry by clicking the checkbox to the right of the URL or Right-click a URL to check/uncheck all items", + "RipMe Error", JOptionPane.ERROR_MESSAGE); } }); configUpdateButton.addActionListener(arg0 -> { @@ -824,7 +876,7 @@ private void update() { }); configSelectLangComboBox.addActionListener(arg0 -> { String level = ((JComboBox) arg0.getSource()).getSelectedItem().toString(); - rb = Utils.getResourceBundle(level); + Utils.setLanguage(level); changeLocale(); }); configSaveDirLabel.addMouseListener(new MouseAdapter() { @@ -834,7 +886,8 @@ public void mouseClicked(MouseEvent e) { Desktop desktop = Desktop.getDesktop(); try { desktop.open(file); - } catch (Exception e1) { } + } catch (Exception e1) { + } } }); configSaveDirButton.addActionListener(arg0 -> { @@ -882,11 +935,10 @@ public void mouseClicked(MouseEvent e) { } } - - } catch(IOException e) { - LOGGER.error("Error reading file " + e.getMessage()); - } - }); + } catch (IOException e) { + LOGGER.error("Error reading file " + e.getMessage()); + } + }); addCheckboxListener(configSaveOrderCheckbox, "download.save_order"); addCheckboxListener(configOverwriteCheckbox, "file.overwrite"); addCheckboxListener(configSaveLogs, "log.save"); @@ -896,7 +948,7 @@ public void mouseClicked(MouseEvent e) { addCheckboxListener(configSaveDescriptions, "descriptions.save"); addCheckboxListener(configPreferMp4, "prefer.mp4"); addCheckboxListener(configWindowPosition, "window.position"); - + configClipboardAutorip.addActionListener(arg0 -> { Utils.setConfigBoolean("clipboard.autorip", configClipboardAutorip.isSelected()); ClipboardUtils.setClipboardAutoRip(configClipboardAutorip.isSelected()); @@ -907,15 +959,20 @@ public void mouseClicked(MouseEvent e) { queueListModel.addListDataListener(new ListDataListener() { @Override public void intervalAdded(ListDataEvent arg0) { - updateQueueLabel(); + updateQueue(); + if (!isRipping) { ripNextAlbum(); } } + @Override - public void contentsChanged(ListDataEvent arg0) { } + public void contentsChanged(ListDataEvent arg0) { + } + @Override - public void intervalRemoved(ListDataEvent arg0) { } + public void intervalRemoved(ListDataEvent arg0) { + } }); } @@ -923,26 +980,26 @@ private void setLogLevel(String level) { Level newLevel = Level.ERROR; level = level.substring(level.lastIndexOf(' ') + 1); switch (level) { - case "Debug": - newLevel = Level.DEBUG; - break; - case "Info": - newLevel = Level.INFO; - break; - case "Warn": - newLevel = Level.WARN; - break; - case "Error": - newLevel = Level.ERROR; - break; + case "Debug": + newLevel = Level.DEBUG; + break; + case "Info": + newLevel = Level.INFO; + break; + case "Warn": + newLevel = Level.WARN; + break; + case "Error": + newLevel = Level.ERROR; + break; } Logger.getRootLogger().setLevel(newLevel); LOGGER.setLevel(newLevel); - ConsoleAppender ca = (ConsoleAppender)Logger.getRootLogger().getAppender("stdout"); + ConsoleAppender ca = (ConsoleAppender) Logger.getRootLogger().getAppender("stdout"); if (ca != null) { ca.setThreshold(newLevel); } - FileAppender fa = (FileAppender)Logger.getRootLogger().getAppender("FILE"); + FileAppender fa = (FileAppender) Logger.getRootLogger().getAppender("FILE"); if (fa != null) { fa.setThreshold(newLevel); } @@ -951,13 +1008,24 @@ private void setLogLevel(String level) { private void setupTrayIcon() { mainFrame.addWindowListener(new WindowAdapter() { @Override - public void windowActivated(WindowEvent e) { trayMenuMain.setLabel("Hide"); } + public void windowActivated(WindowEvent e) { + trayMenuMain.setLabel("Hide"); + } + @Override - public void windowDeactivated(WindowEvent e) { trayMenuMain.setLabel("Show"); } + public void windowDeactivated(WindowEvent e) { + trayMenuMain.setLabel("Show"); + } + @Override - public void windowDeiconified(WindowEvent e) { trayMenuMain.setLabel("Hide"); } + public void windowDeiconified(WindowEvent e) { + trayMenuMain.setLabel("Hide"); + } + @Override - public void windowIconified(WindowEvent e) { trayMenuMain.setLabel("Show"); } + public void windowIconified(WindowEvent e) { + trayMenuMain.setLabel("Show"); + } }); PopupMenu trayMenu = new PopupMenu(); trayMenuMain = new MenuItem("Hide"); @@ -965,9 +1033,7 @@ private void setupTrayIcon() { MenuItem trayMenuAbout = new MenuItem("About " + mainFrame.getTitle()); trayMenuAbout.addActionListener(arg0 -> { StringBuilder about = new StringBuilder(); - about.append("

") - .append(mainFrame.getTitle()) - .append("

"); + about.append("

").append(mainFrame.getTitle()).append("

"); about.append("Download albums from various websites:"); try { List rippers = Utils.getListOfAlbumRippers(); @@ -982,8 +1048,9 @@ private void setupTrayIcon() { about.append(""); } about.append(""); - } catch (Exception e) { } - about.append("
And download videos from video sites:"); + } catch (Exception e) { + } + about.append("
And download videos from video sites:"); try { List rippers = Utils.getListOfVideoRippers(); about.append("
    "); @@ -997,16 +1064,13 @@ private void setupTrayIcon() { about.append(""); } about.append("
"); - } catch (Exception e) { } + } catch (Exception e) { + } about.append("Do you want to visit the project homepage on Github?"); about.append(""); - int response = JOptionPane.showConfirmDialog(null, - about.toString(), - mainFrame.getTitle(), - JOptionPane.YES_NO_OPTION, - JOptionPane.PLAIN_MESSAGE, - new ImageIcon(mainIcon)); + int response = JOptionPane.showConfirmDialog(null, about.toString(), mainFrame.getTitle(), + JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, new ImageIcon(mainIcon)); if (response == JOptionPane.YES_OPTION) { try { Desktop.getDesktop().browse(URI.create("http://github.com/ripmeapp/ripme")); @@ -1047,15 +1111,14 @@ public void mouseClicked(MouseEvent e) { } }); } catch (IOException | AWTException e) { - //TODO implement proper stack trace handling this is really just intented as a placeholder until you implement proper error handling + // TODO implement proper stack trace handling this is really just intented as a + // placeholder until you implement proper error handling e.printStackTrace(); } } private void toggleTrayClick() { - if (mainFrame.getExtendedState() == JFrame.ICONIFIED - || !mainFrame.isActive() - || !mainFrame.isVisible()) { + if (mainFrame.getExtendedState() == JFrame.ICONIFIED || !mainFrame.isActive() || !mainFrame.isVisible()) { mainFrame.setVisible(true); mainFrame.setAlwaysOnTop(true); mainFrame.setAlwaysOnTop(false); @@ -1069,7 +1132,7 @@ private void toggleTrayClick() { /** * Write a line to the Log section of the GUI * - * @param text the string to log + * @param text the string to log * @param color the color of the line */ private void appendLog(final String text, final Color color) { @@ -1080,7 +1143,8 @@ private void appendLog(final String text, final Color color) { synchronized (this) { sd.insertString(sd.getLength(), text + "\n", sas); } - } catch (BadLocationException e) { } + } catch (BadLocationException e) { + } logText.setCaretPosition(sd.getLength()); } @@ -1088,7 +1152,7 @@ private void appendLog(final String text, final Color color) { /** * Write a line to the GUI log and the CLI log * - * @param line the string to log + * @param line the string to log * @param color the color of the line for the GUI log */ public void displayAndLogError(String line, Color color) { @@ -1101,25 +1165,25 @@ private void loadHistory() { HISTORY.clear(); if (historyFile.exists()) { try { - LOGGER.info(rb.getString("loading.history.from") + " " + historyFile.getCanonicalPath()); + LOGGER.info(Utils.getLocalizedString("loading.history.from") + " " + historyFile.getCanonicalPath()); HISTORY.fromFile(historyFile.getCanonicalPath()); } catch (IOException e) { LOGGER.error("Failed to load history from file " + historyFile, e); JOptionPane.showMessageDialog(null, - "RipMe failed to load the history file at " + historyFile.getAbsolutePath() + "\n\n" + - "Error: " + e.getMessage() + "\n\n" + - "Closing RipMe will automatically overwrite the contents of this file,\n" + - "so you may want to back the file up before closing RipMe!", - "RipMe - history load failure", - JOptionPane.ERROR_MESSAGE); + "RipMe failed to load the history file at " + historyFile.getAbsolutePath() + "\n\n" + "Error: " + + e.getMessage() + "\n\n" + + "Closing RipMe will automatically overwrite the contents of this file,\n" + + "so you may want to back the file up before closing RipMe!", + "RipMe - history load failure", JOptionPane.ERROR_MESSAGE); } } else { - LOGGER.info(rb.getString("loading.history.from.configuration")); + LOGGER.info(Utils.getLocalizedString("loading.history.from.configuration")); HISTORY.fromList(Utils.getConfigList("download.history")); if (HISTORY.toList().isEmpty()) { // Loaded from config, still no entries. // Guess rip history based on rip folder - String[] dirs = Utils.getWorkingDirectory().list((dir, file) -> new File(dir.getAbsolutePath() + File.separator + file).isDirectory()); + String[] dirs = Utils.getWorkingDirectory() + .list((dir, file) -> new File(dir.getAbsolutePath() + File.separator + file).isDirectory()); for (String dir : dirs) { String url = RipUtils.urlFromDirectoryName(dir); if (url != null) { @@ -1160,13 +1224,15 @@ private void ripNextAlbum() { return; } String nextAlbum = (String) queueListModel.remove(0); - updateQueueLabel(); + + updateQueue(); + Thread t = ripAlbum(nextAlbum); if (t == null) { try { Thread.sleep(500); } catch (InterruptedException ie) { - LOGGER.error(rb.getString("interrupted.while.waiting.to.rip.next.album"), ie); + LOGGER.error(Utils.getLocalizedString("interrupted.while.waiting.to.rip.next.album"), ie); } ripNextAlbum(); } else { @@ -1175,7 +1241,7 @@ private void ripNextAlbum() { } private Thread ripAlbum(String urlString) { - //shutdownCleanup(); + // shutdownCleanup(); if (!logPanel.isVisible()) { optionLog.doClick(); } @@ -1214,11 +1280,11 @@ private Thread ripAlbum(String urlString) { status("Starting rip..."); ripper.setObserver(this); Thread t = new Thread(ripper); - if (configShowPopup.isSelected() && - (!mainFrame.isVisible() || !mainFrame.isActive())) { + if (configShowPopup.isSelected() && (!mainFrame.isVisible() || !mainFrame.isActive())) { mainFrame.toFront(); mainFrame.setAlwaysOnTop(true); - trayIcon.displayMessage(mainFrame.getTitle(), "Started ripping " + ripper.getURL().toExternalForm(), MessageType.INFO); + trayIcon.displayMessage(mainFrame.getTitle(), "Started ripping " + ripper.getURL().toExternalForm(), + MessageType.INFO); mainFrame.setAlwaysOnTop(false); } return t; @@ -1262,7 +1328,7 @@ public void actionPerformed(ActionEvent event) { String rangeToParse = url.substring(url.indexOf("{") + 1, url.indexOf("}")); int rangeStart = Integer.parseInt(rangeToParse.split("-")[0]); int rangeEnd = Integer.parseInt(rangeToParse.split("-")[1]); - for (int i = rangeStart; i < rangeEnd +1; i++) { + for (int i = rangeStart; i < rangeEnd + 1; i++) { String realURL = url.replaceAll("\\{\\S*\\}", Integer.toString(i)); if (canRip(realURL)) { queueListModel.add(queueListModel.size(), realURL); @@ -1307,9 +1373,9 @@ private synchronized void handleEvent(StatusEvent evt) { int completedPercent = evt.ripper.getCompletionPercentage(); statusProgress.setValue(completedPercent); statusProgress.setVisible(true); - status( evt.ripper.getStatusText() ); + status(evt.ripper.getStatusText()); - switch(msg.getStatus()) { + switch (msg.getStatus()) { case LOADING_RESOURCE: case DOWNLOAD_STARTED: if (LOGGER.isEnabledFor(Level.INFO)) { @@ -1365,7 +1431,8 @@ private synchronized void handleEvent(StatusEvent evt) { entry.count = rsc.count; try { entry.title = ripper.getAlbumTitle(ripper.getURL()); - } catch (MalformedURLException e) { } + } catch (MalformedURLException e) { + } HISTORY.add(entry); historyTableModel.fireTableDataChanged(); } @@ -1384,10 +1451,10 @@ private synchronized void handleEvent(StatusEvent evt) { try { Image folderIcon = ImageIO.read(getClass().getClassLoader().getResource("folder.png")); openButton.setIcon(new ImageIcon(folderIcon)); - } catch (Exception e) { } - /* content key - * %path% the path to the album folder - * %url% is the album url + } catch (Exception e) { + } + /* + * content key %path% the path to the album folder %url% is the album url */ if (Utils.getConfigBoolean("enable.finish.command", false)) { try { @@ -1395,13 +1462,12 @@ private synchronized void handleEvent(StatusEvent evt) { commandToRun = commandToRun.replaceAll("%url%", url); commandToRun = commandToRun.replaceAll("%path%", f.getAbsolutePath()); LOGGER.info("RUnning command " + commandToRun); - // code from: https://stackoverflow.com/questions/5711084/java-runtime-getruntime-getting-output-from-executing-a-command-line-program + // code from: + // https://stackoverflow.com/questions/5711084/java-runtime-getruntime-getting-output-from-executing-a-command-line-program Process proc = Runtime.getRuntime().exec(commandToRun); - BufferedReader stdInput = new BufferedReader(new - InputStreamReader(proc.getInputStream())); + BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream())); - BufferedReader stdError = new BufferedReader(new - InputStreamReader(proc.getErrorStream())); + BufferedReader stdError = new BufferedReader(new InputStreamReader(proc.getErrorStream())); // read the output from the command LOGGER.info("Command output:\n"); @@ -1472,9 +1538,11 @@ public static void disableWindowPositioning() { private static boolean hasWindowPositionBug() { String osName = System.getProperty("os.name"); - // Java on Windows has a bug where if we try to manually set the position of the Window, + // Java on Windows has a bug where if we try to manually set the position of the + // Window, // javaw.exe will not close itself down when the application is closed. - // Therefore, even if isWindowPositioningEnabled, if we are on Windows, we ignore it. + // Therefore, even if isWindowPositioningEnabled, if we are on Windows, we + // ignore it. return osName == null || osName.startsWith("Windows"); } @@ -1500,8 +1568,8 @@ private static void saveWindowPosition(Frame frame) { return; } } - int x = (int)point.getX(); - int y = (int)point.getY(); + int x = (int) point.getX(); + int y = (int) point.getY(); int w = frame.getWidth(); int h = frame.getHeight(); Utils.setConfigInteger("window.x", x); diff --git a/src/main/java/com/rarchives/ripme/utils/Utils.java b/src/main/java/com/rarchives/ripme/utils/Utils.java index 8a8699a36..4333a9f55 100644 --- a/src/main/java/com/rarchives/ripme/utils/Utils.java +++ b/src/main/java/com/rarchives/ripme/utils/Utils.java @@ -50,6 +50,8 @@ public class Utils { private static HashMap> cookieCache; private static HashMap magicHash = new HashMap<>(); + private static ResourceBundle resourceBundle = null; + static { cookieCache = new HashMap<>(); @@ -83,6 +85,8 @@ public class Utils { } catch (Exception e) { LOGGER.error("[!] Failed to load properties file from " + CONFIG_FILE, e); } + + resourceBundle = getResourceBundle(null); } /** @@ -737,6 +741,19 @@ public static ResourceBundle getResourceBundle(String langSelect) { } } + public static void setLanguage(String langSelect) { + resourceBundle = getResourceBundle(langSelect); + } + + public static String getLanguage() { + return resourceBundle.getLocale().toString(); + } + + public static String getLocalizedString(String key) { + LOGGER.debug(String.format("Getting key %s in %s value %s",key, getLanguage(), resourceBundle.getString(key))); + return resourceBundle.getString(key); + } + /** * Formats and reuturns the status text for rippers using the byte progress bar * diff --git a/src/main/resources/LabelsBundle.properties b/src/main/resources/LabelsBundle.properties index 503d3b644..215e0f55d 100644 --- a/src/main/resources/LabelsBundle.properties +++ b/src/main/resources/LabelsBundle.properties @@ -2,7 +2,7 @@ Log = Log History = History created = created modified = modified -Queue = Queue +queue = Queue Configuration = Configuration # Keys for the Configuration menu @@ -27,6 +27,11 @@ restore.window.position = Restore window position remember.url.history = Remember URL history loading.history.from = Loading history from +# Queue keys +queue.remove.all = Remove All +queue.validation = Are you sure you want to remove all elements from the queue? +queue.remove.selected = Remove Selected + # Misc UI keys loading.history.from.configuration = Loading history from configuration diff --git a/src/main/resources/LabelsBundle_ar_AR.properties b/src/main/resources/LabelsBundle_ar_AR.properties index 1a8443b0e..3ec2ca731 100644 --- a/src/main/resources/LabelsBundle_ar_AR.properties +++ b/src/main/resources/LabelsBundle_ar_AR.properties @@ -2,7 +2,7 @@ Log = \u0645\u0644\u0641 \u0627\u0644\u062A\u062A\u0628\u0639 History = \u0630\u0627\u0643\u0631\u0629 \u0627\u0644\u0627\u0633\u062A\u062E\u062F\u0627\u0645 created = \u0627\u0644\u0627\u0646\u0634\u0627\u0621 modified = \u062A\u0645 \u0627\u0644\u062A\u0639\u062F\u064A\u0644 -Queue = \u0637\u0627\u0628\u0648\u0631 +queue = \u0637\u0627\u0628\u0648\u0631 Configuration = \u062A\u0631\u062A\u064A\u0628 # Keys for the Configuration menu diff --git a/src/main/resources/LabelsBundle_de_DE.properties b/src/main/resources/LabelsBundle_de_DE.properties index 868ccec24..a7ec74f1e 100644 --- a/src/main/resources/LabelsBundle_de_DE.properties +++ b/src/main/resources/LabelsBundle_de_DE.properties @@ -2,7 +2,7 @@ History = Verlauf created = erstellt modified = geändert -Queue = Queue +queue = Queue Configuration = Konfiguration # Keys for the Configuration menu diff --git a/src/main/resources/LabelsBundle_en_US.properties b/src/main/resources/LabelsBundle_en_US.properties index 503d3b644..7eb1fb85a 100644 --- a/src/main/resources/LabelsBundle_en_US.properties +++ b/src/main/resources/LabelsBundle_en_US.properties @@ -1,57 +1 @@ -Log = Log -History = History -created = created -modified = modified -Queue = Queue -Configuration = Configuration - -# Keys for the Configuration menu - -current.version = Current version -check.for.updates = Check for updates -auto.update = Auto-update? -max.download.threads = Maximum download threads: -timeout.mill = Timeout (in milliseconds): -retry.download.count = Retry download count -overwrite.existing.files = Overwrite existing files? -sound.when.rip.completes = Sound when rip completes -preserve.order = Preserve order -save.logs = Save logs -notification.when.rip.starts = Notification when rip starts -save.urls.only = Save URLs only -save.album.titles = Save album titles -autorip.from.clipboard = Autorip from Clipboard -save.descriptions = Save descriptions -prefer.mp4.over.gif = Prefer MP4 over GIF -restore.window.position = Restore window position -remember.url.history = Remember URL history -loading.history.from = Loading history from - -# Misc UI keys - -loading.history.from.configuration = Loading history from configuration -interrupted.while.waiting.to.rip.next.album = Interrupted while waiting to rip next album -inactive = Inactive -re-rip.checked = Re-rip Checked -remove = Remove -clear = Clear -download.url.list = Download url list -select.save.dir = Select Save Directory - -# Keys for the logs generated by DownloadFileThread - -nonretriable.status.code = Non-retriable status code -retriable.status.code = Retriable status code -server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads -# A "magic number" can also be called a file signature -was.unable.to.get.content.type.using.magic.number = Was unable to get content type using magic number -magic.number.was = Magic number was -deleting.existing.file = Deleting existing file -request.properties = Request properties -download.interrupted = Download interrupted -exceeded.maximum.retries = Exceeded maximum retries -http.status.exception = HTTP status exception -exception.while.downloading.file = Exception while downloading file -failed.to.download = Failed to download -skipping = Skipping -file.already.exists = file already exists \ No newline at end of file +# This need to be empty since EN is the default language in the bundles \ No newline at end of file diff --git a/src/main/resources/LabelsBundle_es_ES.properties b/src/main/resources/LabelsBundle_es_ES.properties index 88ba098fc..c178ec79c 100644 --- a/src/main/resources/LabelsBundle_es_ES.properties +++ b/src/main/resources/LabelsBundle_es_ES.properties @@ -2,7 +2,7 @@ Log = Log History = Historia created = creado modified = modificado -Queue = Cola +queue = Cola Configuration = Configuracion # Keys for the Configuration menu @@ -27,6 +27,11 @@ restore.window.position = Restaurar posicion de ventana remember.url.history = Recordar historia URL loading.history.from = Cargando historia desde +# Queue keys +queue.remove.all = Eliminar todos los elementos +queue.validation = ¿Esta seguro que desea eliminar todos los elementos de la lista? +queue.remove.selected = Eliminar elementos seleccionados + # Misc UI keys loading.history.from.configuration = Cargando historia desde la configuracion diff --git a/src/main/resources/LabelsBundle_fi_FI.properties b/src/main/resources/LabelsBundle_fi_FI.properties index 4cc4fbe0a..6edd4e45f 100644 --- a/src/main/resources/LabelsBundle_fi_FI.properties +++ b/src/main/resources/LabelsBundle_fi_FI.properties @@ -2,7 +2,7 @@ Log = Logi History = Historia created = luotu modified = muokattu -Queue = Jono +queue = Jono Configuration = Asetukset # Keys for the Configuration menu diff --git a/src/main/resources/LabelsBundle_fr_CH.properties b/src/main/resources/LabelsBundle_fr_CH.properties index 6b2d7c1cd..b489e3e3a 100644 --- a/src/main/resources/LabelsBundle_fr_CH.properties +++ b/src/main/resources/LabelsBundle_fr_CH.properties @@ -2,7 +2,7 @@ Log = Journal History = Historique created = créé le modified = modifié le -Queue = File d'attente +queue = File d'attente Configuration = Configuration # Keys for the Configuration menu diff --git a/src/main/resources/LabelsBundle_in_ID.properties b/src/main/resources/LabelsBundle_in_ID.properties index 6792df56e..b5e773d5b 100644 --- a/src/main/resources/LabelsBundle_in_ID.properties +++ b/src/main/resources/LabelsBundle_in_ID.properties @@ -2,7 +2,7 @@ Log = Log History = Riwayat created = dibuat pada modified = diubah pada -Queue = Antrian +queue = Antrian Configuration = Pengaturan # Keys for the Configuration menu diff --git a/src/main/resources/LabelsBundle_it_IT.properties b/src/main/resources/LabelsBundle_it_IT.properties index f3fdb1325..de00612b7 100644 --- a/src/main/resources/LabelsBundle_it_IT.properties +++ b/src/main/resources/LabelsBundle_it_IT.properties @@ -2,7 +2,7 @@ Log = Log History = Cronologia created = creato modified = modificato -Queue = Coda +queue = Coda Configuration = Configurazione # Keys for the Configuration menu @@ -44,14 +44,14 @@ nonretriable.status.code = Codice di stato irreversibile retriable.status.code = Codice di stato reversibile server.doesnt.support.resuming.downloads = Il server non supporta la ripresa dei download # A "magic number" can also be called a file signature -was.unable.to.get.content.type.using.magic.number = Non stato possibile ottenere il tipo del contenuto usando magic number +was.unable.to.get.content.type.using.magic.number = Non � stato possibile ottenere il tipo del contenuto usando magic number magic.number.was = Magic number era deleting.existing.file = Cancellazione file esistente -request.properties = Richiesta propriet +request.properties = Richiesta propriet� download.interrupted = Download interrotto exceeded.maximum.retries = Superato il numero massimo di tentativi http.status.exception = Eccezione stato HTTP exception.while.downloading.file = Eccezione durante il download del file failed.to.download = Download non riuscito skipping = Saltare -file.already.exists = il file esiste gi \ No newline at end of file +file.already.exists = il file esiste gi� \ No newline at end of file diff --git a/src/main/resources/LabelsBundle_kr_KR.properties b/src/main/resources/LabelsBundle_kr_KR.properties index 5fefceccb..34a35a7a2 100644 --- a/src/main/resources/LabelsBundle_kr_KR.properties +++ b/src/main/resources/LabelsBundle_kr_KR.properties @@ -2,7 +2,7 @@ Log = \uB85C\uADF8 History = \uD788\uC2A4\uD1A0\uB9AC created = \uC0DD\uC0B0\uB428 modified = \uC218\uC815\uB428 -Queue = \uB300\uAE30\uC5F4 +queue = \uB300\uAE30\uC5F4 Configuration = \uAD6C\uC131 # Keys for the Configuration menu diff --git a/src/main/resources/LabelsBundle_nl_NL.properties b/src/main/resources/LabelsBundle_nl_NL.properties index ce3308f68..e1d9d61c3 100644 --- a/src/main/resources/LabelsBundle_nl_NL.properties +++ b/src/main/resources/LabelsBundle_nl_NL.properties @@ -2,7 +2,7 @@ Log = Logboek History = Geschiedenis created = gemaakt modified = aangepast -Queue = Wachtrij +queue = Wachtrij Configuration = Configuratie # Keys for the Configuration menu diff --git a/src/main/resources/LabelsBundle_pl_PL.properties b/src/main/resources/LabelsBundle_pl_PL.properties index 719cfac81..2a6ba3265 100644 --- a/src/main/resources/LabelsBundle_pl_PL.properties +++ b/src/main/resources/LabelsBundle_pl_PL.properties @@ -2,7 +2,7 @@ History = Historia created = Stworzono modified = Zmodyfikowano -Queue = Kolejka +queue = Kolejka Configuration = Konfiguracja # Keys for the Configuration menu diff --git a/src/main/resources/LabelsBundle_porrisavvo_FI.properties b/src/main/resources/LabelsBundle_porrisavvo_FI.properties index 93c02c382..a2ba056e4 100644 --- a/src/main/resources/LabelsBundle_porrisavvo_FI.properties +++ b/src/main/resources/LabelsBundle_porrisavvo_FI.properties @@ -2,7 +2,7 @@ Log = Loki History = Historriijja created = luatu modified = muakat -Queue = Jono +queue = Jono Configuration = Assetuksse # Keys for the Configuration menu diff --git a/src/main/resources/LabelsBundle_pt_BR.properties b/src/main/resources/LabelsBundle_pt_BR.properties index 3122c5e07..882092353 100644 --- a/src/main/resources/LabelsBundle_pt_BR.properties +++ b/src/main/resources/LabelsBundle_pt_BR.properties @@ -2,7 +2,7 @@ Log = Registro History = Histórico created = criado modified = modificado -Queue = Fila +queue = Fila Configuration = Configuração # Keys for the Configuration menu diff --git a/src/main/resources/LabelsBundle_pt_PT.properties b/src/main/resources/LabelsBundle_pt_PT.properties index 7f2cc55be..0925dfb54 100644 --- a/src/main/resources/LabelsBundle_pt_PT.properties +++ b/src/main/resources/LabelsBundle_pt_PT.properties @@ -2,7 +2,7 @@ Log = Registo History = Histórico created = criado modified = modificado -Queue = Fila +queue = Fila Configuration = Configuração # Keys for the Configuration menu diff --git a/src/main/resources/LabelsBundle_ru_RU.properties b/src/main/resources/LabelsBundle_ru_RU.properties index 0a69f8daf..9a97dfa6e 100644 --- a/src/main/resources/LabelsBundle_ru_RU.properties +++ b/src/main/resources/LabelsBundle_ru_RU.properties @@ -2,7 +2,7 @@ History = История created = создано modified = изменено -Queue = Очередь +queue = Очередь Configuration = Настройки # Keys for the Configuration menu From a3bbf8198b3f543ecd79c40ff00be2b988d295ee Mon Sep 17 00:00:00 2001 From: Isaaku Date: Wed, 14 Aug 2019 17:16:21 -0500 Subject: [PATCH 06/21] Added missing history properties to LabelsBundle --- .../ripme/ui/HistoryMenuMouseListener.java | 10 +++--- .../com/rarchives/ripme/ui/MainWindow.java | 32 ++++++++----------- src/main/resources/LabelsBundle.properties | 25 +++++++++++---- workspace.code-workspace | 16 ++++++++++ 4 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 workspace.code-workspace diff --git a/src/main/java/com/rarchives/ripme/ui/HistoryMenuMouseListener.java b/src/main/java/com/rarchives/ripme/ui/HistoryMenuMouseListener.java index 610376265..9044531f7 100644 --- a/src/main/java/com/rarchives/ripme/ui/HistoryMenuMouseListener.java +++ b/src/main/java/com/rarchives/ripme/ui/HistoryMenuMouseListener.java @@ -10,13 +10,15 @@ import javax.swing.JPopupMenu; import javax.swing.JTable; +import com.rarchives.ripme.utils.Utils; + class HistoryMenuMouseListener extends MouseAdapter { private JPopupMenu popup = new JPopupMenu(); private JTable tableComponent; @SuppressWarnings("serial") public HistoryMenuMouseListener() { - Action checkAllAction = new AbstractAction("Check All") { + Action checkAllAction = new AbstractAction(Utils.getLocalizedString("history.check.all")) { @Override public void actionPerformed(ActionEvent ae) { for (int row = 0; row < tableComponent.getRowCount(); row++) { @@ -26,7 +28,7 @@ public void actionPerformed(ActionEvent ae) { }; popup.add(checkAllAction); - Action uncheckAllAction = new AbstractAction("Check None") { + Action uncheckAllAction = new AbstractAction(Utils.getLocalizedString("history.check.none")) { @Override public void actionPerformed(ActionEvent ae) { for (int row = 0; row < tableComponent.getRowCount(); row++) { @@ -38,7 +40,7 @@ public void actionPerformed(ActionEvent ae) { popup.addSeparator(); - Action checkSelected = new AbstractAction("Check Selected") { + Action checkSelected = new AbstractAction(Utils.getLocalizedString("history.check.selected")) { @Override public void actionPerformed(ActionEvent ae) { for (int row : tableComponent.getSelectedRows()) { @@ -48,7 +50,7 @@ public void actionPerformed(ActionEvent ae) { }; popup.add(checkSelected); - Action uncheckSelected = new AbstractAction("Uncheck Selected") { + Action uncheckSelected = new AbstractAction(Utils.getLocalizedString("history.uncheck.selected")) { @Override public void actionPerformed(ActionEvent ae) { for (int row : tableComponent.getSelectedRows()) { diff --git a/src/main/java/com/rarchives/ripme/ui/MainWindow.java b/src/main/java/com/rarchives/ripme/ui/MainWindow.java index 2d69542c1..bbc656be0 100644 --- a/src/main/java/com/rarchives/ripme/ui/MainWindow.java +++ b/src/main/java/com/rarchives/ripme/ui/MainWindow.java @@ -849,8 +849,8 @@ private void update() { // Re-rip all history historyButtonRerip.addActionListener(event -> { if (HISTORY.isEmpty()) { - JOptionPane.showMessageDialog(null, "There are no history entries to re-rip. Rip some albums first", - "RipMe Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(null, Utils.getLocalizedString("history.load.none"), "RipMe Error", + JOptionPane.ERROR_MESSAGE); return; } int added = 0; @@ -861,8 +861,7 @@ private void update() { } } if (added == 0) { - JOptionPane.showMessageDialog(null, "No history entries have been 'Checked'\n" - + "Check an entry by clicking the checkbox to the right of the URL or Right-click a URL to check/uncheck all items", + JOptionPane.showMessageDialog(null, Utils.getLocalizedString("history.load.none.checked"), "RipMe Error", JOptionPane.ERROR_MESSAGE); } }); @@ -1009,26 +1008,26 @@ private void setupTrayIcon() { mainFrame.addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent e) { - trayMenuMain.setLabel("Hide"); + trayMenuMain.setLabel(Utils.getLocalizedString("tray.hide")); } @Override public void windowDeactivated(WindowEvent e) { - trayMenuMain.setLabel("Show"); + trayMenuMain.setLabel(Utils.getLocalizedString("tray.show")); } @Override public void windowDeiconified(WindowEvent e) { - trayMenuMain.setLabel("Hide"); + trayMenuMain.setLabel(Utils.getLocalizedString("tray.hide")); } @Override public void windowIconified(WindowEvent e) { - trayMenuMain.setLabel("Show"); + trayMenuMain.setLabel(Utils.getLocalizedString("tray.show")); } }); PopupMenu trayMenu = new PopupMenu(); - trayMenuMain = new MenuItem("Hide"); + trayMenuMain = new MenuItem(Utils.getLocalizedString("tray.hide")); trayMenuMain.addActionListener(arg0 -> toggleTrayClick()); MenuItem trayMenuAbout = new MenuItem("About " + mainFrame.getTitle()); trayMenuAbout.addActionListener(arg0 -> { @@ -1079,9 +1078,9 @@ public void windowIconified(WindowEvent e) { } } }); - MenuItem trayMenuExit = new MenuItem("Exit"); + MenuItem trayMenuExit = new MenuItem(Utils.getLocalizedString("tray.exit")); trayMenuExit.addActionListener(arg0 -> System.exit(0)); - trayMenuAutorip = new CheckboxMenuItem("Clipboard Autorip"); + trayMenuAutorip = new CheckboxMenuItem(Utils.getLocalizedString("tray.autorip")); trayMenuAutorip.addItemListener(arg0 -> { ClipboardUtils.setClipboardAutoRip(trayMenuAutorip.getState()); configClipboardAutorip.setSelected(trayMenuAutorip.getState()); @@ -1122,10 +1121,10 @@ private void toggleTrayClick() { mainFrame.setVisible(true); mainFrame.setAlwaysOnTop(true); mainFrame.setAlwaysOnTop(false); - trayMenuMain.setLabel("Hide"); + trayMenuMain.setLabel(Utils.getLocalizedString("tray.hide")); } else { mainFrame.setVisible(false); - trayMenuMain.setLabel("Show"); + trayMenuMain.setLabel(Utils.getLocalizedString("tray.show")); } } @@ -1170,10 +1169,7 @@ private void loadHistory() { } catch (IOException e) { LOGGER.error("Failed to load history from file " + historyFile, e); JOptionPane.showMessageDialog(null, - "RipMe failed to load the history file at " + historyFile.getAbsolutePath() + "\n\n" + "Error: " - + e.getMessage() + "\n\n" - + "Closing RipMe will automatically overwrite the contents of this file,\n" - + "so you may want to back the file up before closing RipMe!", + String.format(Utils.getLocalizedString("history.load.failed.warning"), e.getMessage()), "RipMe - history load failure", JOptionPane.ERROR_MESSAGE); } } else { @@ -1446,7 +1442,7 @@ private synchronized void handleEvent(StatusEvent evt) { openButton.setVisible(true); File f = rsc.dir; String prettyFile = Utils.shortenPath(f); - openButton.setText("Open " + prettyFile); + openButton.setText(Utils.getLocalizedString("open") + prettyFile); mainFrame.setTitle("RipMe v" + UpdateUtils.getThisJarVersion()); try { Image folderIcon = ImageIO.read(getClass().getClassLoader().getResource("folder.png")); diff --git a/src/main/resources/LabelsBundle.properties b/src/main/resources/LabelsBundle.properties index 215e0f55d..575f4f8e6 100644 --- a/src/main/resources/LabelsBundle.properties +++ b/src/main/resources/LabelsBundle.properties @@ -4,9 +4,9 @@ created = created modified = modified queue = Queue Configuration = Configuration +open = Open # Keys for the Configuration menu - current.version = Current version check.for.updates = Check for updates auto.update = Auto-update? @@ -32,19 +32,32 @@ queue.remove.all = Remove All queue.validation = Are you sure you want to remove all elements from the queue? queue.remove.selected = Remove Selected -# Misc UI keys +# History +re-rip.checked = Re-rip Checked +remove = Remove +clear = Clear +history.check.all = Check All +history.check.none = Check None +history.check.selected = Check Selected +history.uncheck.selected = Uncheck Selected +history.load.failed.warning = RipMe failed to load the history file at historyFile.getAbsolutePath() \n\nError: %s\n\nClosing RipMe will automatically overwrite the contents of this file,\nso you may want to back the file up before closing RipMe! +history.load.none = There are no history entries to re-rip. Rip some albums first +history.load.none.checked = No history entries have been 'Checked' Check an entry by clicking the checkbox to the right of the URL or Right-click a URL to check/uncheck all items + +# TrayIcon +tray.show = Show +tray.hide = Hide +tray.autorip = Clipboard Autorip +tray.exit = Exit +# Misc UI keys loading.history.from.configuration = Loading history from configuration interrupted.while.waiting.to.rip.next.album = Interrupted while waiting to rip next album inactive = Inactive -re-rip.checked = Re-rip Checked -remove = Remove -clear = Clear download.url.list = Download url list select.save.dir = Select Save Directory # Keys for the logs generated by DownloadFileThread - nonretriable.status.code = Non-retriable status code retriable.status.code = Retriable status code server.doesnt.support.resuming.downloads = Server doesn't support resuming downloads diff --git a/workspace.code-workspace b/workspace.code-workspace new file mode 100644 index 000000000..95b80106b --- /dev/null +++ b/workspace.code-workspace @@ -0,0 +1,16 @@ +{ + "folders": [ + { + "path": "E:\\Downloads\\_Isaaku\\dev" + } + ], + "settings": { + "files.exclude": { + "**/.classpath": false, + "**/.project": true, + "**/.settings": true, + "**/.factorypath": true + }, + "java.configuration.updateBuildConfiguration": "automatic" + } +} \ No newline at end of file From 03e8c2d797a6b6764d0bd9575d8836aef29c8ea2 Mon Sep 17 00:00:00 2001 From: Isaaku Date: Thu, 15 Aug 2019 12:52:28 -0500 Subject: [PATCH 07/21] Get supported languages dynamically --- .../com/rarchives/ripme/ui/MainWindow.java | 12 +-- .../java/com/rarchives/ripme/utils/Utils.java | 34 ++++++- .../ripme/tst/ui/LabelsBundlesTest.java | 95 +++++++++++++++++++ 3 files changed, 130 insertions(+), 11 deletions(-) create mode 100644 src/test/java/com/rarchives/ripme/tst/ui/LabelsBundlesTest.java diff --git a/src/main/java/com/rarchives/ripme/ui/MainWindow.java b/src/main/java/com/rarchives/ripme/ui/MainWindow.java index bbc656be0..7151f6b1b 100644 --- a/src/main/java/com/rarchives/ripme/ui/MainWindow.java +++ b/src/main/java/com/rarchives/ripme/ui/MainWindow.java @@ -139,10 +139,6 @@ public final class MainWindow implements Runnable, RipStatusHandler { private static AbstractRipper ripper; - // All the langs ripme has been translated into - private static String[] supportedLanges = new String[] { "de_DE", "ar_AR", "en_US", "es_ES", "fi_FI", "fr_CH", - "in_ID", "it_IT", "kr_KR", "nl_NL", "pl_PL", "porrisavvo_FI", "pt_BR", "pt_PT", "ru_RU" }; - private void updateQueue(DefaultListModel model) { if (model == null) model = queueListModel; @@ -483,7 +479,7 @@ public void setValueAt(Object value, int row, int col) { queueListModel = new DefaultListModel(); JList queueList = new JList(queueListModel); queueList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - queueList.addMouseListener(queueMenuMouseListener = new QueueMenuMouseListener((model) -> updateQueue(model))); + queueList.addMouseListener(queueMenuMouseListener = new QueueMenuMouseListener()); JScrollPane queueListScroll = new JScrollPane(queueList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); for (String item : Utils.getConfigList("queue")) { @@ -539,8 +535,8 @@ public void setValueAt(Object value, int row, int col) { configLogLevelCombobox = new JComboBox<>( new String[] { "Log level: Error", "Log level: Warn", "Log level: Info", "Log level: Debug" }); - configSelectLangComboBox = new JComboBox<>(supportedLanges); - configSelectLangComboBox.setSelectedItem(Utils.getLanguage()); + configSelectLangComboBox = new JComboBox<>(Utils.getSupportedLanguages()); + configSelectLangComboBox.setSelectedItem(Utils.getSelectedLanguage()); configLogLevelCombobox.setSelectedItem(Utils.getConfigString("log.level", "Log level: Debug")); setLogLevel(configLogLevelCombobox.getSelectedItem().toString()); configSaveDirLabel = new JLabel(); @@ -675,8 +671,6 @@ private void changeLocale() { optionHistory.setText(Utils.getLocalizedString("History")); optionQueue.setText(Utils.getLocalizedString("queue")); optionConfiguration.setText(Utils.getLocalizedString("Configuration")); - - queueMenuMouseListener.updateUI(); } private void setupHandlers() { diff --git a/src/main/java/com/rarchives/ripme/utils/Utils.java b/src/main/java/com/rarchives/ripme/utils/Utils.java index 4333a9f55..e038fea0c 100644 --- a/src/main/java/com/rarchives/ripme/utils/Utils.java +++ b/src/main/java/com/rarchives/ripme/utils/Utils.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.FileNotFoundException; +import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; @@ -21,6 +22,8 @@ import java.util.ResourceBundle; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; @@ -40,6 +43,7 @@ */ public class Utils { + private static final Pattern pattern = Pattern.compile("LabelsBundle_(?[A-Za-z_]+).properties"); private static final String RIP_DIRECTORY = "rips"; private static final String CONFIG_FILE = "rip.properties"; private static final String OS = System.getProperty("os.name").toLowerCase(); @@ -745,12 +749,38 @@ public static void setLanguage(String langSelect) { resourceBundle = getResourceBundle(langSelect); } - public static String getLanguage() { + public static String getSelectedLanguage() { return resourceBundle.getLocale().toString(); } + // All the langs ripme has been translated into + public static String[] getSupportedLanguages() { + File configFile = new File(Utils.class.getResource("/rip.properties").getFile()); + LOGGER.info("ConfigFile: " + configFile); + LOGGER.info("Parent: " + new File(configFile.getParent())); + File[] files = new File(configFile.getParent()).listFiles(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + LOGGER.info("name: " + name); + return name.startsWith("LabelsBundle_"); + } + + }); + + String[] langs = new String[files.length]; + for (int i = 0; i < files.length; i++) { + Matcher matcher = pattern.matcher(files[i].getName()); + if (matcher.find()) + langs[i] = matcher.group("lang"); + } + + return langs; + } + public static String getLocalizedString(String key) { - LOGGER.debug(String.format("Getting key %s in %s value %s",key, getLanguage(), resourceBundle.getString(key))); + LOGGER.debug(String.format("Getting key %s in %s value %s", key, getSelectedLanguage(), + resourceBundle.getString(key))); return resourceBundle.getString(key); } diff --git a/src/test/java/com/rarchives/ripme/tst/ui/LabelsBundlesTest.java b/src/test/java/com/rarchives/ripme/tst/ui/LabelsBundlesTest.java new file mode 100644 index 000000000..58fd5d340 --- /dev/null +++ b/src/test/java/com/rarchives/ripme/tst/ui/LabelsBundlesTest.java @@ -0,0 +1,95 @@ +package com.rarchives.ripme.tst.ui; + +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import com.rarchives.ripme.utils.Utils; + +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.junit.jupiter.api.Test; + +public class LabelsBundlesTest { + + private Logger logger = Logger.getLogger(Utils.class); + + @Test + void testKeyCount() { + ((ConsoleAppender) Logger.getRootLogger().getAppender("stdout")).setThreshold(Level.DEBUG); + File f = new File("E:\\Downloads\\_Isaaku\\dev\\ripme-1.7.86-jar-with-dependencies.jar"); + File[] files = f.listFiles(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + logger.info("name: " + name); + return name.startsWith("LabelsBundle_"); + } + + }); + + for (String s : getResourcesNames("\\**")) { + logger.info(s); + } + + } + + public String[] getResourcesNames(String path) { + Class loader = getClassLoader(); + /*URL u = loader.getResource("/rip.properties"); + path = u.getFile(); + path = new File(path).getParent();*/ + + try { + URL url = loader.getResource(path); + if (url == null) { + return null; + } + + URI uri = url.toURI(); + if (uri.getScheme().equals("jar")) { // Run from jar + try (FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.emptyMap())) { + Path resourcePath = fileSystem.getPath(path); + + // Get all contents of a resource (skip resource itself), if entry is a + // directory remove trailing / + List resourcesNames = Files.walk(resourcePath, 1).skip(1).map(p -> { + String name = p.getFileName().toString(); + if (name.endsWith("/")) { + name = name.substring(0, name.length() - 1); + } + return name; + }).sorted().collect(Collectors.toList()); + + return resourcesNames.toArray(new String[resourcesNames.size()]); + } + } else { // Run from IDE + File resource = new File(uri); + return resource.list(); + } + } catch (IOException e) { + return null; + } catch (URISyntaxException e) { + // TODO Auto-generated catch block + return null; + } + } + + private Class getClassLoader() { + return Utils.class; + //return Thread.currentThread().getContextClassLoader(); + } +} \ No newline at end of file From 1402f3b8dde95da49810f1794ed39b3bf1b77d8f Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 17 Aug 2019 20:04:14 -0400 Subject: [PATCH 08/21] xhamster no longer changes url domain when sanitizing --- .../ripme/ripper/rippers/XhamsterRipper.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 2dbcec2a4..46ec7c189 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/XhamsterRipper.java @@ -44,13 +44,12 @@ public String getDomain() { @Override public URL sanitizeURL(URL url) throws MalformedURLException { - String URLToReturn = url.toExternalForm(); - URLToReturn = URLToReturn.replaceAll("xhamster\\.(com|one|desi)", "xhamster.com"); - URLToReturn = URLToReturn.replaceAll("m.xhamster\\.(com|one|desi)", "xhamster.com"); - URLToReturn = URLToReturn.replaceAll("\\w\\w\\.xhamster\\.(com|one|desi)", "xhamster.com"); - if (!isVideoUrl(url)) { - URLToReturn = URLToReturn.replaceAll("xhamster2?.com", "m.xhamster.com"); + if (isVideoUrl(url)) { + return url; } + String URLToReturn = url.toExternalForm(); + URLToReturn = URLToReturn.replaceAll("https?://\\w?\\w?\\.?xhamster\\.", "https://m.xhamster."); + URLToReturn = URLToReturn.replaceAll("https?://xhamster2\\.", "https://m.xhamster2."); URL san_url = new URL(URLToReturn); LOGGER.info("sanitized URL is " + san_url.toExternalForm()); return san_url; From f9540bd98251c403f0602735117e4cb7cceaa63b Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 17 Aug 2019 20:07:15 -0400 Subject: [PATCH 09/21] Disabled broken test --- .../ripme/tst/ripper/rippers/ViewcomicRipperTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ViewcomicRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ViewcomicRipperTest.java index cc9d2409e..063cc036f 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ViewcomicRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/ViewcomicRipperTest.java @@ -4,10 +4,11 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.ViewcomicRipper; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; public class ViewcomicRipperTest extends RippersTest { - @Test + @Test @Disabled("Ripper broken") public void testViewcomicRipper() throws IOException { ViewcomicRipper ripper = new ViewcomicRipper(new URL("https://view-comic.com/batman-no-mans-land-vol-1/")); testRipper(ripper); From 082772be2ea1529447ff64db95a5e4f93f42ca5d Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 17 Aug 2019 20:10:39 -0400 Subject: [PATCH 10/21] Updated java version used for testing as it will soon go EOL --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e8a2c98a2..8c85a9abc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: java jdk: - - oraclejdk8 + - oraclejdk9 - openjdk8 after_success: - mvn clean test jacoco:report coveralls:report From a94ab586f895a7b9007a0a77f4cfa1a14674b1bb Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sun, 18 Aug 2019 12:54:31 -0400 Subject: [PATCH 11/21] Fixed cert errors with travis and oracleJDK --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8c85a9abc..0c2eeca63 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,13 @@ language: java jdk: - oraclejdk9 - openjdk8 + +matrix: + include: + - jdk: openjdk9 + before_install: + - rm "${JAVA_HOME}/lib/security/cacerts" + - ln -s /etc/ssl/certs/java/cacerts "${JAVA_HOME}/lib/security/cacerts" + after_success: - mvn clean test jacoco:report coveralls:report From 29a63741c2b3548831bc1b6195e88fa4c7ee55ce Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sun, 18 Aug 2019 12:56:08 -0400 Subject: [PATCH 12/21] Disabled flaky tests --- .../ripme/tst/ripper/rippers/LusciousRipperTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/LusciousRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/LusciousRipperTest.java index 6536acebb..6362dcc6e 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/LusciousRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/LusciousRipperTest.java @@ -4,10 +4,11 @@ import java.net.URL; import com.rarchives.ripme.ripper.rippers.LusciousRipper; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; public class LusciousRipperTest extends RippersTest { - @Test + @Test @Disabled("Flaky in the CI") public void testPahealRipper() throws IOException { // a photo set LusciousRipper ripper = new LusciousRipper( @@ -20,7 +21,7 @@ public void testGetGID() throws IOException { LusciousRipper ripper = new LusciousRipper(url); assertEquals("h-na-alice-wa-suki-desu-ka-do-you-like-alice-when_321609", ripper.getGID(url)); } - @Test + @Test @Disabled("Flaky in the CI") public void testGetNextPage() throws IOException { URL multiPageAlbumUrl = new URL("https://luscious.net/albums/women-of-color_58/"); LusciousRipper multiPageRipper = new LusciousRipper(multiPageAlbumUrl); From 22b4ccbd6306ec580a40ddc82a8123cd2b093cff Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sun, 18 Aug 2019 12:58:08 -0400 Subject: [PATCH 13/21] Formatting --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0c2eeca63..ccf3d504f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,6 @@ matrix: before_install: - rm "${JAVA_HOME}/lib/security/cacerts" - ln -s /etc/ssl/certs/java/cacerts "${JAVA_HOME}/lib/security/cacerts" - + after_success: - mvn clean test jacoco:report coveralls:report From d4a17784514a76d3cfec9456534bc7fbac4dadf3 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sun, 18 Aug 2019 13:29:32 -0400 Subject: [PATCH 14/21] Removed broken jdk test --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ccf3d504f..2fb28575c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: java jdk: - - oraclejdk9 - openjdk8 matrix: From 53866a527c5f800f613bcacde7284a539fb430eb Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sun, 18 Aug 2019 13:33:55 -0400 Subject: [PATCH 15/21] unbroke ci --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2fb28575c..ccf3d504f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: java jdk: + - oraclejdk9 - openjdk8 matrix: From 7865d97c1593670be1831ee7610828e81e4081ea Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Mon, 19 Aug 2019 16:19:09 -0400 Subject: [PATCH 16/21] Fixed travis config --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ccf3d504f..0fd1b17f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,4 @@ language: java -jdk: - - oraclejdk9 - - openjdk8 matrix: include: @@ -9,6 +6,7 @@ matrix: before_install: - rm "${JAVA_HOME}/lib/security/cacerts" - ln -s /etc/ssl/certs/java/cacerts "${JAVA_HOME}/lib/security/cacerts" + - jdk: openjdk8 after_success: - mvn clean test jacoco:report coveralls:report From 1c555c01f1ca2026ae94c06a0487d3be6228d768 Mon Sep 17 00:00:00 2001 From: rtsketo Date: Thu, 22 Aug 2019 06:00:47 +0300 Subject: [PATCH 17/21] Fixes for gfycat thumbs urls. --- .../ripme/ripper/rippers/GfycatRipper.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java index 52a19b749..7c49fbba6 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/GfycatRipper.java @@ -29,7 +29,7 @@ public class GfycatRipper extends AbstractHTMLRipper { public GfycatRipper(URL url) throws IOException { - super(url); + super(new URL(url.toExternalForm().split("-")[0].replace("thumbs.", ""))); } @Override @@ -76,15 +76,16 @@ public void downloadURL(URL url, int index) { @Override 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()); - if (m.matches()) { - return m.group(1); - } - + + if (m.matches()) + return m.group(2); + throw new MalformedURLException( - "Expected gfycat.com format:" - + "gfycat.com/id" + "Expected gfycat.com format: " + + "gfycat.com/id or " + + "thumbs.gfycat.com/id.gif" + " Got: " + url); } @@ -92,7 +93,7 @@ private String stripHTMLTags(String t) { t = t.replaceAll("\n" + " \n" + " ", ""); - t.replaceAll("\n" + + t = t.replaceAll("\n" + "", ""); t = t.replaceAll("\n", ""); t = t.replaceAll("=\"\"", ""); From 28dc3f796f2973a1237834b1bbabeedf84fbf210 Mon Sep 17 00:00:00 2001 From: rtsketo Date: Thu, 22 Aug 2019 14:35:24 +0300 Subject: [PATCH 18/21] Fixed update batch file to work in directories with spaces. --- .../java/com/rarchives/ripme/ui/UpdateUtils.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index 07e7f496b..f947cd6d8 100644 --- a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java +++ b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java @@ -23,7 +23,7 @@ public class UpdateUtils { private static final Logger logger = Logger.getLogger(UpdateUtils.class); - private static final String DEFAULT_VERSION = "1.7.86"; + private static final String DEFAULT_VERSION = "1.7.87"; private static final String REPO_NAME = "ripmeapp/ripme"; private static final String updateJsonURL = "https://raw.githubusercontent.com/" + REPO_NAME + "/master/ripme.json"; private static String mainFileName; @@ -264,12 +264,14 @@ private static void downloadJarAndLaunch(String updateJarURL, Boolean shouldLaun // Windows final String batchFile = "update_ripme.bat"; final String batchPath = new File(batchFile).getAbsolutePath(); - String script = "@echo off\r\n" + "timeout 1\r\n" + "copy " + updateFileName + " " + mainFileName + "\r\n" - + "del " + updateFileName + "\r\n"; - if (shouldLaunch) { - script += mainFileName + "\r\n"; - } - script += "del " + batchPath + "\r\n"; + String script = "@echo off\r\n" + "timeout 1\r\n" + + "copy \"" + updateFileName + "\" \"" + mainFileName + "\"\r\n" + + "del \"" + updateFileName + "\"\r\n"; + + if (shouldLaunch) + script += "\"" + mainFileName + "\"\r\n"; + script += "del \"" + batchPath + "\"\r\n"; + final String[] batchExec = new String[] { batchPath }; // Create updater script try (BufferedWriter bw = new BufferedWriter(new FileWriter(batchFile))) { From 132382b402cda35c6e1376e3d5ae6db80095efa7 Mon Sep 17 00:00:00 2001 From: rtsketo Date: Thu, 22 Aug 2019 14:36:51 +0300 Subject: [PATCH 19/21] Fixed update batch file to work in directories with spaces. --- src/main/java/com/rarchives/ripme/ui/UpdateUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index f947cd6d8..094da0682 100644 --- a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java +++ b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java @@ -23,7 +23,7 @@ public class UpdateUtils { private static final Logger logger = Logger.getLogger(UpdateUtils.class); - private static final String DEFAULT_VERSION = "1.7.87"; + private static final String DEFAULT_VERSION = "1.7.86"; private static final String REPO_NAME = "ripmeapp/ripme"; private static final String updateJsonURL = "https://raw.githubusercontent.com/" + REPO_NAME + "/master/ripme.json"; private static String mainFileName; From dcc1d2f06c7ecbd5e3575d563d5c418b42451b83 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Thu, 22 Aug 2019 23:58:39 -0400 Subject: [PATCH 20/21] 1.7.87: Added ripper for allporncomic.com; Fixed Xhamster ripper; Added support xhamster2.com and xhamster.desi; Fixes for gfycat thumbs urls --- pom.xml | 2 +- ripme.json | 7 ++++--- src/main/java/com/rarchives/ripme/ui/UpdateUtils.java | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 77300393e..b87f47ed4 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.rarchives.ripme ripme jar - 1.7.86 + 1.7.87 ripme http://rip.rarchives.com diff --git a/ripme.json b/ripme.json index 2c91fc8b1..1d8b20971 100644 --- a/ripme.json +++ b/ripme.json @@ -1,7 +1,7 @@ { - "latestVersion": "1.7.86", - "currentHash": "d78f7dfaa8ef55575a8485cdf93bbd09e3ea9a3bd224e84e970bcdd0a51d5305", + "currentHash": "52dfb707d6247f44949c0d97b19c7815dc848b26837b98ae561c0dea20993a12", "changeList": [ + "1.7.87: Added ripper for allporncomic.com; Fixed Xhamster ripper; Added support xhamster2.com and xhamster.desi; Fixes for gfycat thumbs urls", "1.7.86: Added Meituri Ripper; fixed -u flag; Fixed pornhub ripper; Xhamster ripper can now queue users videos", "1.7.85: Fixed instagram ripper; Flickr ripper now downloads largest image", "1.7.84: Fixed instagram ripper; xhamster ripper now accepts urls with page numbers; Fixed Deviantart Ripper", @@ -258,5 +258,6 @@ "1.0.4: Fixed spaces-in-directory bug", "1.0.3: Added VK.com ripper", "1.0.1: Added auto-update functionality" - ] + ], + "latestVersion": "1.7.87" } \ No newline at end of file diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index 094da0682..f947cd6d8 100644 --- a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java +++ b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java @@ -23,7 +23,7 @@ public class UpdateUtils { private static final Logger logger = Logger.getLogger(UpdateUtils.class); - private static final String DEFAULT_VERSION = "1.7.86"; + private static final String DEFAULT_VERSION = "1.7.87"; private static final String REPO_NAME = "ripmeapp/ripme"; private static final String updateJsonURL = "https://raw.githubusercontent.com/" + REPO_NAME + "/master/ripme.json"; private static String mainFileName; From 5545677cfefae6481470c51eeb9c867b74a845ac Mon Sep 17 00:00:00 2001 From: Isaaku Date: Fri, 23 Aug 2019 16:28:02 -0500 Subject: [PATCH 21/21] Fix get supported languages dynamically Remove UTF8-BOM from de_DE, pl_PL and ru_RU bundles Added test to find is there is a Key in a language bundle but not in the default bundle Added test to list keys missing from a language bundle --- .../java/com/rarchives/ripme/utils/Utils.java | 51 +++++--- .../resources/LabelsBundle_de_DE.properties | 2 +- .../resources/LabelsBundle_pl_PL.properties | 2 +- .../resources/LabelsBundle_ru_RU.properties | 2 +- .../ripme/tst/ui/LabelsBundlesTest.java | 112 ++++++------------ 5 files changed, 76 insertions(+), 93 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/utils/Utils.java b/src/main/java/com/rarchives/ripme/utils/Utils.java index e038fea0c..98ed88950 100644 --- a/src/main/java/com/rarchives/ripme/utils/Utils.java +++ b/src/main/java/com/rarchives/ripme/utils/Utils.java @@ -7,14 +7,22 @@ import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.lang.reflect.Constructor; +import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.net.URLDecoder; import java.nio.ByteBuffer; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -24,6 +32,7 @@ import java.util.jar.JarFile; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Stream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; @@ -44,6 +53,7 @@ public class Utils { private static final Pattern pattern = Pattern.compile("LabelsBundle_(?[A-Za-z_]+).properties"); + private static final String DEFAULT_LANG = "en_US"; private static final String RIP_DIRECTORY = "rips"; private static final String CONFIG_FILE = "rip.properties"; private static final String OS = System.getProperty("os.name").toLowerCase(); @@ -755,27 +765,34 @@ public static String getSelectedLanguage() { // All the langs ripme has been translated into public static String[] getSupportedLanguages() { - File configFile = new File(Utils.class.getResource("/rip.properties").getFile()); - LOGGER.info("ConfigFile: " + configFile); - LOGGER.info("Parent: " + new File(configFile.getParent())); - File[] files = new File(configFile.getParent()).listFiles(new FilenameFilter() { - - @Override - public boolean accept(File dir, String name) { - LOGGER.info("name: " + name); - return name.startsWith("LabelsBundle_"); + ArrayList filesList = new ArrayList<>(); + try { + URI uri = Utils.class.getResource("/rip.properties").toURI(); + + Path myPath; + if (uri.getScheme().equals("jar")) { + FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.emptyMap()); + myPath = fileSystem.getPath("/"); + } else { + myPath = Paths.get(uri).getParent(); } - }); + Files.walk(myPath, 1).filter(p -> p.toString().contains("LabelsBundle_")).distinct() + .forEach(filesList::add); - String[] langs = new String[files.length]; - for (int i = 0; i < files.length; i++) { - Matcher matcher = pattern.matcher(files[i].getName()); - if (matcher.find()) - langs[i] = matcher.group("lang"); - } + String[] langs = new String[filesList.size()]; + for (int i = 0; i < filesList.size(); i++) { + Matcher matcher = pattern.matcher(filesList.get(i).toString()); + if (matcher.find()) + langs[i] = matcher.group("lang"); + } - return langs; + return langs; + } catch (Exception e) { + e.printStackTrace(); + // On error return default language + return new String[] { DEFAULT_LANG }; + } } public static String getLocalizedString(String key) { diff --git a/src/main/resources/LabelsBundle_de_DE.properties b/src/main/resources/LabelsBundle_de_DE.properties index a7ec74f1e..61461abaf 100644 --- a/src/main/resources/LabelsBundle_de_DE.properties +++ b/src/main/resources/LabelsBundle_de_DE.properties @@ -1,4 +1,4 @@ -Log = Log +Log = Log History = Verlauf created = erstellt modified = geändert diff --git a/src/main/resources/LabelsBundle_pl_PL.properties b/src/main/resources/LabelsBundle_pl_PL.properties index 2a6ba3265..4ba4590ea 100644 --- a/src/main/resources/LabelsBundle_pl_PL.properties +++ b/src/main/resources/LabelsBundle_pl_PL.properties @@ -1,4 +1,4 @@ -Log = Logi +Log = Logi History = Historia created = Stworzono modified = Zmodyfikowano diff --git a/src/main/resources/LabelsBundle_ru_RU.properties b/src/main/resources/LabelsBundle_ru_RU.properties index 9a97dfa6e..a3100df85 100644 --- a/src/main/resources/LabelsBundle_ru_RU.properties +++ b/src/main/resources/LabelsBundle_ru_RU.properties @@ -1,4 +1,4 @@ -Log = Лог +Log = Лог History = История created = создано modified = изменено diff --git a/src/test/java/com/rarchives/ripme/tst/ui/LabelsBundlesTest.java b/src/test/java/com/rarchives/ripme/tst/ui/LabelsBundlesTest.java index 58fd5d340..6189d86aa 100644 --- a/src/test/java/com/rarchives/ripme/tst/ui/LabelsBundlesTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ui/LabelsBundlesTest.java @@ -1,95 +1,61 @@ package com.rarchives.ripme.tst.ui; -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collections; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.ResourceBundle; +import java.util.Set; import com.rarchives.ripme.utils.Utils; -import org.apache.log4j.ConsoleAppender; -import org.apache.log4j.Level; import org.apache.log4j.Logger; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class LabelsBundlesTest { - private Logger logger = Logger.getLogger(Utils.class); + private static final String DEFAULT_LANG = "en_US"; @Test void testKeyCount() { - ((ConsoleAppender) Logger.getRootLogger().getAppender("stdout")).setThreshold(Level.DEBUG); - File f = new File("E:\\Downloads\\_Isaaku\\dev\\ripme-1.7.86-jar-with-dependencies.jar"); - File[] files = f.listFiles(new FilenameFilter() { - - @Override - public boolean accept(File dir, String name) { - logger.info("name: " + name); - return name.startsWith("LabelsBundle_"); + ResourceBundle defaultBundle = Utils.getResourceBundle(null); + HashMap> dictionary = new HashMap<>(); + for (String lang : Utils.getSupportedLanguages()) { + ResourceBundle.clearCache(); + if (lang.equals(DEFAULT_LANG)) + continue; + ResourceBundle selectedLang = Utils.getResourceBundle(lang); + for (final Enumeration keys = defaultBundle.getKeys(); keys.hasMoreElements();) { + String element = keys.nextElement(); + if (selectedLang.containsKey(element) + && !selectedLang.getString(element).equals(defaultBundle.getString(element))) { + if (dictionary.get(lang) == null) + dictionary.put(lang, new ArrayList<>()); + dictionary.get(lang).add(element); + } } - - }); - - for (String s : getResourcesNames("\\**")) { - logger.info(s); } + dictionary.keySet().forEach(d -> { + logger.warn(String.format("Keys missing in %s", d)); + dictionary.get(d).forEach(v -> logger.warn(v)); + logger.warn("\n"); + }); } - public String[] getResourcesNames(String path) { - Class loader = getClassLoader(); - /*URL u = loader.getResource("/rip.properties"); - path = u.getFile(); - path = new File(path).getParent();*/ - - try { - URL url = loader.getResource(path); - if (url == null) { - return null; - } - - URI uri = url.toURI(); - if (uri.getScheme().equals("jar")) { // Run from jar - try (FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.emptyMap())) { - Path resourcePath = fileSystem.getPath(path); - - // Get all contents of a resource (skip resource itself), if entry is a - // directory remove trailing / - List resourcesNames = Files.walk(resourcePath, 1).skip(1).map(p -> { - String name = p.getFileName().toString(); - if (name.endsWith("/")) { - name = name.substring(0, name.length() - 1); - } - return name; - }).sorted().collect(Collectors.toList()); - - return resourcesNames.toArray(new String[resourcesNames.size()]); - } - } else { // Run from IDE - File resource = new File(uri); - return resource.list(); + @Test + void testKeyName() { + ResourceBundle defaultBundle = Utils.getResourceBundle(null); + Set defaultSet = defaultBundle.keySet(); + for (String lang : Utils.getSupportedLanguages()) { + if (lang.equals(DEFAULT_LANG)) + continue; + for (String key : Utils.getResourceBundle(lang).keySet()) { + assertTrue(defaultSet.contains(key), + String.format("The key %s of %s is not in the default bundle", key, lang)); } - } catch (IOException e) { - return null; - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - return null; } } - - private Class getClassLoader() { - return Utils.class; - //return Thread.currentThread().getContextClassLoader(); - } } \ No newline at end of file