From 834b8b520540af7b6c178a39d89314e644172944 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 28 Oct 2014 17:22:48 +0000 Subject: [PATCH] * all users will now require authentication when using OpenSubtitles --- source/net/filebot/cli/CmdlineOperations.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/source/net/filebot/cli/CmdlineOperations.java b/source/net/filebot/cli/CmdlineOperations.java index 9c8b09f2..23540744 100644 --- a/source/net/filebot/cli/CmdlineOperations.java +++ b/source/net/filebot/cli/CmdlineOperations.java @@ -74,6 +74,7 @@ import net.filebot.web.MovieFormat; import net.filebot.web.MovieIdentificationService; import net.filebot.web.MoviePart; import net.filebot.web.MusicIdentificationService; +import net.filebot.web.OpenSubtitlesClient; import net.filebot.web.SearchResult; import net.filebot.web.SortOrder; import net.filebot.web.SubtitleDescriptor; @@ -720,7 +721,7 @@ public class CmdlineOperations implements CmdlineInterface { // lookup subtitles by hash for (VideoHashSubtitleService service : getVideoHashSubtitleServices()) { - if (remainingVideos.isEmpty() || (databaseFilter != null && !databaseFilter.matcher(service.getName()).matches())) { + if (remainingVideos.isEmpty() || (databaseFilter != null && !databaseFilter.matcher(service.getName()).matches()) || !requireLogin(service)) { continue; } @@ -736,7 +737,7 @@ public class CmdlineOperations implements CmdlineInterface { } for (SubtitleProvider service : getSubtitleProviders()) { - if (strict || remainingVideos.isEmpty() || (databaseFilter != null && !databaseFilter.matcher(service.getName()).matches())) { + if (strict || remainingVideos.isEmpty() || (databaseFilter != null && !databaseFilter.matcher(service.getName()).matches()) || !requireLogin(service)) { continue; } @@ -766,6 +767,16 @@ public class CmdlineOperations implements CmdlineInterface { return subtitleFiles; } + private static boolean requireLogin(Object service) { + if (service instanceof OpenSubtitlesClient) { + OpenSubtitlesClient osdb = (OpenSubtitlesClient) service; + if (osdb.isAnonymous()) { + throw new CmdlineException(String.format("%s: Please enter your login details by calling `filebot -script fn:osdb.login`", osdb.getName())); + } + } + return true; // no login => logged in by default + } + @Override public List getMissingSubtitles(Collection files, String db, String query, final String languageName, String output, String csn, final String format, boolean strict) throws Exception { List videoFiles = filter(filter(files, VIDEO_FILES), new FileFilter() {