* improve the update-mes script

This commit is contained in:
Reinhard Pointner 2012-12-07 10:04:29 +00:00
parent 88a34527c8
commit 042d1f99db
3 changed files with 33 additions and 23 deletions

View File

@ -181,6 +181,8 @@
<li>Extract files from multi-volume rar archives</li>
<li>Fetch artwork and create nfo files for TV shows or movies</li>
<li>Export your media files including media info as CSV text file</li>
<li>Transfer files from and to any server via FTP/SCP/SFTP and run commands via SSH</li>
<li>Update your XBMC or Plex library and MyEpisodes.com account</li>
... and more!
</ul>
<p>Setting up a <strong>fully automated media center</strong> extract archives, organize tv shows and movies, download subtitles, fetch artwork and metadata, update XBMC with µTorrent and FileBot it's <a href="http://filebot.sourceforge.net/forums/viewtopic.php?f=4&amp;t=215#p1561">that</a> easy!</p>

View File

@ -38,17 +38,17 @@ class MyEpisodesScraper {
}
def getShows = {
def shows = cache.get("MyEpisodes.Shows")
def shows = cache.get('MyEpisodes.Shows')
if (shows == null) {
shows = ['other', 'A'..'Z'].flatten().findResults{ section ->
get("http://myepisodes.com/shows.php?list=${section}").select('a').findResults{ a ->
try {
return [id:a.absUrl('href').match(/showid=(\d+)/).toInteger(), name:a.text()]
return [id:a.absUrl('href').match(/showid=(\d+)/).toInteger(), name:a.text().trim()]
} catch(e) {
return null
}
}
}.flatten()
}.flatten().sort{ it.name }
cache.put('MyEpisodes.Shows', shows)
}
return shows
@ -57,7 +57,7 @@ class MyEpisodesScraper {
def getShowList = {
get("http://www.myepisodes.com/shows.php?type=manage").select('option').findResults{ option ->
try {
return [id:option.attr('value').toInteger(), name:option.text()]
return [id:option.attr('value').toInteger(), name:option.text().trim()]
} catch(e) {
return null
}
@ -68,7 +68,7 @@ class MyEpisodesScraper {
get("http://myepisodes.com/views.php?type=manageshow&mode=add&showid=${showid}")
}
def update = { showid, season, episode, tick = 'acquired', value = '0'->
def update = { showid, season, episode, tick = 'acquired', value = '0' ->
get("http://myepisodes.com/myshows.php?action=Update&showid=${showid}&season=${season}&episode=${episode}&${tick}=${value}")
}

View File

@ -1,29 +1,37 @@
include('lib/ws')
// filebot -script fn:update-mes "X:/path/to/episodes" --def login=user:pwd addshows=y tick=acquired
def mesacc = myepisodes.split(':')
def mescheck = tryQuietly { tick } ?: 'acquired'
def mesacc = login.split(':')
def mesadd = tryQuietly{ addshows.toBoolean() }
def mesupdate = tryQuietly { tick } ?: 'acquired'
// import myepisodes scraper
include('lib/ws')
def mes = MyEpisodes(mesacc[0], mesacc[1])
def myshows = mes.getShowList()
def matches = { s1, s2 ->
def norm = { s -> s.replaceAll(/\W/, '').toLowerCase() }
return norm(s1) == norm(s2)
}
// series name => series key (e.g. Doctor Who (2005) => doctorwho)
def collationKey = { s -> s.replaceAll(/\W/).replaceAll(/(?<!\d)\d{4}$/).lower() }
args.getFiles{ it.isVideo() && parseEpisodeNumber(it) }.groupBy{ detectSeriesName(it) }.each{ series, files ->
def show = myshows.find{ matches(it.name, series) } ?: mes.getShows().find{ matches(it.name, series) }
if (show != null) {
if (!myshows.contains(show)) {
mes.addShow(show.id)
println "[added] $show.name"
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
}
files.each{
mes.addShow(show.id)
println "[added] $show.name"
}
files.each{
if (show != null) {
def sxe = parseEpisodeNumber(it)
mes.update(show.id, sxe.season, sxe.episode, mescheck)
println "[$mescheck] $series $sxe [$it.name]"
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]"
}
} else {
println "[failure] '$series' not found"
}
}