aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiederick de Vries <diederick@diederickdevries.net>2019-04-15 07:28:16 +0200
committerDiederick de Vries <diederick@diederickdevries.net>2019-04-15 07:28:16 +0200
commit8174417b422e7bf18c638a65aad4af6a5e34de65 (patch)
treef86bbb5a862113ef6aed9c23bbde5c4246ba94a1
parente68af60360705c17d645546946daeaca9655bce4 (diff)
parentb1fb06f72d4fffdd22f9adea5c9487ff0d5255b4 (diff)
downloadaftercare-master.tar.gz
aftercare-master.tar.bz2
aftercare-master.zip
Merge branch 'master' of bender:/srv/git/aftercareHEADmaster
-rw-r--r--aftercare.groovy26
-rw-r--r--example.conf4
2 files changed, 13 insertions, 17 deletions
diff --git a/aftercare.groovy b/aftercare.groovy
index 21db104..d9226c0 100644
--- a/aftercare.groovy
+++ b/aftercare.groovy
@@ -95,7 +95,7 @@ class Aftercare {
95 [ 95 [
96 original: file.getCanonicalPath(), 96 original: file.getCanonicalPath(),
97 series: findEpisodeName(file.name, se), 97 series: findEpisodeName(file.name, se),
98 season: se.substring(1,3) as Integer, 98 season: findEpisodeNumber(se) as Integer,
99 episode: se.toUpperCase(), 99 episode: se.toUpperCase(),
100 ext: file.name.substring(file.name.lastIndexOf('.') + 1), 100 ext: file.name.substring(file.name.lastIndexOf('.') + 1),
101 path: file.getCanonicalPath().substring (0, file.getCanonicalPath().lastIndexOf('/')) 101 path: file.getCanonicalPath().substring (0, file.getCanonicalPath().lastIndexOf('/'))
@@ -136,25 +136,21 @@ class Aftercare {
136 } 136 }
137 log.info "Finished" 137 log.info "Finished"
138 } 138 }
139 139
140 private String capitalize(String s) { 140 private String findEpisodeNumber(String s) {
141 def c = [], t = "" 141 return s.toLowerCase().startsWith('s') ? s.substring(1,3) : s.substring(0,2)
142
143 s.tokenize(' ').each { word ->
144 c << word.capitalize()
145 }
146
147 c.each { word ->
148 t = t + " " + word
149 }
150 return t.trim()
151 } 142 }
152 143
153 private String findEpisodeName(String s, String se) { 144 private String findEpisodeName(String s, String se) {
154 this.capitalize(s.substring(0, s.indexOf(se)) 145
146 s.substring(0, s.indexOf(se))
155 .replaceAll("\\.", "\\ ") 147 .replaceAll("\\.", "\\ ")
156 .replaceAll("'", "") 148 .replaceAll("'", "")
157 .trim()) 149 .replaceAll("_", " ")
150 .trim()
151 .split(' ')
152 .collect { it.capitalize() }
153 .join(' ')
158 } 154 }
159} 155}
160 156
diff --git a/example.conf b/example.conf
index a658e52..2b2c7f6 100644
--- a/example.conf
+++ b/example.conf
@@ -9,5 +9,5 @@ chmod = "644"
9 9
10dry_run = true 10dry_run = true
11 11
12allowed = ['mkv', 'mp4', 'mpg', 'avi'] 12allowed = ['mkv', 'mp4', 'mpg', 'avi']
13nrs = "[Ss]?[0-9]{1,2}[EeXx][0-9]{1,2}" 13epsnrs = "[Ss]?[0-9]{1,2}[EeXx][0-9]{1,2}"