diff --git a/generate-bundle.py b/generate-bundle.py index 36ddfd4..8620db0 100644 --- a/generate-bundle.py +++ b/generate-bundle.py @@ -14,10 +14,6 @@ import PyInstaller.__main__ -os.mkdir("dist") -flag = ["-F", "main.py", "--optimize", "2"] -if platform.system() != 'Windows': - flag.append("--strip") -PyInstaller.__main__.run(flag) +PyInstaller.__main__.run(["main.spec"]) diff --git a/main.py b/main.py index b7cd002..9a6f66a 100644 --- a/main.py +++ b/main.py @@ -6,10 +6,10 @@ def print_result(result): - print(result.title) - print(result.summary) - print(result.url) - print("====================") + print(f"\033[1;32m标题: \033[0m{result.title}") + print(f"\033[1;34m简介: \033[0m{result.summary}") + print(f"\033[1;36mURL: \033[0m{result.url}") + print("\033[1;33m====================\033[0m") print() diff --git a/main.spec b/main.spec new file mode 100644 index 0000000..26ecc5e --- /dev/null +++ b/main.spec @@ -0,0 +1,45 @@ +# -*- mode: python ; coding: utf-8 -*- +import platform + + +a = Analysis( + ['main.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, + optimize=2, +) +pyz = PYZ(a.pure) + +if platform.system() != 'Windows': + strip = True + a.exclude_system_libraries() +else: + strip = False + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [('O', None, 'OPTION'), ('O', None, 'OPTION')], + name='main', + debug=False, + bootloader_ignore_signals=False, + strip=strip, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) diff --git a/plugin/engine/bing.py b/plugin/engine/bing.py index 4758f3d..50d21d8 100644 --- a/plugin/engine/bing.py +++ b/plugin/engine/bing.py @@ -1,13 +1,10 @@ import typing -from plugin.engine.base import SearchEngine, SearchResult +from plugin.engine.base import SearchResult import re import requests from lxml.html import etree -from plugin.utils.translate import translate, EN - - class Bing: def get_bing_url(self, keywords): @@ -17,7 +14,7 @@ def get_bing_url(self, keywords): return bing_url def search(self, keywords, site) -> typing.List[SearchResult]: - keywords = f'"{translate(keywords)}" 插件 site:{site}' + keywords = f'"{keywords}" 插件 site:{site}' url = self.get_bing_url(keywords) result: typing.List[SearchResult] = [] headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0',