Skip to content

Commit edecc0d

Browse files
author
RSSHub-Py
committed
🎯 更新 EMagazine 路由和部署配置\n- 修复静态文件加载问题\n- 优化 EMagazine 爬虫,支持 EPUB 链接\n- 更新 Vercel 部署配置\n- 更新 Python 版本和依赖
1 parent 2138da3 commit edecc0d

File tree

8 files changed

+83
-77
lines changed

8 files changed

+83
-77
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 使用官方的 Python 镜像作为基础镜像
2-
FROM python:3.8-slim
2+
FROM python:3.12.3-slim
33

44
# 设置工作目录
55
WORKDIR /app

Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ certifi = "==2021.10.8"
1818
charset-normalizer = "==2.0.9"
1919
click = "==8.0.3"
2020
colorama = "==0.4.4"
21-
cssselect = "==1.1.0"
21+
cssselect = "==1.2.0"
2222
executing = "==0.8.2"
2323
feedparser = "==6.0.8"
2424
flask = "==2.0.2"
@@ -33,7 +33,7 @@ idna = "==3.3"
3333
itsdangerous = "==2.0.1"
3434
jinja2 = "==3.0.3"
3535
markupsafe = "==2.0.1"
36-
parsel = "==1.6.0"
36+
parsel = "==1.8.1"
3737
pyppeteer = "==1.0.2"
3838
pygments = "==2.11.1"
3939
python-dotenv = "==0.19.2"

Pipfile.lock

Lines changed: 24 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ Create docker container: `docker run -dt --name pyrsshub -p 5000:5000 hillerliao
6262

6363
## Requirements
6464

65-
- Python 3.8
65+
- Python 3.12.3

main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@
88
from rsshub import create_app
99

1010
app = create_app('production')
11+
12+
# Standard WSGI application for Vercel
13+
application = app
14+
15+
# For local development
16+
if __name__ == '__main__':
17+
app.run(debug=True)

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ arrow==1.2.2
22
beautifulsoup4==4.11.1
33
Bootstrap_Flask==1.8.0
44
click==8.0.3
5+
cssselect==1.2.0
56
feedparser==6.0.8
67
Flask==2.0.2
8+
Werkzeug==2.0.3
79
Flask_Analytics==0.6.0
810
Flask_Caching==2.0.2
911
Flask_DebugToolbar==0.11.0
1012
Flask_Moment==1.0.2
1113
icecream==2.1.1
1214
Jinja2==3.0.3
13-
parsel==1.6.0
15+
parsel==1.8.1
1416
ptpython==3.0.31
1517
pyjsparser==2.7.1
1618
pyppeteer==2.0.0

rsshub/spiders/emagazine/magazine.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,35 @@ def parse(entry):
1111
item = {}
1212
item['title'] = entry.find('title').text if entry.find('title') else 'No Title'
1313

14-
# 获取下载链接
15-
acquisition_link = entry.find('link', rel='http://opds-spec.org/acquisition')
16-
if acquisition_link:
17-
item['link'] = domain + acquisition_link.get('href', '')
18-
else:
19-
item['link'] = ''
14+
# 获取下载链接 - 优先寻找 EPUB 格式的链接
15+
epub_link = None
16+
17+
# 查找所有下载链接
18+
acquisition_links = entry.find_all('link', rel='http://opds-spec.org/acquisition')
19+
for link in acquisition_links:
20+
href = link.get('href', '')
21+
# 如果链接以 /epub/ 结尾,则使用这个链接
22+
if href.endswith('/epub/'):
23+
epub_link = domain + href
24+
break
25+
# 或者如果链接包含 epub 关键字
26+
elif 'epub' in href.lower():
27+
epub_link = domain + href
28+
29+
# 如果没找到 EPUB 链接,使用第一个下载链接并修改为 /epub/ 结尾
30+
if not epub_link and acquisition_links:
31+
first_link = acquisition_links[0]
32+
href = first_link.get('href', '')
33+
# 移除路径中的文件名,只保留目录部分,然后添加 /epub/
34+
if '/' in href:
35+
path_parts = href.split('/')
36+
# 保留路径的主干部分
37+
base_path = '/'.join(path_parts[:-1]) if len(path_parts) > 1 else href
38+
epub_link = domain + base_path + '/epub/'
39+
else:
40+
epub_link = domain + '/epub/'
41+
42+
item['link'] = epub_link if epub_link else ''
2043

2144
# 获取描述
2245
summary = entry.find('summary')

vercel.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22
"version": 2,
33
"builds": [
44
{
5-
"src": "./main.py",
5+
"src": "main.py",
66
"use": "@vercel/python"
7+
},
8+
{
9+
"src": "rsshub/static/**",
10+
"use": "@vercel/static"
711
}
812
],
913
"routes": [
14+
{
15+
"src": "/static/(.*)",
16+
"dest": "/rsshub/static/$1"
17+
},
1018
{
1119
"src": "/(.*)",
12-
"dest": "/main.py"
20+
"dest": "main.py"
1321
}
14-
]
22+
],
23+
"env": {
24+
"FLASK_ENV": "production",
25+
"FLASK_CONFIG": "production",
26+
"PYTHONPATH": "$PYTHONPATH:."
27+
}
1528
}

0 commit comments

Comments
 (0)