From 5cb5d82e83afecea51baa22cb9ae65020dd560bb Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 24 Jul 2014 12:10:59 +0000 Subject: [PATCH] + remove depricated data sources --- source/net/filebot/Settings.properties | 1 - source/net/filebot/WebServices.java | 4 +- .../resources/search.serienjunkies.png | Bin 660 -> 0 bytes .../net/filebot/resources/search.sublight.png | Bin 251 -> 0 bytes .../net/filebot/resources/search.subscene.png | Bin 822 -> 0 bytes .../net/filebot/web/SerienjunkiesClient.java | 178 ------------------ .../web/SerienjunkiesSearchResult.java | 56 ------ source/net/filebot/web/TheTVDBClient.java | 2 +- .../filebot/web/SerienjunkiesClientTest.java | 58 ------ test/net/filebot/web/WebTestSuite.java | 2 +- 10 files changed, 3 insertions(+), 298 deletions(-) delete mode 100644 source/net/filebot/resources/search.serienjunkies.png delete mode 100644 source/net/filebot/resources/search.sublight.png delete mode 100644 source/net/filebot/resources/search.subscene.png delete mode 100644 source/net/filebot/web/SerienjunkiesClient.java delete mode 100644 source/net/filebot/web/SerienjunkiesSearchResult.java delete mode 100644 test/net/filebot/web/SerienjunkiesClientTest.java 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 d049c2d7ffffd492a0973eed991ac364a390cc9c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 660 zcmV;F0&D$=P)*lTAxhQ2>UYbMCow6~_+-#feG^G)Rriq@qQF zAh-yGk~WcxR&83PhSXGX`l-}jsr^$*R#x#dfOp+LkF&ID!fn`Y?TOlnmTa~UD zEv&EIs;RA?7jfV<=ZoI`>Dl=XWm!0mjWM9LK^sHLw*In4N=cGvEKAbT)bP_J(KX?g z+`^ra(dz1Sny%xAaGVrcYm{XXgc0vQe#LQY+FSPlU@MDP<5T!S$l2a5)Y4k6`pv`# z&YbKbTbJSX!)Hh-5JIqLSC+-q9G)NWV_}gniaFhL0zU{DpZrAUkrtF~D+-%MZVW%6 zHW5Y%6KVWiZjv$Hwa9y9yqX&66GskMKfaiHAAp}}$${d^Z{3e6fhe@Su zl0-8!aDj8Dx>;Jyb9dwgmFaS7s?y{)x6sFYj>2m|++AL^Tro{qImfBr_4Xrd@42xG!H z#<3Ny=cANFV2~KHnF>1gH>@0JZN4mwG33^k_GW6cgGuQ3mpl*G^(lEC#jP#el8f*A u=p;r;u%tu^UN<&2UD~m8_muem&-5G2Ec~IoXL4nJ za0`Jj zCtPVbn84s=<>Y2}8mw}G}Zc)I$ztaD0e0s!$nTd)8C diff --git a/source/net/filebot/resources/search.subscene.png b/source/net/filebot/resources/search.subscene.png deleted file mode 100644 index 5c07e6b9b4c70699fb1e4569a6b003ac25921f5f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 822 zcmV-61Ihe}P)Vucj^KyV=y>7o?`abcmj6mgY5petQT7X@)6A{a%)g^KZmh=R3HY)I4w+E|;$ z=4S5Pxp!vX_jPeKwYg_`c%J7R4!@%wJv!;qw8QqY&at!Bpl}79w2Q;X^8{-Olp1K_ zxQ0%WO|q;z6i^z=o*fl-HACipTjkVKlQ@LAZ&nBc84R%&5m7^C040izq{H+?ojqd> zj!(g*rB%d}EscmE#`zdyQ3{*`W85GBMZ240gN#?780FW+Hkbb_(B7ScWMq7ts9G6> zh-ODKCe0kBv4nArnTJ{&8%a37kPv8L`@T{nYaBVaA8UnPzu?fg~z^yTsF)r;k+Vq?WuCPRz8J z-XF8Exrw)XG@kADdZcN==_hM^zu4!et2x!a;n)G;lgo-M&6zn6l1spw$77`I@!pqf zXkX*)9*Jk2DY$Z@;Qo6wFB}c{;+LGnS&Ew}f7}pWezwJfdmEg5xX))lB)t83j%cA0 zhNwe_?{;b0!8&j_J~$JzvJP_>N=(}0_2&W(?;GRda>DHUYs{|*jaZ@nC2=c20o~kj zUn}6l*Fyg4DZX0LOgGxhU-WqQLe543)llKwZIrjLazGR)me&hjIiFGK=RC4caqioa zw-)+zoFWQto3}XFj&S6|cgu!1J~k{}y2;nS3t=SqL&`yEYwb|88NtG`p;-&5MI}k* z7($T2GwFK0fykZlN 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 { }