* fix SerienJunkies NPE problems

This commit is contained in:
Reinhard Pointner 2012-10-25 16:20:50 +00:00
parent bfe4add9ab
commit aa9cccc285
2 changed files with 15 additions and 9 deletions

View File

@ -130,10 +130,15 @@ public class SerienjunkiesClient extends AbstractEpisodeListProvider {
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(seriesName.trim(), series.getStartDate(), season, episode, title.trim(), i + 1, null, airdate));
String title = (String) obj.get("original");
String german = (String) obj.get("german");
if (title == null || (Locale.GERMAN.equals(locale) && german != null)) {
title = german;
}
episodes.add(new Episode(seriesName, series.getStartDate(), season, episode, title, i + 1, null, airdate));
}
// make sure episodes are in ordered correctly

View File

@ -5,14 +5,15 @@ package net.sourceforge.filebot.web;
import static org.junit.Assert.*;
import java.util.List;
import java.util.Locale;
import net.sf.ehcache.CacheManager;
import net.sourceforge.filebot.web.SerienjunkiesClient.SerienjunkiesSearchResult;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import net.sf.ehcache.CacheManager;
import net.sourceforge.filebot.web.SerienjunkiesClient.SerienjunkiesSearchResult;
public class SerienjunkiesClientTest {
@ -36,7 +37,7 @@ public class SerienjunkiesClientTest {
@Test
public void getEpisodeListAll() throws Exception {
List<Episode> list = serienjunkies.getEpisodeList(new SerienjunkiesSearchResult(260, "greys-anatomy", "Grey's Anatomy", null, null));
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);