get_screenshot()兼容旧版本path参数

This commit is contained in:
g1879 2023-10-09 22:59:41 +08:00
parent 1015d6c076
commit 9690a57502
2 changed files with 19 additions and 14 deletions

View File

@ -881,13 +881,15 @@ class ChromiumBase(BasePage):
pic_type = 'jpeg' if as_base64 == 'jpg' else as_base64 pic_type = 'jpeg' if as_base64 == 'jpg' else as_base64
else: else:
if not name: path = str(path).rstrip('\\/') if path else '.'
name = f'{self.title}.jpg' if not path.endswith(('.jpg', '.jpeg', '.png', '.webp')):
if not path: if not name:
path = '.' name = f'{self.title}.jpg'
if not name.endswith(('.jpg', '.jpeg', '.png', '.webp')): elif not name.endswith(('.jpg', '.jpeg', '.png', '.webp')):
name = f'{name}.jpg' name = f'{name}.jpg'
path = get_usable_path(f'{path}{sep}{name}') path = f'{path}{sep}{name}'
path = get_usable_path(path)
pic_type = path.suffix.lower() pic_type = path.suffix.lower()
pic_type = 'jpeg' if pic_type == '.jpg' else pic_type[1:] pic_type = 'jpeg' if pic_type == '.jpg' else pic_type[1:]

View File

@ -535,13 +535,16 @@ class ChromiumFrame(ChromiumBase):
pic_type = 'jpeg' if as_base64 == 'jpg' else as_base64 pic_type = 'jpeg' if as_base64 == 'jpg' else as_base64
else: else:
if not path: path = str(path).rstrip('\\/') if path else '.'
path = '.' if path and path.endswith(('.jpg', '.jpeg', '.png', '.webp')):
if not name: pic_type = path.rsplit('.', 1)[-1]
name = f'{self.title}.jpg'
if not name.endswith(('.jpg', '.jpeg', '.png', '.webp')): elif name and name.endswith(('.jpg', '.jpeg', '.png', '.webp')):
name = f'{name}.jpg' pic_type = name.rsplit('.', 1)[-1]
pic_type = name.split('.')[-1]
else:
pic_type = 'jpeg'
if pic_type == 'jpg': if pic_type == 'jpg':
pic_type = 'jpeg' pic_type = 'jpeg'