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
else:
if not name:
name = f'{self.title}.jpg'
if not path:
path = '.'
if not name.endswith(('.jpg', '.jpeg', '.png', '.webp')):
name = f'{name}.jpg'
path = get_usable_path(f'{path}{sep}{name}')
path = str(path).rstrip('\\/') if path else '.'
if not path.endswith(('.jpg', '.jpeg', '.png', '.webp')):
if not name:
name = f'{self.title}.jpg'
elif not name.endswith(('.jpg', '.jpeg', '.png', '.webp')):
name = f'{name}.jpg'
path = f'{path}{sep}{name}'
path = get_usable_path(path)
pic_type = path.suffix.lower()
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
else:
if not path:
path = '.'
if not name:
name = f'{self.title}.jpg'
if not name.endswith(('.jpg', '.jpeg', '.png', '.webp')):
name = f'{name}.jpg'
pic_type = name.split('.')[-1]
path = str(path).rstrip('\\/') if path else '.'
if path and path.endswith(('.jpg', '.jpeg', '.png', '.webp')):
pic_type = path.rsplit('.', 1)[-1]
elif name and name.endswith(('.jpg', '.jpeg', '.png', '.webp')):
pic_type = name.rsplit('.', 1)[-1]
else:
pic_type = 'jpeg'
if pic_type == 'jpg':
pic_type = 'jpeg'