From 343c5a45b9d3bcb78a3075c98502dc0b087d9f54 Mon Sep 17 00:00:00 2001 From: Craig Hornsby Date: Wed, 18 Apr 2018 08:41:42 -0400 Subject: [PATCH] Fix for index out of range on cvinfo files If the cvinfo had information in an unsupported format, like just 4050-xxxxx then the regular expression sub would cause an end of index exception. Now the regex just looks for 4050-xxxxx, and doesn't really care about the format. https://github.com/evilhero/mylar/issues/1923 --- mylar/librarysync.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mylar/librarysync.py b/mylar/librarysync.py index 437d4d78..2d119104 100755 --- a/mylar/librarysync.py +++ b/mylar/librarysync.py @@ -252,9 +252,11 @@ def libraryScan(dir=None, append=False, ComicID=None, ComicName=None, cron=None, urllink = f.readline() if urllink: - cid = urllink.split('/') - if '4050-' in cid[-2]: - cvinfo_CID = re.sub('4050-', '', cid[-2]).strip() + cid = urllink.strip() + pattern = re.compile(r"^.*?\b(49|4050)-(?P\d{2,})\b.*$", re.I) + match = pattern.match(cid) + if match: + cvinfo_CID = match.group("num") logger.info('CVINFO file located within directory. Attaching everything in directory that is valid to ComicID: ' + str(cvinfo_CID)) #store the location of the cvinfo so it's applied to the correct directory (since we're scanning multile direcorties usually) cvscanned_loc = os.path.dirname(comlocation)