escape strings

This commit is contained in:
j 2024-09-11 22:52:01 +01:00
commit 41edea1862
20 changed files with 74 additions and 74 deletions

View file

@ -201,7 +201,7 @@ def parse_path(path, directory_key='director'):
# '_.foo$' or '_ (' is '?'
string = re.sub(re.compile(r'_(?=(\.\w+$| \())', re.U), '?', string)
# ' _..._ ' is '<...>'
string = re.sub('(?<= )_(.+)_(?= )', '<\g<1>>', string)
string = re.sub(r'(?<= )_(.+)_(?= )', r'<\g<1>>', string)
# 'foo_bar' or 'foo _ bar' is '/'
string = re.sub(re.compile(r'(?<=\w)_(?=\w)', re.U), '/', string)
string = re.sub(' _ ', ' / ', string)
@ -243,7 +243,7 @@ def parse_path(path, directory_key='director'):
data['year'] = match.group(0)[2:-1] if match else None
file_title = re.sub('[/:]', '_', data['title'])
# (remove title from beginning of filename if the rest contains a dot)
file = re.sub('^' + re.escape(file_title) + '(?=.*\.)', '', file)
file = re.sub(r'^' + re.escape(file_title) + r'(?=.*\.)', '', file)
# (split by nospace+dot+word, but remove spaces preceding extension)
parts = re.split(r'(?<!\s)\.(?=\w)', re.sub(r'\s+(?=.\w+$)', '', file))
title, parts, extension = [