From 5c1e91c3975b6b5ea87069d78c144d57d453f93c Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 7 Aug 2016 19:46:18 +0800 Subject: [PATCH] Convert illegal runtime values like "1h 30min" or "90min" to valid Integer values --- source/net/filebot/web/OMDbClient.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/net/filebot/web/OMDbClient.java b/source/net/filebot/web/OMDbClient.java index e2d36ae7..aa24f23b 100644 --- a/source/net/filebot/web/OMDbClient.java +++ b/source/net/filebot/web/OMDbClient.java @@ -165,7 +165,7 @@ public class OMDbClient implements MovieIdentificationService { Map fields = new EnumMap(MovieProperty.class); fields.put(MovieProperty.title, data.get("title")); fields.put(MovieProperty.certification, data.get("rated")); - fields.put(MovieProperty.runtime, data.get("runtime")); + fields.put(MovieProperty.runtime, getRuntimeMinutes(data.get("runtime"))); fields.put(MovieProperty.tagline, data.get("plot")); fields.put(MovieProperty.vote_average, data.get("imdbRating")); fields.put(MovieProperty.vote_count, data.get("imdbVotes").replaceAll("\\D", "")); @@ -194,6 +194,18 @@ public class OMDbClient implements MovieIdentificationService { return new MovieInfo(fields, emptyList(), genres, emptyMap(), languages, emptyList(), emptyList(), actors, emptyList()); } + private String getRuntimeMinutes(String runtime) { + List n = matchIntegers(runtime); + switch (n.size()) { + case 0: + return null; + case 1: + return Integer.toString(n.get(0));// e.g 162 min + default: + return Integer.toString(n.get(0) * 60 + n.get(1));// e.g 1h 30min + } + } + private SimpleDate parsePartialDate(String value, String format) { if (value != null && value.length() > 0) { try {