From 2fc8d92e038564721e725267a035bd56a5ecf86d Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 13 May 2010 14:20:33 +0000 Subject: [PATCH] * share all web service client objects across the application --- .../net/sourceforge/filebot/WebServices.java | 62 +++++++++++++++++++ .../panel/episodelist/EpisodeListPanel.java | 15 +---- .../filebot/ui/panel/rename/RenamePanel.java | 9 +-- .../ui/panel/subtitle/SubtitlePanel.java | 5 +- .../ui/panel/subtitle/SubtitleServices.java | 41 ------------ 5 files changed, 69 insertions(+), 63 deletions(-) create mode 100644 source/net/sourceforge/filebot/WebServices.java delete mode 100644 source/net/sourceforge/filebot/ui/panel/subtitle/SubtitleServices.java diff --git a/source/net/sourceforge/filebot/WebServices.java b/source/net/sourceforge/filebot/WebServices.java new file mode 100644 index 00000000..d4fb6104 --- /dev/null +++ b/source/net/sourceforge/filebot/WebServices.java @@ -0,0 +1,62 @@ + +package net.sourceforge.filebot; + + +import static net.sourceforge.filebot.Settings.*; + +import net.sourceforge.filebot.web.AnidbClient; +import net.sourceforge.filebot.web.EpisodeListProvider; +import net.sourceforge.filebot.web.IMDbClient; +import net.sourceforge.filebot.web.OpenSubtitlesClient; +import net.sourceforge.filebot.web.SublightSubtitleClient; +import net.sourceforge.filebot.web.SubsceneSubtitleClient; +import net.sourceforge.filebot.web.SubtitleProvider; +import net.sourceforge.filebot.web.SubtitleSourceClient; +import net.sourceforge.filebot.web.TVDotComClient; +import net.sourceforge.filebot.web.TVRageClient; +import net.sourceforge.filebot.web.TheTVDBClient; +import net.sourceforge.filebot.web.VideoHashSubtitleService; + + +/** + * Reuse the same web service client so login, cache, etc. can be shared. + */ +public final class WebServices { + + // episode dbs + public static final TVRageClient TVRage = new TVRageClient(); + public static final AnidbClient AniDB = new AnidbClient(); + public static final TVDotComClient TVDotCom = new TVDotComClient(); + public static final IMDbClient IMDb = new IMDbClient(); + public static final TheTVDBClient TheTVDB = new TheTVDBClient(getApplicationProperty("thetvdb.apikey")); + + // subtitle dbs + public static final OpenSubtitlesClient OpenSubtitles = new OpenSubtitlesClient(String.format("%s %s", getApplicationName(), getApplicationVersion())); + public static final SublightSubtitleClient Sublight = new SublightSubtitleClient(getApplicationName(), getApplicationProperty("sublight.apikey")); + public static final SubsceneSubtitleClient Subscene = new SubsceneSubtitleClient(); + public static final SubtitleSourceClient SubtitleSource = new SubtitleSourceClient(); + + + public static EpisodeListProvider[] getEpisodeListProviders() { + return new EpisodeListProvider[] { TVRage, AniDB, TVDotCom, IMDb, TheTVDB }; + } + + + public static SubtitleProvider[] getSubtitleProviders() { + return new SubtitleProvider[] { OpenSubtitles, Subscene, Sublight, SubtitleSource }; + } + + + public static VideoHashSubtitleService[] getVideoHashSubtitleServices() { + return new VideoHashSubtitleService[] { OpenSubtitles, Sublight }; + } + + + /** + * Dummy constructor to prevent instantiation. + */ + private WebServices() { + throw new UnsupportedOperationException(); + } + +} diff --git a/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java b/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java index 0d6089a2..dcbe56c4 100644 --- a/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java +++ b/source/net/sourceforge/filebot/ui/panel/episodelist/EpisodeListPanel.java @@ -2,7 +2,6 @@ package net.sourceforge.filebot.ui.panel.episodelist; -import static net.sourceforge.filebot.Settings.*; import static net.sourceforge.filebot.ui.panel.episodelist.SeasonSpinnerModel.*; import java.awt.datatransfer.Clipboard; @@ -25,6 +24,7 @@ import javax.swing.JSpinner; import javax.swing.KeyStroke; import net.sourceforge.filebot.Settings; +import net.sourceforge.filebot.WebServices; import net.sourceforge.filebot.ui.AbstractSearchPanel; import net.sourceforge.filebot.ui.FileBotList; import net.sourceforge.filebot.ui.FileBotListExportHandler; @@ -35,14 +35,9 @@ import net.sourceforge.filebot.ui.transfer.ClipboardHandler; import net.sourceforge.filebot.ui.transfer.CompositeTranserable; import net.sourceforge.filebot.ui.transfer.FileExportHandler; import net.sourceforge.filebot.ui.transfer.SaveAction; -import net.sourceforge.filebot.web.AnidbClient; import net.sourceforge.filebot.web.Episode; import net.sourceforge.filebot.web.EpisodeListProvider; -import net.sourceforge.filebot.web.IMDbClient; import net.sourceforge.filebot.web.SearchResult; -import net.sourceforge.filebot.web.TVDotComClient; -import net.sourceforge.filebot.web.TVRageClient; -import net.sourceforge.filebot.web.TheTVDBClient; import net.sourceforge.tuned.StringUtilities; import net.sourceforge.tuned.ui.LabelProvider; import net.sourceforge.tuned.ui.SelectButton; @@ -80,13 +75,7 @@ public class EpisodeListPanel extends AbstractSearchPanel