@@ -4,6 +4,7 @@ import grails.transaction.NotTransactional
44import grails.transaction.Transactional
55
66import java.util.regex.Matcher
7+ import java.util.regex.Pattern
78
89@Transactional
910class BulkCreateService {
@@ -35,20 +36,21 @@ class BulkCreateService {
3536
3637
3738 def movieRegex = regexConfig?. movies ?: STD_MOVIE_REGEX
39+ def movieRegexList = movieRegex instanceof List ? movieRegex : [movieRegex]
3840 def tvShowRegex = regexConfig?. shows ?: STD_TVSHOW_REGEX
3941 def tvShowRegexList = tvShowRegex instanceof List ? tvShowRegex : [tvShowRegex]
4042
4143 def result = []
4244
4345 files. each { file ->
44- def fileResult = matchSingleFile(file, movieRegex , tvShowRegexList)
46+ def fileResult = matchSingleFile(file, movieRegexList , tvShowRegexList)
4547 result. add(fileResult)
4648 }
4749
4850 return result
4951 }
5052
51- private matchSingleFile (file , movieRegex , List tvShowRegexList ) {
53+ private matchSingleFile (file , List< Pattern > movieRegexList , List< Pattern > tvShowRegexList ) {
5254 def fileResult = [file : file. path]
5355 def foundMatch = false
5456
@@ -67,12 +69,19 @@ class BulkCreateService {
6769 return fileResult
6870 }
6971
70- def movieMatcher = fileName =~ ' (?i)' + movieRegex
71- if (movieMatcher. matches()) {
72- matchMovieFromFile(movieMatcher, fileResult, movieRegex)
73- foundMatch = true
74- return fileResult
75- }
72+ foundMatch = movieRegexList. any { movieRegex ->
73+ def movieMatcher = fileName =~ ' (?i)' + movieRegex
74+
75+ if (movieMatcher. matches()) {
76+ matchMovieFromFile(movieMatcher, fileResult, movieRegex)
77+ return true
78+ return fileResult
79+ }
80+ }
81+
82+ if (foundMatch) {
83+ return fileResult
84+ }
7685
7786 fileResult. status = MATCHER_STATUS . NO_MATCH
7887 fileResult. message = ' No match found'
0 commit comments