1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-15 05:45:05 -05:00
filebot/website/scripts/update-mes.groovy

39 lines
1.3 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'
2013-04-16 13:30:51 -04:00
def mesvalue = tryQuietly { value } ?: '1'
2012-12-06 14:24:25 -05:00
2012-12-07 05:04:29 -05:00
// import myepisodes scraper
2013-08-04 11:19:09 -04:00
include('lib/scraper')
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-04-16 13:30:51 -04:00
def collationKey = { s -> s == null ? '' : s.replaceAll(/^(?i)(The|A)\b/, '').replaceAll(/(?<!\d)\d{4}$/).replaceAll(/\W/).lower() }
2012-12-06 14:24:25 -05:00
2013-10-22 23:44:36 -04:00
args.getFiles().findAll{ it.isVideo() && parseEpisodeNumber(it) && detectSeriesName(it) }.groupBy{ detectSeriesName(it) }.each{ series, files ->
2012-12-07 05:04:29 -05:00
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)
2013-04-16 13:30:51 -04:00
mes.update(show.id, sxe.season, sxe.episode, mesupdate, mesvalue)
2012-12-07 05:04:29 -05:00
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
}
}
}