1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-25 17:28:51 -05:00
filebot/website/scripts/update-mes.groovy

38 lines
1.2 KiB
Groovy
Raw Normal View History

2012-12-07 05:04:29 -05:00
// filebot -script fn:update-mes "X:/path/to/episodes" --def login=user:pwd addshows=y tick=acquired
def mesacc = login.split(':')
def mesadd = tryQuietly{ addshows.toBoolean() }
def mesupdate = tryQuietly { tick } ?: 'acquired'
2012-12-06 14:24:25 -05:00
2012-12-07 05:04:29 -05:00
// import myepisodes scraper
include('fn:lib/ws')
2012-12-06 14:24:25 -05:00
def mes = MyEpisodes(mesacc[0], mesacc[1])
def myshows = mes.getShowList()
2012-12-07 05:04:29 -05:00
// series name => series key (e.g. Doctor Who (2005) => doctorwho)
2013-03-13 11:48:13 -04:00
def collationKey = { s -> s == null ? '' : s.replaceAll(/\W/).replaceAll(/(?<!\d)\d{4}$/).lower() }
2012-12-06 14:24:25 -05:00
2012-12-07 05:04:29 -05:00
args.getFiles{ it.isVideo() && parseEpisodeNumber(it) && detectSeriesName(it) }.groupBy{ detectSeriesName(it) }.each{ series, files ->
def show = myshows.find{ collationKey(it.name) == collationKey(series) }
if (show == null && mesadd) {
show = mes.getShows().find{ collationKey(it.name) == collationKey(series) }
if (show == null) {
println "[failure] '$series' not found"
return
2012-12-06 14:24:25 -05:00
}
2012-12-07 05:04:29 -05:00
mes.addShow(show.id)
println "[added] $show.name"
}
files.each{
if (show != null) {
2012-12-06 14:24:25 -05:00
def sxe = parseEpisodeNumber(it)
2012-12-07 05:04:29 -05:00
mes.update(show.id, sxe.season, sxe.episode, mesupdate)
println "[$mesupdate] $show.name $sxe [$it.name]"
} else {
println "[failure] '$series' has not been added [$it.name]"
2012-12-06 14:24:25 -05:00
}
}
}