From 203ea9d45506b37abd1b7fccc9a0fcc4aa2c3fa6 Mon Sep 17 00:00:00 2001 From: cdhigh Date: Wed, 11 Dec 2024 19:40:25 -0300 Subject: [PATCH] fix economist recipe failure --- application/lib/calibre/scraper/__init__.py | 0 application/lib/calibre/scraper/qt.py | 4 ++++ application/lib/calibre/scraper/simple.py | 14 ++++++++++++++ application/view/adv.py | 2 +- docs/Chinese/deployment.md | 1 + tests/readme.developer.md | 2 ++ 6 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 application/lib/calibre/scraper/__init__.py create mode 100644 application/lib/calibre/scraper/qt.py create mode 100644 application/lib/calibre/scraper/simple.py diff --git a/application/lib/calibre/scraper/__init__.py b/application/lib/calibre/scraper/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/application/lib/calibre/scraper/qt.py b/application/lib/calibre/scraper/qt.py new file mode 100644 index 00000000..a23b3d0d --- /dev/null +++ b/application/lib/calibre/scraper/qt.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -*- +from urlopener import UrlOpener as Browser +WebEngineBrowser = Browser diff --git a/application/lib/calibre/scraper/simple.py b/application/lib/calibre/scraper/simple.py new file mode 100644 index 00000000..98c3ffee --- /dev/null +++ b/application/lib/calibre/scraper/simple.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -*- +# License: GPL v3 Copyright: 2022, Kovid Goyal +#使用urlopener模拟calibre的qt WebEngineBrowser +def read_url(storage, url, timeout=60, as_html=True): + from urlopener import UrlOpener + raw_bytes = UrlOpener().open_novisit(url, timeout=timeout).read() + if not as_html: + return raw_bytes + from calibre.ebooks.chardet import xml_to_unicode + return xml_to_unicode(raw_bytes, strip_encoding_pats=True)[0] + +def cleanup_overseers(): + return lambda : 1 diff --git a/application/view/adv.py b/application/view/adv.py index 676bb012..b7c555d6 100644 --- a/application/view/adv.py +++ b/application/view/adv.py @@ -476,7 +476,7 @@ def AdvFwdRoute(): resp = UrlOpener().post(url, data=request.data, headers=inHeaders) headers = dict(resp.headers) headers.pop('Transfer-Encoding', None) #服务器处理分块的头标识 - #headers.pop('Content-Encoding', None) #服务器压缩数据的头标识 + headers.pop('Content-Encoding', None) #服务器压缩数据的头标识,requests已经解压了 return Response(resp.content, status=resp.status_code, headers=headers) except Exception as e: return f"Unexpected error: {str(e)}", 500 diff --git a/docs/Chinese/deployment.md b/docs/Chinese/deployment.md index 2cd92b38..d55e5eb6 100644 --- a/docs/Chinese/deployment.md +++ b/docs/Chinese/deployment.md @@ -292,6 +292,7 @@ sudo nginx -t #test if nginx config file is correct #set gunicorn auto start sudo cp ./tools/nginx/gunicorn.service /usr/lib/systemd/system/gunicorn.service +sudo chmod 644 /usr/lib/systemd/system/gunicorn.service sudo systemctl daemon-reload sudo systemctl start gunicorn sudo systemctl status gunicorn diff --git a/tests/readme.developer.md b/tests/readme.developer.md index d7f6e24a..79a6dd5f 100644 --- a/tests/readme.developer.md +++ b/tests/readme.developer.md @@ -40,6 +40,8 @@ sudo docker login sudo docker push kindleear/kindleear:tag sudo docker push kindleear/kindleear sudo docker load -i kindleear.tar +docker buildx ls +docker buildx rm xname ``` # 电子书简要生成流程