diff --git a/source/split_mkv/changelog.md b/source/split_mkv/changelog.md
index 7cddd2cfb..a9854ac97 100644
--- a/source/split_mkv/changelog.md
+++ b/source/split_mkv/changelog.md
@@ -1,4 +1,6 @@
+**0.0.7**
+- add seriest title to season subdirectory
**0.0.6**
- create season subdirectory
diff --git a/source/split_mkv/info.json b/source/split_mkv/info.json
index 0a7a7f629..448c8029c 100644
--- a/source/split_mkv/info.json
+++ b/source/split_mkv/info.json
@@ -15,5 +15,5 @@
"on_worker_process": 0
},
"tags": "MKV,ffmpeg,library file test",
- "version": "0.0.6"
+ "version": "0.0.7"
}
diff --git a/source/split_mkv/plugin.py b/source/split_mkv/plugin.py
index 686e02a8f..929be6705 100644
--- a/source/split_mkv/plugin.py
+++ b/source/split_mkv/plugin.py
@@ -229,6 +229,7 @@ def on_postprocessor_task_results(data):
# move files from temp dir in cache to destination dir
logger.info("dest files: '{}'".format(data.get('destination_files')))
srcpathbase = data.get('source_data')['basename']
+ srcpathbase_no_ext = os.path.splitext(srcpathbase)[0]
if data.get('library_id'):
settings = Settings(library_id=data.get('library_id'))
@@ -258,15 +259,27 @@ def on_postprocessor_task_results(data):
# get season number for new directory if plugin configured for that option
if season_dir:
match = re.search(r'.*S(\d+)[ -]*E\d+.*$', srcpathbase)
- if match:
+ match2 = re.search(r'(^.*)S\d+[ -]*E\d+-E*\d+(.*$)', srcpathbase_no_ext)
+
+ if match and match2:
season = match.group(1)
- dest_dir += 'Season ' + season + '/'
- try:
- os.makedirs(dest_dir, mode=0o777)
- except FileExistsError:
- logger.info("Directory '{}' already exists - placing split files there".format(dest_dir))
+ st=match2.group(1) + match2.group(2)
+ st=re.search(r'^\s*(.*$)\s*$', st)
+ logger.debug("Season: '{}', Series Title: '{}'".format(season, st))
+ if st:
+ st = st.group(1)
+ else:
+ st = "title doesn't match pattern"
+ if st != "title doesn't match pattern":
+ dest_dir += st + ' - ' + 'Season ' + season + '/'
+ try:
+ os.makedirs(dest_dir, mode=0o777)
+ except FileExistsError:
+ logger.info("Directory '{}' already exists - placing split files there".format(dest_dir))
+ else:
+ logger.info("Sseries title doesn't match pattern - leaving split files in same directory as multiepisode file")
else:
- logger.info("could not identify season number - leaving split files in same directory as multiepisode file")
+ logger.info("could not identify season number & / or series title - leaving split files in same directory as multiepisode file")
logger.debug("dest_file: '{}', dest_dir: '{}'".format(dest_file, dest_dir))