From 48c7b5e7011b4a7e95c38ea4f9dd7ee98fb146ab Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 20 Mar 2018 09:32:38 +0700 Subject: [PATCH] Parse TheMovieDB vote_average field into Artwork object --- source/net/filebot/web/TMDbClient.java | 3 ++- test/net/filebot/web/TMDbClientTest.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/net/filebot/web/TMDbClient.java b/source/net/filebot/web/TMDbClient.java index d10e7319..82223ade 100644 --- a/source/net/filebot/web/TMDbClient.java +++ b/source/net/filebot/web/TMDbClient.java @@ -293,8 +293,9 @@ public class TMDbClient implements MovieIdentificationService, ArtworkProvider { String width = getString(it, "width"); String height = getString(it, "height"); Locale language = getStringValue(it, "iso_639_1", Locale::new); + Double rating = getStringValue(it, "vote_average", Double::parseDouble); - return new Artwork(Stream.of(category, String.join("x", width, height)), image, language, null); + return new Artwork(Stream.of(category, String.join("x", width, height)), image, language, rating); }).sorted(Artwork.RATING_ORDER).collect(toList()); } diff --git a/test/net/filebot/web/TMDbClientTest.java b/test/net/filebot/web/TMDbClientTest.java index 05121dc1..fa5ad44e 100644 --- a/test/net/filebot/web/TMDbClientTest.java +++ b/test/net/filebot/web/TMDbClientTest.java @@ -119,7 +119,8 @@ public class TMDbClientTest { public void getArtwork() throws Exception { Artwork a = db.getArtwork(16320, "backdrops", Locale.ROOT).get(0); assertEquals("[backdrops, 1920x1080]", a.getTags().toString()); - assertEquals("http://image.tmdb.org/t/p/original/mQPg3iZyztfzFNwrW40nCUtXy2l.jpg", a.getUrl().toString()); + assertEquals("https://image.tmdb.org/t/p/original/mQPg3iZyztfzFNwrW40nCUtXy2l.jpg", a.getUrl().toString()); + assertEquals(6.0, a.getRating(), 1.0); } @Test @@ -130,7 +131,7 @@ public class TMDbClientTest { assertEquals(null, p.getJob()); assertEquals(null, p.getDepartment()); assertEquals("0", p.getOrder().toString()); - assertEquals("http://image.tmdb.org/t/p/original/B7VTVtnKyFk0AtYjEbqzBQlPec.jpg", p.getImage().toString()); + assertEquals("https://image.tmdb.org/t/p/original/B7VTVtnKyFk0AtYjEbqzBQlPec.jpg", p.getImage().toString()); } @Test