2019-05-01 06:14:42 -04:00
|
|
|
#!/usr/bin/env filebot -script
|
|
|
|
|
|
|
|
import static org.apache.commons.io.FileUtils.*
|
|
|
|
|
|
|
|
|
|
|
|
def originals = _args.outputPath.resolve "images/thetvdb/original/poster"
|
|
|
|
def thumbs = _args.outputPath.resolve "images/thetvdb/thumb/poster"
|
|
|
|
|
|
|
|
originals.mkdirs()
|
|
|
|
thumbs.mkdirs()
|
|
|
|
|
|
|
|
|
|
|
|
void ls(f) {
|
|
|
|
println "${f} (${byteCountToDisplaySize(f.length())})"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def tvdbEntries = MediaDetection.seriesIndex.object as Set
|
|
|
|
|
|
|
|
|
2019-05-01 06:33:35 -04:00
|
|
|
def index = []
|
2019-05-01 06:14:42 -04:00
|
|
|
|
|
|
|
|
|
|
|
tvdbEntries.each{
|
|
|
|
println "[$it.id] $it.name"
|
2019-05-01 06:33:35 -04:00
|
|
|
|
|
|
|
def original = originals.resolve "${it.id}.jpg"
|
|
|
|
def thumb = thumbs.resolve "${it.id}.png"
|
|
|
|
|
|
|
|
if (original.exists() && thumb.exists()) {
|
|
|
|
index << it
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-05-01 06:14:42 -04:00
|
|
|
def artwork = TheTVDB.getArtwork it.id, 'poster', Locale.ENGLISH
|
2019-05-01 06:33:35 -04:00
|
|
|
if (!artwork) {
|
|
|
|
sleep 1000
|
|
|
|
return
|
|
|
|
}
|
2019-05-01 06:14:42 -04:00
|
|
|
|
2019-05-01 06:33:35 -04:00
|
|
|
if (!original.exists()) {
|
|
|
|
sleep 2000
|
|
|
|
artwork[0].url.saveAs original
|
|
|
|
ls original
|
|
|
|
}
|
2019-05-01 06:14:42 -04:00
|
|
|
|
2019-05-01 06:33:35 -04:00
|
|
|
if (!thumb.exists()) {
|
2019-05-01 06:14:42 -04:00
|
|
|
execute '/usr/local/bin/convert', original, '-strip', '-thumbnail', '48x48>', 'PNG8:' + thumb
|
|
|
|
ls thumb
|
|
|
|
}
|
2019-05-01 06:33:35 -04:00
|
|
|
|
|
|
|
index << it
|
2019-05-01 06:14:42 -04:00
|
|
|
}
|
2019-05-01 06:33:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
def indexFile = index.toSorted().join('\n').saveAs thumbs.resolve('index.txt')
|
|
|
|
execute '/usr/local/bin/xz', indexFile, '--force'
|
|
|
|
|
|
|
|
println "Index: ${index.size()}"
|