From b9099abbb183db2b80d7d6c7de915717311168a4 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 30 Apr 2016 22:59:51 +0800 Subject: [PATCH] Improved console output for -get-subtitles commands --- source/net/filebot/cli/CmdlineOperations.java | 15 ++++++++------- source/net/filebot/web/ShooterSubtitles.java | 13 +++++++++---- source/net/filebot/web/SubtitleProvider.java | 8 +------- .../net/filebot/web/VideoHashSubtitleService.java | 8 +------- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/source/net/filebot/cli/CmdlineOperations.java b/source/net/filebot/cli/CmdlineOperations.java index d7dc5e55..d0fb7749 100644 --- a/source/net/filebot/cli/CmdlineOperations.java +++ b/source/net/filebot/cli/CmdlineOperations.java @@ -74,6 +74,7 @@ import net.filebot.vfs.FileInfo; import net.filebot.vfs.MemoryFile; import net.filebot.vfs.SimpleFileInfo; import net.filebot.web.AudioTrack; +import net.filebot.web.Datasource; import net.filebot.web.Episode; import net.filebot.web.EpisodeFormat; import net.filebot.web.EpisodeListProvider; @@ -702,7 +703,7 @@ public class CmdlineOperations implements CmdlineInterface { try { log.fine("Looking up subtitles by hash via " + service.getName()); Map> options = lookupSubtitlesByHash(service, remainingVideos, language.getName(), false, strict); - Map downloads = downloadSubtitleBatch(service.getName(), options, outputFormat, outputEncoding, naming); + Map downloads = downloadSubtitleBatch(service, options, outputFormat, outputEncoding, naming); remainingVideos.removeAll(downloads.keySet()); subtitleFiles.addAll(downloads.values()); } catch (Exception e) { @@ -718,7 +719,7 @@ public class CmdlineOperations implements CmdlineInterface { try { log.fine(format("Looking up subtitles by name via %s", service.getName())); Map> options = findSubtitlesByName(service, remainingVideos, language.getName(), query, false, strict); - Map downloads = downloadSubtitleBatch(service.getName(), options, outputFormat, outputEncoding, naming); + Map downloads = downloadSubtitleBatch(service, options, outputFormat, outputEncoding, naming); remainingVideos.removeAll(downloads.keySet()); subtitleFiles.addAll(downloads.values()); } catch (Exception e) { @@ -807,7 +808,7 @@ public class CmdlineOperations implements CmdlineInterface { } } - private Map downloadSubtitleBatch(String service, Map> subtitles, SubtitleFormat outputFormat, Charset outputEncoding, SubtitleNaming naming) { + private Map downloadSubtitleBatch(Datasource service, Map> subtitles, SubtitleFormat outputFormat, Charset outputEncoding, SubtitleNaming naming) { Map downloads = new LinkedHashMap(); // fetch subtitle @@ -815,7 +816,7 @@ public class CmdlineOperations implements CmdlineInterface { if (options.size() > 0) { SubtitleDescriptor subtitle = options.get(0); try { - downloads.put(movie, downloadSubtitle(subtitle, movie, outputFormat, outputEncoding, naming)); + downloads.put(movie, downloadSubtitle(service, subtitle, movie, outputFormat, outputEncoding, naming)); } catch (Exception e) { log.warning(format("Failed to download %s: %s", subtitle.getPath(), e.getMessage())); } @@ -825,9 +826,9 @@ public class CmdlineOperations implements CmdlineInterface { return downloads; } - private File downloadSubtitle(SubtitleDescriptor descriptor, File movieFile, SubtitleFormat outputFormat, Charset outputEncoding, SubtitleNaming naming) throws Exception { + private File downloadSubtitle(Datasource service, SubtitleDescriptor descriptor, File movieFile, SubtitleFormat outputFormat, Charset outputEncoding, SubtitleNaming naming) throws Exception { // fetch subtitle archive - log.config(format("Fetching [%s]", descriptor.getPath())); + log.config(format("Fetching [%s] subtitles [%s] from [%s]", descriptor.getLanguageName(), descriptor.getPath(), service.getName())); MemoryFile subtitleFile = fetchSubtitle(descriptor); // subtitle filename is based on movie filename @@ -839,7 +840,7 @@ public class CmdlineOperations implements CmdlineInterface { ext = outputFormat.getFilter().extension(); // adjust extension of the output file } - log.finest(format("Export [%s] as: %s / %s", subtitleFile.getName(), outputFormat, outputEncoding.displayName(Locale.ROOT))); + log.finest(format("Export [%s] as [%s / %s]", subtitleFile.getName(), outputFormat, outputEncoding.displayName(Locale.ROOT))); data = exportSubtitles(subtitleFile, outputFormat, 0, outputEncoding); } diff --git a/source/net/filebot/web/ShooterSubtitles.java b/source/net/filebot/web/ShooterSubtitles.java index 33396fe2..877365cf 100644 --- a/source/net/filebot/web/ShooterSubtitles.java +++ b/source/net/filebot/web/ShooterSubtitles.java @@ -41,13 +41,18 @@ public class ShooterSubtitles implements VideoHashSubtitleService { } @Override - public URI getLink() { - return URI.create("http://shooter.cn"); + public Icon getIcon() { + return ResourceManager.getIcon("search.shooter"); } @Override - public Icon getIcon() { - return ResourceManager.getIcon("search.shooter"); + public String getIdentifier() { + return "Shooter"; + } + + @Override + public URI getLink() { + return URI.create("http://shooter.cn"); } public Cache getCache() { diff --git a/source/net/filebot/web/SubtitleProvider.java b/source/net/filebot/web/SubtitleProvider.java index bf5c1f77..52e90c72 100644 --- a/source/net/filebot/web/SubtitleProvider.java +++ b/source/net/filebot/web/SubtitleProvider.java @@ -3,9 +3,7 @@ package net.filebot.web; import java.net.URI; import java.util.List; -import javax.swing.Icon; - -public interface SubtitleProvider { +public interface SubtitleProvider extends Datasource { public List search(String query) throws Exception; @@ -15,10 +13,6 @@ public interface SubtitleProvider { public URI getSubtitleListLink(SubtitleSearchResult searchResult, String languageName); - public String getName(); - public URI getLink(); - public Icon getIcon(); - } diff --git a/source/net/filebot/web/VideoHashSubtitleService.java b/source/net/filebot/web/VideoHashSubtitleService.java index efdf852d..9a59c9cc 100644 --- a/source/net/filebot/web/VideoHashSubtitleService.java +++ b/source/net/filebot/web/VideoHashSubtitleService.java @@ -6,18 +6,12 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import javax.swing.Icon; - -public interface VideoHashSubtitleService { +public interface VideoHashSubtitleService extends Datasource { public Map> getSubtitleList(File[] videoFiles, String languageName) throws Exception; - public String getName(); - public URI getLink(); - public Icon getIcon(); - public CheckResult checkSubtitle(File videoFile, File subtitleFile) throws Exception; public void uploadSubtitle(Object identity, Locale locale, File[] videoFiles, File[] subtitleFiles) throws Exception;