mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 00:38:52 -05:00
* share all web service client objects across the application
This commit is contained in:
parent
d40a41d3a2
commit
2fc8d92e03
62
source/net/sourceforge/filebot/WebServices.java
Normal file
62
source/net/sourceforge/filebot/WebServices.java
Normal file
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -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<EpisodeListProvider, E
|
||||
|
||||
@Override
|
||||
protected EpisodeListProvider[] getSearchEngines() {
|
||||
return new EpisodeListProvider[] {
|
||||
new TVRageClient(),
|
||||
new AnidbClient(),
|
||||
new TVDotComClient(),
|
||||
new IMDbClient(),
|
||||
new TheTVDBClient(getApplicationProperty("thetvdb.apikey"))
|
||||
};
|
||||
return WebServices.getEpisodeListProviders();
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,6 @@ import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@ -34,18 +33,14 @@ import ca.odell.glazedlists.swing.EventSelectionModel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sourceforge.filebot.ResourceManager;
|
||||
import net.sourceforge.filebot.Settings;
|
||||
import net.sourceforge.filebot.WebServices;
|
||||
import net.sourceforge.filebot.similarity.Match;
|
||||
import net.sourceforge.filebot.ui.panel.rename.RenameModel.FormattedFuture;
|
||||
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.MovieDescriptor;
|
||||
import net.sourceforge.filebot.web.OpenSubtitlesClient;
|
||||
import net.sourceforge.filebot.web.TMDbClient;
|
||||
import net.sourceforge.filebot.web.TVDotComClient;
|
||||
import net.sourceforge.filebot.web.TVRageClient;
|
||||
import net.sourceforge.filebot.web.TheTVDBClient;
|
||||
import net.sourceforge.tuned.ExceptionUtilities;
|
||||
import net.sourceforge.tuned.PreferencesMap.PreferencesEntry;
|
||||
import net.sourceforge.tuned.ui.ActionPopup;
|
||||
@ -145,7 +140,7 @@ public class RenamePanel extends JComponent {
|
||||
final ActionPopup actionPopup = new ActionPopup("Fetch Episode List", ResourceManager.getIcon("action.fetch"));
|
||||
|
||||
// create actions for match popup episode list completion
|
||||
for (EpisodeListProvider provider : Arrays.asList(new TVRageClient(), new AnidbClient(), new TVDotComClient(), new IMDbClient(), new TheTVDBClient(getApplicationProperty("thetvdb.apikey")))) {
|
||||
for (EpisodeListProvider provider : WebServices.getEpisodeListProviders()) {
|
||||
actionPopup.add(new AutoCompleteAction(provider.getName(), provider.getIcon(), new EpisodeListMatcher(provider)));
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ import javax.swing.Icon;
|
||||
import javax.swing.JComboBox;
|
||||
|
||||
import net.sourceforge.filebot.Settings;
|
||||
import net.sourceforge.filebot.WebServices;
|
||||
import net.sourceforge.filebot.ui.AbstractSearchPanel;
|
||||
import net.sourceforge.filebot.ui.SelectDialog;
|
||||
import net.sourceforge.filebot.web.SearchResult;
|
||||
@ -103,7 +104,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
||||
|
||||
@Override
|
||||
public VideoHashSubtitleService[] getServices() {
|
||||
return SubtitleServices.getVideoHashSubtitleServices();
|
||||
return WebServices.getVideoHashSubtitleServices();
|
||||
}
|
||||
|
||||
|
||||
@ -141,7 +142,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
||||
|
||||
@Override
|
||||
protected SubtitleProvider[] getSearchEngines() {
|
||||
return SubtitleServices.getSubtitleProviders();
|
||||
return WebServices.getSubtitleProviders();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
|
||||
package net.sourceforge.filebot.ui.panel.subtitle;
|
||||
|
||||
|
||||
import static net.sourceforge.filebot.Settings.*;
|
||||
|
||||
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.VideoHashSubtitleService;
|
||||
|
||||
|
||||
final class SubtitleServices {
|
||||
|
||||
public static final OpenSubtitlesClient openSubtitlesClient = new OpenSubtitlesClient(String.format("%s %s", getApplicationName(), getApplicationVersion()));
|
||||
public static final SublightSubtitleClient sublightSubtitleClient = new SublightSubtitleClient(getApplicationName(), getApplicationProperty("sublight.apikey"));
|
||||
|
||||
public static final SubsceneSubtitleClient subsceneSubtitleClient = new SubsceneSubtitleClient();
|
||||
public static final SubtitleSourceClient subtitleSourceClient = new SubtitleSourceClient();
|
||||
|
||||
|
||||
public static SubtitleProvider[] getSubtitleProviders() {
|
||||
return new SubtitleProvider[] { openSubtitlesClient, subsceneSubtitleClient, sublightSubtitleClient, subtitleSourceClient };
|
||||
}
|
||||
|
||||
|
||||
public static VideoHashSubtitleService[] getVideoHashSubtitleServices() {
|
||||
return new VideoHashSubtitleService[] { openSubtitlesClient, sublightSubtitleClient };
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dummy constructor to prevent instantiation.
|
||||
*/
|
||||
private SubtitleServices() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user