diff --git a/source/net/filebot/Settings.properties b/source/net/filebot/Settings.properties index 9b8278dd..2020328d 100644 --- a/source/net/filebot/Settings.properties +++ b/source/net/filebot/Settings.properties @@ -17,6 +17,5 @@ analytics.WebPropertyID: UA-25379256-3 # database api keys thetvdb.apikey: 58B4AA94C59AD656 themoviedb.apikey: 5a6edae568130bf10617b6d45be99f13 -serienjunkies.apikey: 9fbhw9uebfiwvbefzuwv fanart.tv.apikey: 780b986b22c35e6f7a134a2f392c2deb acoustid.apikey: 0B3qZnQc diff --git a/source/net/filebot/WebServices.java b/source/net/filebot/WebServices.java index 6f28954f..df27ab66 100644 --- a/source/net/filebot/WebServices.java +++ b/source/net/filebot/WebServices.java @@ -33,7 +33,6 @@ import net.filebot.web.MovieIdentificationService; import net.filebot.web.MusicIdentificationService; import net.filebot.web.OpenSubtitlesClient; import net.filebot.web.SearchResult; -import net.filebot.web.SerienjunkiesClient; import net.filebot.web.SubtitleProvider; import net.filebot.web.TMDbClient; import net.filebot.web.TVRageClient; @@ -50,7 +49,6 @@ public final class WebServices { // episode dbs public static final TVRageClient TVRage = new TVRageClient(); public static final AnidbClient AniDB = new AnidbClientWithLocalSearch(getApplicationName().toLowerCase(), 5); - public static final SerienjunkiesClient Serienjunkies = new SerienjunkiesClient(getApplicationProperty("serienjunkies.apikey")); // extended TheTVDB module with local search public static final TheTVDBClientWithLocalSearch TheTVDB = new TheTVDBClientWithLocalSearch(getApplicationProperty("thetvdb.apikey")); @@ -68,7 +66,7 @@ public final class WebServices { public static final XattrMetaInfoProvider XattrMetaData = new XattrMetaInfoProvider(); public static EpisodeListProvider[] getEpisodeListProviders() { - return new EpisodeListProvider[] { TheTVDB, AniDB, TVRage, Serienjunkies }; + return new EpisodeListProvider[] { TheTVDB, AniDB, TVRage }; } public static MovieIdentificationService[] getMovieIdentificationServices() { diff --git a/source/net/filebot/resources/search.serienjunkies.png b/source/net/filebot/resources/search.serienjunkies.png deleted file mode 100644 index d049c2d7..00000000 Binary files a/source/net/filebot/resources/search.serienjunkies.png and /dev/null differ diff --git a/source/net/filebot/resources/search.sublight.png b/source/net/filebot/resources/search.sublight.png deleted file mode 100644 index 662a00fc..00000000 Binary files a/source/net/filebot/resources/search.sublight.png and /dev/null differ diff --git a/source/net/filebot/resources/search.subscene.png b/source/net/filebot/resources/search.subscene.png deleted file mode 100644 index 5c07e6b9..00000000 Binary files a/source/net/filebot/resources/search.subscene.png and /dev/null differ diff --git a/source/net/filebot/web/SerienjunkiesClient.java b/source/net/filebot/web/SerienjunkiesClient.java deleted file mode 100644 index 9b3e6b66..00000000 --- a/source/net/filebot/web/SerienjunkiesClient.java +++ /dev/null @@ -1,178 +0,0 @@ -package net.filebot.web; - -import static net.filebot.web.EpisodeUtilities.*; -import static net.filebot.web.WebRequest.*; - -import java.io.IOException; -import java.io.Reader; -import java.net.URI; -import java.net.URL; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Locale; -import java.util.Set; - -import javax.net.ssl.HttpsURLConnection; -import javax.swing.Icon; - -import net.filebot.Cache; -import net.filebot.ResourceManager; - -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -public class SerienjunkiesClient extends AbstractEpisodeListProvider { - - private final String host = "api.serienjunkies.de"; - - private final String apikey; - - public SerienjunkiesClient(String apikey) { - this.apikey = apikey; - } - - @Override - public String getName() { - return "Serienjunkies"; - } - - @Override - public Icon getIcon() { - return ResourceManager.getIcon("search.serienjunkies"); - } - - @Override - public Locale getDefaultLocale() { - return Locale.GERMAN; - } - - @Override - public ResultCache getCache() { - return new ResultCache(host, Cache.getCache("web-datasource")); - } - - @Override - public List search(String query, final Locale locale) throws Exception { - // bypass automatic caching since search is based on locally cached data anyway - return fetchSearchResult(query, locale); - } - - @Override - public List fetchSearchResult(String query, Locale locale) throws Exception { - LocalSearch index = new LocalSearch(getSeriesTitles()) { - - @Override - protected Set getFields(SearchResult series) { - return set(series.getEffectiveNames()); - } - }; - - return new ArrayList(index.search(query)); - } - - protected synchronized List getSeriesTitles() throws IOException { - ResultCache cache = getCache(); - - @SuppressWarnings("unchecked") - List seriesList = (List) cache.getSearchResult(null, Locale.ROOT); - if (seriesList != null) { - return seriesList; - } - - // fetch series data - seriesList = new ArrayList(); - - JSONObject data = (JSONObject) request("/allseries.php?d=" + apikey); - JSONArray list = (JSONArray) data.get("allseries"); - - for (Object element : list) { - JSONObject obj = (JSONObject) element; - - Integer sid = new Integer((String) obj.get("id")); - String link = (String) obj.get("link"); - String mainTitle = (String) obj.get("short"); - String germanTitle = (String) obj.get("short_german"); - SimpleDate startDate = SimpleDate.parse((String) obj.get("firstepisode"), "yyyy-MM-dd"); - - Set titleSet = new LinkedHashSet(2); - for (String title : new String[] { germanTitle, mainTitle }) { - if (title != null && title.length() > 0) { - titleSet.add(title); - } - } - if (titleSet.size() > 0) { - List titleList = new ArrayList(titleSet); - seriesList.add(new SerienjunkiesSearchResult(sid, link, titleList.get(0), titleList.subList(1, titleList.size()).toArray(new String[0]), startDate)); - } - } - - // populate cache - return cache.putSearchResult(null, Locale.ROOT, seriesList); - } - - @Override - public List fetchEpisodeList(SearchResult searchResult, SortOrder sortOrder, Locale locale) throws IOException { - SerienjunkiesSearchResult series = (SerienjunkiesSearchResult) searchResult; - - // fetch episode data - List episodes = new ArrayList(25); - - String seriesName = series.getName(); - JSONObject data = (JSONObject) request("/allepisodes.php?d=" + apikey + "&q=" + series.getSeriesId()); - JSONArray list = (JSONArray) data.get("allepisodes"); - - for (int i = 0; i < list.size(); i++) { - JSONObject obj = (JSONObject) list.get(i); - - Integer season = new Integer((String) obj.get("season")); - Integer episode = new Integer((String) obj.get("episode")); - SimpleDate airdate = SimpleDate.parse((String) ((JSONObject) obj.get("airdates")).get("premiere"), "yyyy-MM-dd"); - - String title = (String) obj.get("original"); - String german = (String) obj.get("german"); - if (title == null || (Locale.GERMAN.equals(locale) && german != null)) { - title = german; - } - - // enforce sanity - if (title == null) { - title = ""; - } - - // additional metadata - SortOrder order = SortOrder.Airdate; - Locale language = Locale.GERMAN.equals(locale) ? Locale.GERMAN : Locale.ENGLISH; - - episodes.add(new Episode(seriesName, series.getStartDate(), season, episode, title, i + 1, null, order, language, airdate, searchResult)); - } - - // make sure episodes are in ordered correctly - sortEpisodes(episodes); - - return episodes; - } - - protected Object request(String resource) throws IOException { - URL url = new URL("https", host, resource); - HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); - - // disable SSL certificate validation - connection.setSSLSocketFactory(createIgnoreCertificateSocketFactory()); - - // fetch and parse JSON data - Reader reader = getReader(connection); - try { - return JSONValue.parse(reader); - } finally { - reader.close(); - } - } - - @Override - public URI getEpisodeListLink(SearchResult searchResult) { - return URI.create(String.format("http://www.serienjunkies.de/%s/alle-serien-staffeln.html", ((SerienjunkiesSearchResult) searchResult).getLink())); - } - -} diff --git a/source/net/filebot/web/SerienjunkiesSearchResult.java b/source/net/filebot/web/SerienjunkiesSearchResult.java deleted file mode 100644 index e227e0f6..00000000 --- a/source/net/filebot/web/SerienjunkiesSearchResult.java +++ /dev/null @@ -1,56 +0,0 @@ -package net.filebot.web; - -public class SerienjunkiesSearchResult extends SearchResult { - - protected int sid; - protected String link; - protected SimpleDate startDate; - - protected SerienjunkiesSearchResult() { - // used by serializer - } - - public SerienjunkiesSearchResult(int sid, String link, String germanTitle, String[] otherTitles, SimpleDate startDate) { - super(germanTitle, otherTitles); - this.sid = sid; - this.link = link; - this.startDate = startDate; - } - - public int getId() { - return sid; - } - - public int getSeriesId() { - return sid; - } - - public String getLink() { - return link; - } - - public SimpleDate getStartDate() { - return startDate; - } - - @Override - public int hashCode() { - return sid; - } - - @Override - public boolean equals(Object object) { - if (object instanceof SerienjunkiesSearchResult) { - SerienjunkiesSearchResult other = (SerienjunkiesSearchResult) object; - return this.sid == other.sid; - } - - return false; - } - - @Override - public SerienjunkiesSearchResult clone() { - return new SerienjunkiesSearchResult(sid, link, name, aliasNames, startDate == null ? null : startDate.clone()); - } - -} diff --git a/source/net/filebot/web/TheTVDBClient.java b/source/net/filebot/web/TheTVDBClient.java index ef4de516..024d1192 100644 --- a/source/net/filebot/web/TheTVDBClient.java +++ b/source/net/filebot/web/TheTVDBClient.java @@ -118,7 +118,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider { @Override public List fetchEpisodeList(SearchResult searchResult, SortOrder sortOrder, Locale locale) throws Exception { TheTVDBSearchResult series = (TheTVDBSearchResult) searchResult; - Document dom = getXmlResource(MirrorType.XML, "/api/" + apikey + "/series/" + series.getSeriesId() + "/all/" + locale.getLanguage() + ".xml"); + Document dom = getXmlResource(MirrorType.XML, "/api/" + apikey + "/series/" + series.getSeriesId() + "/all/" + getLanguageCode(locale) + ".xml"); // we could get the series name from the search result, but the language may not match the given parameter String seriesName = selectString("Data/Series/SeriesName", dom); diff --git a/test/net/filebot/web/SerienjunkiesClientTest.java b/test/net/filebot/web/SerienjunkiesClientTest.java deleted file mode 100644 index 7c748770..00000000 --- a/test/net/filebot/web/SerienjunkiesClientTest.java +++ /dev/null @@ -1,58 +0,0 @@ - -package net.filebot.web; - - -import static org.junit.Assert.*; - -import java.util.List; -import java.util.Locale; - -import net.sf.ehcache.CacheManager; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - - -public class SerienjunkiesClientTest { - - private SerienjunkiesClient serienjunkies = new SerienjunkiesClient("9fbhw9uebfiwvbefzuwv"); - - - @Test - public void search() throws Exception { - List results = serienjunkies.search("alias die agentin"); - assertEquals(1, results.size()); - - SerienjunkiesSearchResult series = (SerienjunkiesSearchResult) results.get(0); - assertEquals(34, series.getSeriesId()); - assertEquals("Alias", series.getLink()); - assertEquals("Alias - Die Agentin", series.getName()); - assertEquals("Alias", series.getEffectiveNames().get(1)); - assertEquals("Alias - Die Agentin", series.getEffectiveNames().get(0)); - assertEquals("2001-09-30", series.getStartDate().toString()); - } - - - @Test - public void getEpisodeListAll() throws Exception { - List list = serienjunkies.getEpisodeList(new SerienjunkiesSearchResult(260, "greys-anatomy", "Grey's Anatomy", null, null), null, Locale.GERMAN); - - // check ordinary episode - Episode eps = list.get(0); - assertEquals("Grey's Anatomy", eps.getSeriesName()); - assertEquals("Nur 48 Stunden", eps.getTitle()); - assertEquals("1", eps.getEpisode().toString()); - assertEquals("1", eps.getSeason().toString()); - assertEquals("1", eps.getAbsolute().toString()); - assertEquals("2005-03-27", eps.getAirdate().toString()); - } - - - @BeforeClass - @AfterClass - public static void clearCache() { - CacheManager.getInstance().clearAll(); - } - -} diff --git a/test/net/filebot/web/WebTestSuite.java b/test/net/filebot/web/WebTestSuite.java index 3f5ea5e7..ebba27f3 100644 --- a/test/net/filebot/web/WebTestSuite.java +++ b/test/net/filebot/web/WebTestSuite.java @@ -5,7 +5,7 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({ AnidbClientTest.class, TVRageClientTest.class, TheTVDBClientTest.class, SerienjunkiesClientTest.class, TMDbClientTest.class, IMDbClientTest.class, OpenSubtitlesXmlRpcTest.class }) +@SuiteClasses({ AnidbClientTest.class, TVRageClientTest.class, TheTVDBClientTest.class, TMDbClientTest.class, IMDbClientTest.class, OpenSubtitlesXmlRpcTest.class }) public class WebTestSuite { }