Skip to content

Commit

Permalink
fix economist recipe failure
Browse files Browse the repository at this point in the history
  • Loading branch information
cdhigh committed Dec 11, 2024
1 parent de33fcf commit 203ea9d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
Empty file.
4 changes: 4 additions & 0 deletions application/lib/calibre/scraper/qt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
from urlopener import UrlOpener as Browser
WebEngineBrowser = Browser
14 changes: 14 additions & 0 deletions application/lib/calibre/scraper/simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# License: GPL v3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
#使用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
2 changes: 1 addition & 1 deletion application/view/adv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/Chinese/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/readme.developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

# 电子书简要生成流程
Expand Down

0 comments on commit 203ea9d

Please sign in to comment.