From 7436a7077a702dd6c6533acb80e4f2523b1cf06e Mon Sep 17 00:00:00 2001 From: waynethomas69 Date: Thu, 11 Jul 2019 19:34:55 +1200 Subject: [PATCH] Update episode.py Allow for double-digit Season numbers when season and episode are separated by "x" (e.g. 10x01) --- resources/lib/items/episode.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/lib/items/episode.py b/resources/lib/items/episode.py index bfd581c..19b4552 100644 --- a/resources/lib/items/episode.py +++ b/resources/lib/items/episode.py @@ -55,7 +55,7 @@ def add_to_library(self): # Rename episode if metadata is available self.rename_using_metadata() # Don't add episodes that don't have episode id in name - if not re.match('.*[0-9]x[0-9].*|.*[Ss][0-9].*[Ee][0-9].*', self.clean_title): + if not re.match('.*[0-9]+x[0-9].*|.*[Ss][0-9].*[Ee][0-9].*', self.clean_title): utils.log_msg('No episode number detected for {0}. Not adding to library...'\ .format(self.clean_title), xbmc.LOGNOTICE) return @@ -67,7 +67,7 @@ def add_to_library(self): # Link tvshow.nfo and artwork now, if self.metadata_dir exists files = os.listdir(self.metadata_dir) for fname in files: - if not (re.match('.*[0-9]x[0-9].*|.*[Ss][0-9].*[Ee][0-9].*', fname) + if not (re.match('.*[0-9]+x[0-9].*|.*[Ss][0-9].*[Ee][0-9].*', fname) or '.strm' in fname): utils.fs.softlink_file( os.path.join(self.metadata_dir, fname), @@ -120,13 +120,13 @@ def create_metadata_item(self): if not os.path.exists(strm_path): # Rename file if old nfo file has episode id old_renamed = glob( - os.path.join(show_dir, '*[0-9]x[0-9]* - {0}.nfo'.format(clean_title_no_0x0)) + os.path.join(show_dir, '*[0-9]+x[0-9]* - {0}.nfo'.format(clean_title_no_0x0)) ) if old_renamed: # Prepend title with epid if so epid = old_renamed[0].split('/')[-1].replace(clean_title_no_0x0 + '.nfo', '') new_title = epid + self.title.replace('-0x0', '') - elif not re.match('.*[0-9]x[0-9].*|.*[Ss][0-9]+[Ee][0-9].*', self.clean_title): + elif not re.match('.*[0-9]+x[0-9].*|.*[Ss][0-9]+[Ee][0-9].*', self.clean_title): # Otherwise, append -0x0 if title doesn't already have valid episode id new_title = self.title + '-0x0' else: @@ -152,7 +152,7 @@ def read_metadata_item(self): if os.path.isdir(show_dir): # Rename item if old nfo file has episode id old_renamed = glob( - os.path.join(show_dir, '*[0-9]x[0-9]* - {0}.nfo'.format(clean_title_no_0x0)) + os.path.join(show_dir, '*[0-9]+x[0-9]* - {0}.nfo'.format(clean_title_no_0x0)) ) if old_renamed: # Prepend title with epid if so