优化图片文件名处理,修复URL处理逻辑以支持去除引号和空格
This commit is contained in:
		| @@ -33,6 +33,8 @@ def choose_input_file(): | ||||
|         input_file_entry.insert(0, file_path) | ||||
|  | ||||
| def clean_filename(url): | ||||
|     #print("origin: "+url) | ||||
|      | ||||
|     try: | ||||
|         # 首先检查URL是否有常见的图片扩展名 | ||||
|         image_extensions = ('.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp') | ||||
| @@ -45,6 +47,10 @@ def clean_filename(url): | ||||
|         if fd_id: | ||||
|             return f"{fd_id.group(1)}.jpg" | ||||
|          | ||||
|  | ||||
|  | ||||
|  | ||||
|          | ||||
|         # 如果既没有扩展名也没有fdId,使用时间戳 | ||||
|         return f"image_{int(time.time())}.jpg" | ||||
|     except: | ||||
| @@ -79,7 +85,10 @@ def download_images(): | ||||
|         if not url.startswith(('http://', 'https://')): | ||||
|             if 'www.soujianzhu.cn' not in url: | ||||
|                 url = 'https://www.soujianzhu.cn' + url | ||||
|         if '"' in url: | ||||
|             url = url.split(' ')[0] | ||||
|              | ||||
|             url=url.strip() | ||||
|         try: | ||||
|             response = requests.get(url, headers=headers, timeout=30) | ||||
|             if response.status_code == 200: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user