diff --git a/build-data/Discover.groovy b/build-data/Discover.groovy index 8cb7d6d3..178fb184 100755 --- a/build-data/Discover.groovy +++ b/build-data/Discover.groovy @@ -9,22 +9,30 @@ if (recentMoviesFile.exists()) { } } -def toDate = LocalDate.now() -def fromDate = LocalDate.now().minus(Period.ofDays(30)) -def locale = Locale.ENGLISH - -TheMovieDB.discover(fromDate, toDate, locale).each{ m -> +def updateMovieIndex = { m -> if (!recentMoviesIndex.containsKey(m.tmdbId)) { - def i = TheMovieDB.getMovieInfo(m, locale, false) + def i = TheMovieDB.getMovieInfo(m, Locale.ENGLISH, false) if (i.imdbId == null) return def row = [i.id.pad(6), i.imdbId.pad(7), i.released.year as String, i.name] - println row + log.finest "$row" recentMoviesIndex.put(row[0] as int, row) } } + +def to = LocalDate.now() +def from = to.minus(Period.ofDays(30)) +def year = from.year + +log.fine "Discover Recent [$from to $to]" +TheMovieDB.discover(from, to, Locale.ENGLISH).each{ updateMovieIndex(it) } + +log.fine "Discover Best of Year [$year]" +TheMovieDB.discover(year, Locale.ENGLISH).each{ updateMovieIndex(it) } + + recentMoviesIndex.values()*.join('\t').join('\n').saveAs(recentMoviesFile)