mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-09 22:09:47 -04:00
* code cleanup
This commit is contained in:
parent
d499bb01d6
commit
40c64041a1
@ -133,7 +133,7 @@
|
||||
/>
|
||||
|
||||
<!--
|
||||
Very long-lived cache (one month!) for AniDB and Serienjunkies anime list and episode information.
|
||||
Very long-lived cache (one month!) anime/series list and episode information.
|
||||
-->
|
||||
<cache name="web-persistent-datasource"
|
||||
maxElementsInMemory="20"
|
||||
|
@ -110,11 +110,9 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
return seriesList;
|
||||
|
||||
// fetch series data
|
||||
Reader reader = getReader(createConnection("allseries.php?d=" + apikey));
|
||||
seriesList = new ArrayList<SerienjunkiesSearchResult>();
|
||||
|
||||
try {
|
||||
JSONObject data = (JSONObject) JSONValue.parse(reader);
|
||||
JSONObject data = (JSONObject) request("allseries.php?d=" + apikey);
|
||||
JSONArray list = (JSONArray) data.get("allseries");
|
||||
|
||||
for (Object element : list) {
|
||||
@ -129,9 +127,6 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
|
||||
// populate cache
|
||||
cache.putSeriesList(seriesList);
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
|
||||
return seriesList;
|
||||
}
|
||||
@ -146,12 +141,10 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
if (episodes != null)
|
||||
return episodes;
|
||||
|
||||
// fetch series data
|
||||
Reader reader = getReader(createConnection("allepisodes.php?d=" + apikey + "&q=" + series.getSeriesId()));
|
||||
// fetch episode data
|
||||
episodes = new ArrayList<Episode>(25);
|
||||
|
||||
try {
|
||||
JSONObject data = (JSONObject) JSONValue.parse(reader);
|
||||
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++) {
|
||||
@ -166,9 +159,6 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
|
||||
// populate cache
|
||||
cache.putEpisodeList(episodes, series.getSeriesId());
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
|
||||
// make sure episodes are in ordered correctly
|
||||
sortEpisodes(episodes);
|
||||
@ -177,14 +167,20 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
}
|
||||
|
||||
|
||||
private HttpsURLConnection createConnection(String resource) throws IOException, GeneralSecurityException {
|
||||
private Object request(String resource) throws IOException, GeneralSecurityException {
|
||||
URL url = new URL("https", host, resource);
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
|
||||
// disable SSL certificate validation
|
||||
connection.setSSLSocketFactory(createIgnoreCertificateSocketFactory());
|
||||
|
||||
return connection;
|
||||
// fetch and parse json data
|
||||
Reader reader = getReader(connection);
|
||||
try {
|
||||
return JSONValue.parse(reader);
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user