Improved console output for -get-subtitles commands

This commit is contained in:
Reinhard Pointner 2016-04-30 22:59:51 +08:00
parent 06815469f6
commit b9099abbb1
4 changed files with 19 additions and 25 deletions

View File

@ -74,6 +74,7 @@ import net.filebot.vfs.FileInfo;
import net.filebot.vfs.MemoryFile; import net.filebot.vfs.MemoryFile;
import net.filebot.vfs.SimpleFileInfo; import net.filebot.vfs.SimpleFileInfo;
import net.filebot.web.AudioTrack; import net.filebot.web.AudioTrack;
import net.filebot.web.Datasource;
import net.filebot.web.Episode; import net.filebot.web.Episode;
import net.filebot.web.EpisodeFormat; import net.filebot.web.EpisodeFormat;
import net.filebot.web.EpisodeListProvider; import net.filebot.web.EpisodeListProvider;
@ -702,7 +703,7 @@ public class CmdlineOperations implements CmdlineInterface {
try { try {
log.fine("Looking up subtitles by hash via " + service.getName()); log.fine("Looking up subtitles by hash via " + service.getName());
Map<File, List<SubtitleDescriptor>> options = lookupSubtitlesByHash(service, remainingVideos, language.getName(), false, strict); Map<File, List<SubtitleDescriptor>> options = lookupSubtitlesByHash(service, remainingVideos, language.getName(), false, strict);
Map<File, File> downloads = downloadSubtitleBatch(service.getName(), options, outputFormat, outputEncoding, naming); Map<File, File> downloads = downloadSubtitleBatch(service, options, outputFormat, outputEncoding, naming);
remainingVideos.removeAll(downloads.keySet()); remainingVideos.removeAll(downloads.keySet());
subtitleFiles.addAll(downloads.values()); subtitleFiles.addAll(downloads.values());
} catch (Exception e) { } catch (Exception e) {
@ -718,7 +719,7 @@ public class CmdlineOperations implements CmdlineInterface {
try { try {
log.fine(format("Looking up subtitles by name via %s", service.getName())); log.fine(format("Looking up subtitles by name via %s", service.getName()));
Map<File, List<SubtitleDescriptor>> options = findSubtitlesByName(service, remainingVideos, language.getName(), query, false, strict); Map<File, List<SubtitleDescriptor>> options = findSubtitlesByName(service, remainingVideos, language.getName(), query, false, strict);
Map<File, File> downloads = downloadSubtitleBatch(service.getName(), options, outputFormat, outputEncoding, naming); Map<File, File> downloads = downloadSubtitleBatch(service, options, outputFormat, outputEncoding, naming);
remainingVideos.removeAll(downloads.keySet()); remainingVideos.removeAll(downloads.keySet());
subtitleFiles.addAll(downloads.values()); subtitleFiles.addAll(downloads.values());
} catch (Exception e) { } catch (Exception e) {
@ -807,7 +808,7 @@ public class CmdlineOperations implements CmdlineInterface {
} }
} }
private Map<File, File> downloadSubtitleBatch(String service, Map<File, List<SubtitleDescriptor>> subtitles, SubtitleFormat outputFormat, Charset outputEncoding, SubtitleNaming naming) { private Map<File, File> downloadSubtitleBatch(Datasource service, Map<File, List<SubtitleDescriptor>> subtitles, SubtitleFormat outputFormat, Charset outputEncoding, SubtitleNaming naming) {
Map<File, File> downloads = new LinkedHashMap<File, File>(); Map<File, File> downloads = new LinkedHashMap<File, File>();
// fetch subtitle // fetch subtitle
@ -815,7 +816,7 @@ public class CmdlineOperations implements CmdlineInterface {
if (options.size() > 0) { if (options.size() > 0) {
SubtitleDescriptor subtitle = options.get(0); SubtitleDescriptor subtitle = options.get(0);
try { try {
downloads.put(movie, downloadSubtitle(subtitle, movie, outputFormat, outputEncoding, naming)); downloads.put(movie, downloadSubtitle(service, subtitle, movie, outputFormat, outputEncoding, naming));
} catch (Exception e) { } catch (Exception e) {
log.warning(format("Failed to download %s: %s", subtitle.getPath(), e.getMessage())); log.warning(format("Failed to download %s: %s", subtitle.getPath(), e.getMessage()));
} }
@ -825,9 +826,9 @@ public class CmdlineOperations implements CmdlineInterface {
return downloads; 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 // 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); MemoryFile subtitleFile = fetchSubtitle(descriptor);
// subtitle filename is based on movie filename // 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 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); data = exportSubtitles(subtitleFile, outputFormat, 0, outputEncoding);
} }

View File

@ -41,13 +41,18 @@ public class ShooterSubtitles implements VideoHashSubtitleService {
} }
@Override @Override
public URI getLink() { public Icon getIcon() {
return URI.create("http://shooter.cn"); return ResourceManager.getIcon("search.shooter");
} }
@Override @Override
public Icon getIcon() { public String getIdentifier() {
return ResourceManager.getIcon("search.shooter"); return "Shooter";
}
@Override
public URI getLink() {
return URI.create("http://shooter.cn");
} }
public Cache getCache() { public Cache getCache() {

View File

@ -3,9 +3,7 @@ package net.filebot.web;
import java.net.URI; import java.net.URI;
import java.util.List; import java.util.List;
import javax.swing.Icon; public interface SubtitleProvider extends Datasource {
public interface SubtitleProvider {
public List<SubtitleSearchResult> search(String query) throws Exception; public List<SubtitleSearchResult> search(String query) throws Exception;
@ -15,10 +13,6 @@ public interface SubtitleProvider {
public URI getSubtitleListLink(SubtitleSearchResult searchResult, String languageName); public URI getSubtitleListLink(SubtitleSearchResult searchResult, String languageName);
public String getName();
public URI getLink(); public URI getLink();
public Icon getIcon();
} }

View File

@ -6,18 +6,12 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.swing.Icon; public interface VideoHashSubtitleService extends Datasource {
public interface VideoHashSubtitleService {
public Map<File, List<SubtitleDescriptor>> getSubtitleList(File[] videoFiles, String languageName) throws Exception; public Map<File, List<SubtitleDescriptor>> getSubtitleList(File[] videoFiles, String languageName) throws Exception;
public String getName();
public URI getLink(); public URI getLink();
public Icon getIcon();
public CheckResult checkSubtitle(File videoFile, File subtitleFile) throws Exception; public CheckResult checkSubtitle(File videoFile, File subtitleFile) throws Exception;
public void uploadSubtitle(Object identity, Locale locale, File[] videoFiles, File[] subtitleFiles) throws Exception; public void uploadSubtitle(Object identity, Locale locale, File[] videoFiles, File[] subtitleFiles) throws Exception;