mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 08:48:51 -05:00
+ updated Serienjunkies support (support episode airdate and website links)
This commit is contained in:
parent
40c64041a1
commit
38bbaaf5d8
@ -10,7 +10,6 @@ import java.io.Reader;
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -51,7 +50,25 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
|
||||
|
||||
@Override
|
||||
public List<SearchResult> search(String query) throws Exception {
|
||||
public String getName() {
|
||||
return "Serienjunkies";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getIcon("search.serienjunkies");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasSingleSeasonSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SearchResult> search(String query) throws IOException {
|
||||
// normalize
|
||||
query = query.toLowerCase();
|
||||
|
||||
@ -103,7 +120,7 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
}
|
||||
|
||||
|
||||
protected List<SerienjunkiesSearchResult> getSeriesTitles() throws Exception {
|
||||
protected List<SerienjunkiesSearchResult> getSeriesTitles() throws IOException {
|
||||
// try cache first
|
||||
List<SerienjunkiesSearchResult> seriesList = cache.getSeriesList();
|
||||
if (seriesList != null)
|
||||
@ -118,11 +135,12 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
for (Object element : list) {
|
||||
JSONObject obj = (JSONObject) element;
|
||||
|
||||
String sid = (String) obj.get("id");
|
||||
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");
|
||||
|
||||
seriesList.add(new SerienjunkiesSearchResult(Integer.parseInt(sid), mainTitle, germanTitle != null && germanTitle.length() > 0 ? germanTitle : null));
|
||||
seriesList.add(new SerienjunkiesSearchResult(sid, link, mainTitle, germanTitle != null && germanTitle.length() > 0 ? germanTitle : null));
|
||||
}
|
||||
|
||||
// populate cache
|
||||
@ -133,7 +151,7 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
|
||||
|
||||
@Override
|
||||
public List<Episode> getEpisodeList(SearchResult searchResult) throws Exception {
|
||||
public List<Episode> getEpisodeList(SearchResult searchResult) throws IOException {
|
||||
SerienjunkiesSearchResult series = (SerienjunkiesSearchResult) searchResult;
|
||||
|
||||
// try cache first
|
||||
@ -150,11 +168,12 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
JSONObject obj = (JSONObject) list.get(i);
|
||||
|
||||
String season = (String) obj.get("season");
|
||||
String episode = (String) obj.get("episode");
|
||||
Integer season = new Integer((String) obj.get("season"));
|
||||
Integer episode = new Integer((String) obj.get("episode"));
|
||||
String title = (String) obj.get("german");
|
||||
Date airdate = Date.parse((String) ((JSONObject) obj.get("airdates")).get("premiere"), "yyyy-MM-dd");
|
||||
|
||||
episodes.add(new Episode(series.getName(), new Integer(season), new Integer(episode), title, i + 1, null, null));
|
||||
episodes.add(new Episode(series.getName(), season, episode, title, i + 1, null, airdate));
|
||||
}
|
||||
|
||||
// populate cache
|
||||
@ -167,7 +186,20 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
}
|
||||
|
||||
|
||||
private Object request(String resource) throws IOException, GeneralSecurityException {
|
||||
@Override
|
||||
public List<Episode> getEpisodeList(SearchResult searchResult, int season) throws IOException {
|
||||
List<Episode> all = getEpisodeList(searchResult);
|
||||
List<Episode> eps = filterBySeason(all, season);
|
||||
|
||||
if (eps.isEmpty()) {
|
||||
throw new SeasonOutOfBoundsException(searchResult.getName(), season, getLastSeason(all));
|
||||
}
|
||||
|
||||
return eps;
|
||||
}
|
||||
|
||||
|
||||
protected Object request(String resource) throws IOException {
|
||||
URL url = new URL("https", host, resource);
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
|
||||
@ -184,45 +216,27 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Episode> getEpisodeList(SearchResult searchResult, int season) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URI getEpisodeListLink(SearchResult searchResult) {
|
||||
return null;
|
||||
return getEpisodeListLink(searchResult, "alle-serien-staffeln");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URI getEpisodeListLink(SearchResult searchResult, int season) {
|
||||
return null;
|
||||
return getEpisodeListLink(searchResult, "season" + season);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Serienjunkies";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getIcon("search.serienjunkies");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasSingleSeasonSupport() {
|
||||
return false;
|
||||
public URI getEpisodeListLink(SearchResult searchResult, String page) {
|
||||
return URI.create(String.format("http://www.serienjunkies.de/%s/%s.html", ((SerienjunkiesSearchResult) searchResult).getLink(), page));
|
||||
}
|
||||
|
||||
|
||||
public static class SerienjunkiesSearchResult extends SearchResult implements Serializable {
|
||||
|
||||
protected int sid;
|
||||
protected String link;
|
||||
protected String mainTitle;
|
||||
protected String germanTitle;
|
||||
|
||||
@ -232,21 +246,27 @@ public class SerienjunkiesClient implements EpisodeListProvider {
|
||||
}
|
||||
|
||||
|
||||
public SerienjunkiesSearchResult(int sid, String mainTitle, String germanTitle) {
|
||||
public SerienjunkiesSearchResult(int sid, String link, String mainTitle, String germanTitle) {
|
||||
this.sid = sid;
|
||||
this.link = link;
|
||||
this.mainTitle = mainTitle;
|
||||
this.germanTitle = germanTitle;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return germanTitle != null ? germanTitle : mainTitle; // prefer german title
|
||||
}
|
||||
|
||||
|
||||
public int getSeriesId() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return germanTitle != null ? germanTitle : mainTitle; // prefer german title
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,7 +226,7 @@ public final class WebRequest {
|
||||
}
|
||||
|
||||
|
||||
public static SSLSocketFactory createIgnoreCertificateSocketFactory() throws GeneralSecurityException {
|
||||
public static SSLSocketFactory createIgnoreCertificateSocketFactory() {
|
||||
// create a trust manager that does not validate certificate chains
|
||||
TrustManager trustAnyCertificate = new X509TrustManager() {
|
||||
|
||||
@ -243,9 +243,13 @@ public final class WebRequest {
|
||||
}
|
||||
};
|
||||
|
||||
SSLContext sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, new TrustManager[] { trustAnyCertificate }, new SecureRandom());
|
||||
return sc.getSocketFactory();
|
||||
try {
|
||||
SSLContext sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, new TrustManager[] { trustAnyCertificate }, new SecureRandom());
|
||||
return sc.getSocketFactory();
|
||||
} catch (GeneralSecurityException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,6 +26,7 @@ public class SerienjunkiesClientTest {
|
||||
|
||||
SerienjunkiesSearchResult first = (SerienjunkiesSearchResult) results.get(0);
|
||||
assertEquals(34, first.getSeriesId());
|
||||
assertEquals("Alias", first.getLink());
|
||||
assertEquals("Alias - Die Agentin", first.getName());
|
||||
assertEquals("Alias", first.getMainTitle());
|
||||
assertEquals("Alias - Die Agentin", first.getGermanTitle());
|
||||
@ -34,7 +35,7 @@ public class SerienjunkiesClientTest {
|
||||
|
||||
@Test
|
||||
public void getEpisodeListAll() throws Exception {
|
||||
List<Episode> list = serienjunkies.getEpisodeList(new SerienjunkiesSearchResult(260, "Grey's Anatomy", null));
|
||||
List<Episode> list = serienjunkies.getEpisodeList(new SerienjunkiesSearchResult(260, "greys-anatomy", "Grey's Anatomy", null));
|
||||
|
||||
// check ordinary episode
|
||||
Episode eps = list.get(0);
|
||||
@ -43,6 +44,7 @@ public class SerienjunkiesClientTest {
|
||||
assertEquals("1", eps.getEpisode().toString());
|
||||
assertEquals("1", eps.getSeason().toString());
|
||||
assertEquals("1", eps.getAbsolute().toString());
|
||||
assertEquals("2005-03-27", eps.airdate().toString());
|
||||
|
||||
// check umlaut in title
|
||||
eps = list.get(2);
|
||||
@ -50,6 +52,7 @@ public class SerienjunkiesClientTest {
|
||||
assertEquals("1", eps.getSeason().toString());
|
||||
assertEquals("3", eps.getEpisode().toString());
|
||||
assertEquals("3", eps.getAbsolute().toString());
|
||||
assertEquals("2005-04-10", eps.airdate().toString());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user