mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-02 08:25:02 -04:00
+ remove depricated data sources
This commit is contained in:
parent
c6bbd4db54
commit
5cb5d82e83
@ -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
|
||||
|
@ -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() {
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 660 B |
Binary file not shown.
Before Width: | Height: | Size: 251 B |
Binary file not shown.
Before Width: | Height: | Size: 822 B |
@ -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<SearchResult> 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<SearchResult> fetchSearchResult(String query, Locale locale) throws Exception {
|
||||
LocalSearch<SearchResult> index = new LocalSearch<SearchResult>(getSeriesTitles()) {
|
||||
|
||||
@Override
|
||||
protected Set<String> getFields(SearchResult series) {
|
||||
return set(series.getEffectiveNames());
|
||||
}
|
||||
};
|
||||
|
||||
return new ArrayList<SearchResult>(index.search(query));
|
||||
}
|
||||
|
||||
protected synchronized List<SerienjunkiesSearchResult> getSeriesTitles() throws IOException {
|
||||
ResultCache cache = getCache();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SerienjunkiesSearchResult> seriesList = (List) cache.getSearchResult(null, Locale.ROOT);
|
||||
if (seriesList != null) {
|
||||
return seriesList;
|
||||
}
|
||||
|
||||
// fetch series data
|
||||
seriesList = new ArrayList<SerienjunkiesSearchResult>();
|
||||
|
||||
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<String> titleSet = new LinkedHashSet<String>(2);
|
||||
for (String title : new String[] { germanTitle, mainTitle }) {
|
||||
if (title != null && title.length() > 0) {
|
||||
titleSet.add(title);
|
||||
}
|
||||
}
|
||||
if (titleSet.size() > 0) {
|
||||
List<String> titleList = new ArrayList<String>(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<Episode> fetchEpisodeList(SearchResult searchResult, SortOrder sortOrder, Locale locale) throws IOException {
|
||||
SerienjunkiesSearchResult series = (SerienjunkiesSearchResult) searchResult;
|
||||
|
||||
// fetch episode data
|
||||
List<Episode> episodes = new ArrayList<Episode>(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()));
|
||||
}
|
||||
|
||||
}
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
@ -118,7 +118,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||
@Override
|
||||
public List<Episode> 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);
|
||||
|
@ -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<SearchResult> 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<Episode> 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();
|
||||
}
|
||||
|
||||
}
|
@ -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 {
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user