* gracefully ignore missing data
This commit is contained in:
parent
b2e092c697
commit
c3093eb8d1
|
@ -225,7 +225,11 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
|
|
||||||
|
|
||||||
public Locale getLanguage() {
|
public Locale getLanguage() {
|
||||||
|
try {
|
||||||
return new Locale(get(MovieProperty.language));
|
return new Locale(get(MovieProperty.language));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -239,14 +243,22 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getId() {
|
public Integer getId() {
|
||||||
return Integer.parseInt(get(MovieProperty.id));
|
try {
|
||||||
|
return new Integer(get(MovieProperty.id));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getImdbId() {
|
public Integer getImdbId() {
|
||||||
// e.g. tt0379786
|
// e.g. tt0379786
|
||||||
return Integer.parseInt(get(MovieProperty.imdb_id).substring(2));
|
try {
|
||||||
|
return new Integer(get(MovieProperty.imdb_id).substring(2));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -264,13 +276,21 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getVotes() {
|
public Integer getVotes() {
|
||||||
return Integer.parseInt(get(MovieProperty.votes));
|
try {
|
||||||
|
return new Integer(get(MovieProperty.votes));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public double getRating() {
|
public Double getRating() {
|
||||||
return Double.parseDouble(get(MovieProperty.rating));
|
try {
|
||||||
|
return new Double(get(MovieProperty.rating));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -286,8 +306,12 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getRuntime() {
|
public Integer getRuntime() {
|
||||||
return Integer.parseInt(get(MovieProperty.runtime));
|
try {
|
||||||
|
return new Integer(get(MovieProperty.runtime));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -350,7 +374,7 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
try {
|
try {
|
||||||
return new URL(get(ArtworkProperty.url));
|
return new URL(get(ArtworkProperty.url));
|
||||||
} catch (MalformedURLException e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,13 +385,21 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getWidth() {
|
public Integer getWidth() {
|
||||||
return Integer.parseInt(get(ArtworkProperty.width));
|
try {
|
||||||
|
return new Integer(get(ArtworkProperty.width));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getHeight() {
|
public Integer getHeight() {
|
||||||
return Integer.parseInt(get(ArtworkProperty.height));
|
try {
|
||||||
|
return new Integer(get(ArtworkProperty.height));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -460,9 +460,13 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getId() {
|
public Integer getId() {
|
||||||
// e.g. 80348
|
// e.g. 80348
|
||||||
|
try {
|
||||||
return Integer.parseInt(get(SeriesProperty.id));
|
return Integer.parseInt(get(SeriesProperty.id));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -480,12 +484,14 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
|
|
||||||
protected List<String> split(String values) {
|
protected List<String> split(String values) {
|
||||||
List<String> items = new ArrayList<String>();
|
List<String> items = new ArrayList<String>();
|
||||||
|
if (values != null && values.length() > 0) {
|
||||||
for (String it : values.split("[|]")) {
|
for (String it : values.split("[|]")) {
|
||||||
it = it.trim();
|
it = it.trim();
|
||||||
if (it.length() > 0) {
|
if (it.length() > 0) {
|
||||||
items.add(it);
|
items.add(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,15 +520,23 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getImdbId() {
|
public Integer getImdbId() {
|
||||||
// e.g. tt0934814
|
// e.g. tt0934814
|
||||||
|
try {
|
||||||
return Integer.parseInt(get(SeriesProperty.IMDB_ID).substring(2));
|
return Integer.parseInt(get(SeriesProperty.IMDB_ID).substring(2));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Locale getLanguage() {
|
public Locale getLanguage() {
|
||||||
// e.g. en
|
// e.g. en
|
||||||
|
try {
|
||||||
return new Locale(get(SeriesProperty.Language));
|
return new Locale(get(SeriesProperty.Language));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -532,15 +546,23 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public double getRating() {
|
public Double getRating() {
|
||||||
// e.g. 9.0
|
// e.g. 9.0
|
||||||
|
try {
|
||||||
return Double.parseDouble(get(SeriesProperty.Rating));
|
return Double.parseDouble(get(SeriesProperty.Rating));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getRatingCount() {
|
public Integer getRatingCount() {
|
||||||
// e.g. 696
|
// e.g. 696
|
||||||
|
try {
|
||||||
return Integer.parseInt(get(SeriesProperty.RatingCount));
|
return Integer.parseInt(get(SeriesProperty.RatingCount));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -595,7 +617,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public URL getPosterUrl() throws MalformedURLException {
|
public URL getPosterUrl() {
|
||||||
try {
|
try {
|
||||||
return new URL(getBannerMirrorUrl(), get(SeriesProperty.poster));
|
return new URL(getBannerMirrorUrl(), get(SeriesProperty.poster));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// filebot -script "http://filebot.sf.net/scripts/artwork.tmdb.groovy" -trust-script /path/to/media/
|
// filebot -script "http://filebot.sf.net/scripts/artwork.tmdb.groovy" -trust-script /path/to/media/
|
||||||
|
|
||||||
// EXPERIMENTAL // HERE THERE BE DRAGONS
|
// EXPERIMENTAL // HERE THERE BE DRAGONS
|
||||||
if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 802) throw new Exception("Application revision too old")
|
if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 808) throw new Exception("Application revision too old")
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -41,6 +41,11 @@ def fetchMovieArtworkAndNfo(movieDir, movie) {
|
||||||
println "Fetch nfo and artwork for $movie"
|
println "Fetch nfo and artwork for $movie"
|
||||||
def movieInfo = TheMovieDB.getMovieInfo(movie, Locale.ENGLISH)
|
def movieInfo = TheMovieDB.getMovieInfo(movie, Locale.ENGLISH)
|
||||||
|
|
||||||
|
println movieInfo
|
||||||
|
movieInfo.images.each {
|
||||||
|
println "Available artwork: $it.url => $it"
|
||||||
|
}
|
||||||
|
|
||||||
// fetch nfo
|
// fetch nfo
|
||||||
fetchNfo(movieDir['movie.nfo'], movieInfo)
|
fetchNfo(movieDir['movie.nfo'], movieInfo)
|
||||||
|
|
||||||
|
@ -50,7 +55,7 @@ def fetchMovieArtworkAndNfo(movieDir, movie) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def jobs = args.getFolders().findResults { dir ->
|
args.getFolders().each { dir ->
|
||||||
def videos = dir.listFiles{ it.isVideo() }
|
def videos = dir.listFiles{ it.isVideo() }
|
||||||
if (videos.isEmpty()) {
|
if (videos.isEmpty()) {
|
||||||
return null
|
return null
|
||||||
|
@ -66,7 +71,6 @@ def jobs = args.getFolders().findResults { dir ->
|
||||||
// auto-select series
|
// auto-select series
|
||||||
def movie = options.sortBySimilarity(query, { it.name })[0]
|
def movie = options.sortBySimilarity(query, { it.name })[0]
|
||||||
|
|
||||||
return { fetchMovieArtworkAndNfo(dir, movie) }
|
println "$dir => $movie"
|
||||||
|
fetchMovieArtworkAndNfo(dir, movie)
|
||||||
}
|
}
|
||||||
|
|
||||||
parallel(jobs, 10)
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
// filebot -script "http://filebot.sf.net/scripts/artwork.tvdb.groovy" -trust-script /path/to/media/
|
// filebot -script "http://filebot.sf.net/scripts/artwork.tvdb.groovy" -trust-script /path/to/media/
|
||||||
|
|
||||||
// EXPERIMENTAL // HERE THERE BE DRAGONS
|
// EXPERIMENTAL // HERE THERE BE DRAGONS
|
||||||
if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 802) throw new Exception("Application revision too old")
|
if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 808) throw new Exception("Application revision too old")
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch series and season banners for all tv shows. Series name is auto-detected if possible or the folder name is used.
|
* Fetch series and season banners for all tv shows. Series name is auto-detected if possible or the folder name is used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
def fetchBanner(outputFile, series, bannerType, bannerType2, season = null) {
|
def fetchBanner(outputFile, series, bannerType, bannerType2 = null, season = null) {
|
||||||
// select and fetch banner
|
// select and fetch banner
|
||||||
def banner = TheTVDB.getBanner(series, bannerType, bannerType2, season, Locale.ENGLISH, 0)
|
def banner = TheTVDB.getBanner(series, bannerType, bannerType2, season, Locale.ENGLISH, 0)
|
||||||
if (banner == null) {
|
if (banner == null) {
|
||||||
println "Banner not found: $outputFile"
|
println "Banner not found: $outputFile / $bannerType:$bannerType2"
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,9 @@ def fetchBanner(outputFile, series, bannerType, bannerType2, season = null) {
|
||||||
|
|
||||||
|
|
||||||
def fetchNfo(outputFile, series) {
|
def fetchNfo(outputFile, series) {
|
||||||
TheTVDB.getSeriesInfo(series, Locale.ENGLISH).applyXmlTemplate('''<tvshow xmlns:gsp='http://groovy.codehaus.org/2005/gsp'>
|
def info = TheTVDB.getSeriesInfo(series, Locale.ENGLISH)
|
||||||
|
println info
|
||||||
|
info.applyXmlTemplate('''<tvshow xmlns:gsp='http://groovy.codehaus.org/2005/gsp'>
|
||||||
<title>$name</title>
|
<title>$name</title>
|
||||||
<year>${firstAired?.year}</year>
|
<year>${firstAired?.year}</year>
|
||||||
<rating>$rating</rating>
|
<rating>$rating</rating>
|
||||||
|
@ -49,15 +51,19 @@ def fetchNfo(outputFile, series) {
|
||||||
def fetchSeriesBannersAndNfo(seriesDir, seasonDir, series, season) {
|
def fetchSeriesBannersAndNfo(seriesDir, seasonDir, series, season) {
|
||||||
println "Fetch nfo and banners for $series / Season $season"
|
println "Fetch nfo and banners for $series / Season $season"
|
||||||
|
|
||||||
|
TheTVDB.getBannerList(series.seriesId).each {
|
||||||
|
println "Available banner: $it.url => $it"
|
||||||
|
}
|
||||||
|
|
||||||
// fetch nfo
|
// fetch nfo
|
||||||
fetchNfo(seriesDir['tvshow.nfo'], series)
|
fetchNfo(seriesDir['tvshow.nfo'], series)
|
||||||
|
|
||||||
// fetch series banner, fanart, posters, etc
|
// fetch series banner, fanart, posters, etc
|
||||||
fetchBanner(seriesDir['folder.jpg'], series, "poster", "680x1000")
|
["680x1000", null].findResult{ fetchBanner(seriesDir['folder.jpg'], series, "poster", it) }
|
||||||
fetchBanner(seriesDir['banner.jpg'], series, "series", "graphical")
|
["graphical", null].findResult{ fetchBanner(seriesDir['banner.jpg'], series, "series", it) }
|
||||||
|
|
||||||
// fetch highest resolution fanart
|
// fetch highest resolution fanart
|
||||||
["1920x1080", "1280x720"].findResult{ fetchBanner(seriesDir["fanart.jpg"], series, "fanart", it) }
|
["1920x1080", "1280x720", null].findResult{ fetchBanner(seriesDir["fanart.jpg"], series, "fanart", it) }
|
||||||
|
|
||||||
// fetch season banners
|
// fetch season banners
|
||||||
if (seasonDir != seriesDir) {
|
if (seasonDir != seriesDir) {
|
||||||
|
@ -67,7 +73,7 @@ def fetchSeriesBannersAndNfo(seriesDir, seasonDir, series, season) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def jobs = args.getFolders().findResults { dir ->
|
args.getFolders().each { dir ->
|
||||||
def videos = dir.listFiles{ it.isVideo() }
|
def videos = dir.listFiles{ it.isVideo() }
|
||||||
if (videos.isEmpty()) {
|
if (videos.isEmpty()) {
|
||||||
return null
|
return null
|
||||||
|
@ -78,9 +84,9 @@ def jobs = args.getFolders().findResults { dir ->
|
||||||
|
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
query = dir.dir.hasFile{ it.name =~ /Season/ && it.isDirectory() } ? dir.dir.name : dir.name
|
query = dir.dir.hasFile{ it.name =~ /Season/ && it.isDirectory() } ? dir.dir.name : dir.name
|
||||||
println "Failed to detect series name from video files -> Query by $query instead"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println "$dir => Search by $query"
|
||||||
def options = TheTVDB.search(query, Locale.ENGLISH)
|
def options = TheTVDB.search(query, Locale.ENGLISH)
|
||||||
if (options.isEmpty()) {
|
if (options.isEmpty()) {
|
||||||
println "TV Series not found: $query"
|
println "TV Series not found: $query"
|
||||||
|
@ -94,7 +100,6 @@ def jobs = args.getFolders().findResults { dir ->
|
||||||
def seriesDir = [dir.dir, dir].sortBySimilarity(series.name, { it.name })[0]
|
def seriesDir = [dir.dir, dir].sortBySimilarity(series.name, { it.name })[0]
|
||||||
def season = sxe && sxe.season > 0 ? sxe.season : 1
|
def season = sxe && sxe.season > 0 ? sxe.season : 1
|
||||||
|
|
||||||
return { fetchSeriesBannersAndNfo(seriesDir, dir, series, season) }
|
println "$dir => $series"
|
||||||
|
fetchSeriesBannersAndNfo(seriesDir, dir, series, season)
|
||||||
}
|
}
|
||||||
|
|
||||||
parallel(jobs, 10)
|
|
||||||
|
|
Loading…
Reference in New Issue