* added .nfo creation as scripting example
This commit is contained in:
parent
ad0714c67b
commit
6dfbfd2d35
|
@ -382,14 +382,14 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
|||
}
|
||||
|
||||
|
||||
public SeriesInfo getSeriesInfo(int seriesid, Locale locale) throws Exception {
|
||||
public SeriesInfo getSeriesInfo(TheTVDBSearchResult searchResult, Locale locale) throws Exception {
|
||||
// check cache first
|
||||
SeriesInfo cachedItem = getCache().getData("seriesInfo", seriesid, SeriesInfo.class);
|
||||
SeriesInfo cachedItem = getCache().getData("seriesInfo", searchResult.seriesId, SeriesInfo.class);
|
||||
if (cachedItem != null) {
|
||||
return cachedItem;
|
||||
}
|
||||
|
||||
Document dom = getDocument(getResource(MirrorType.XML, "/api/" + apikey + "/series/" + seriesid + "/" + locale.getLanguage() + ".xml"));
|
||||
Document dom = getDocument(getResource(MirrorType.XML, "/api/" + apikey + "/series/" + searchResult.seriesId + "/" + locale.getLanguage() + ".xml"));
|
||||
|
||||
Node node = selectNode("//Series", dom);
|
||||
Map<SeriesProperty, String> fields = new EnumMap<SeriesProperty, String>(SeriesProperty.class);
|
||||
|
@ -406,7 +406,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
|||
}
|
||||
|
||||
SeriesInfo seriesInfo = new SeriesInfo(fields);
|
||||
getCache().putData("seriesInfo", seriesid, seriesInfo);
|
||||
getCache().putData("seriesInfo", searchResult.seriesId, seriesInfo);
|
||||
return seriesInfo;
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,25 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
|||
|
||||
public List<String> getActors() {
|
||||
// e.g. |Zachary Levi|Adam Baldwin|Yvonne Strzechowski|
|
||||
return asList(get(SeriesProperty.Actors).replaceFirst("^[|]", "").split("[|]"));
|
||||
return split(get(SeriesProperty.Actors));
|
||||
}
|
||||
|
||||
|
||||
public List<String> getGenre() {
|
||||
// e.g. |Comedy|
|
||||
return split(get(SeriesProperty.Genre));
|
||||
}
|
||||
|
||||
|
||||
protected List<String> split(String values) {
|
||||
List<String> items = new ArrayList<String>();
|
||||
for (String it : values.split("[|]")) {
|
||||
it = it.trim();
|
||||
if (it.length() > 0) {
|
||||
items.add(it);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
|
@ -496,12 +514,6 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
|||
}
|
||||
|
||||
|
||||
public List<String> getGenre() {
|
||||
// e.g. |Comedy|
|
||||
return asList(get(SeriesProperty.Genre).replaceFirst("^[|]", "").split("[|]"));
|
||||
}
|
||||
|
||||
|
||||
public int getImdbId() {
|
||||
// e.g. tt0934814
|
||||
return Integer.parseInt(get(SeriesProperty.IMDB_ID).substring(2));
|
||||
|
@ -538,7 +550,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
|||
}
|
||||
|
||||
|
||||
public String getSeriesName() {
|
||||
public String getName() {
|
||||
// e.g. Chuck
|
||||
return get(SeriesProperty.SeriesName);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ public class TheTVDBClientTest {
|
|||
|
||||
@Test
|
||||
public void getSeriesInfo() throws Exception {
|
||||
SeriesInfo it = thetvdb.getSeriesInfo(80348, Locale.ENGLISH);
|
||||
SeriesInfo it = thetvdb.getSeriesInfo(new TheTVDBSearchResult(null, 80348), Locale.ENGLISH);
|
||||
|
||||
assertEquals(80348, it.getId(), 0);
|
||||
assertEquals("Adam Baldwin", it.getActors().get(2));
|
||||
|
|
|
@ -13,14 +13,32 @@ def fetchBanner(outputDir, outputName, series, bannerType, bannerType2, season =
|
|||
println "Banner not found: $outputName"
|
||||
return null
|
||||
}
|
||||
|
||||
println "Fetch $banner.url"
|
||||
|
||||
println "Fetching banner $banner"
|
||||
return banner.url.saveAs(new File(outputDir, outputName + ".jpg"))
|
||||
}
|
||||
|
||||
|
||||
def fetchSeriesBanners(dir, series, seasons) {
|
||||
println "Fetch banners for $series / Season $seasons"
|
||||
def fetchNfo(outputDir, outputName, series) {
|
||||
def info = TheTVDB.getSeriesInfo(series, Locale.ENGLISH)
|
||||
println "Writing nfo $info"
|
||||
|
||||
new File(outputDir, outputName + ".nfo").withWriter{ out ->
|
||||
out.println("Name: $info.name")
|
||||
out.println("IMDb: http://www.imdb.com/title/tt${info.imdbId.pad(7)}")
|
||||
out.println("Actors: ${info.actors.join(', ')}")
|
||||
out.println("Genere: ${info.genre.join(', ')}")
|
||||
out.println("Language: ${info.language.displayName}")
|
||||
out.println("Overview: $info.overview")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def fetchSeriesBannersAndNfo(dir, series, seasons) {
|
||||
println "Fetch nfo and banners for $series / Season $seasons"
|
||||
|
||||
// fetch nfo
|
||||
fetchNfo(dir, series.name, series)
|
||||
|
||||
// fetch series banner, fanart, posters, etc
|
||||
fetchBanner(dir, "folder", series, "poster", "680x1000")
|
||||
|
@ -55,5 +73,5 @@ args.eachMediaFolder() { dir ->
|
|||
return;
|
||||
}
|
||||
|
||||
fetchSeriesBanners(dir, options[0], seasons)
|
||||
fetchSeriesBannersAndNfo(dir, options[0], seasons)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue