Skip to content

Commit 9dc5469

Browse files
author
farfarfun
committed
Bump version to 1.1.64, add GithubDrive source updater with cat icons
1 parent 29ce10e commit 9dc5469

2 files changed

Lines changed: 108 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "funread"
3-
version = "1.1.63"
3+
version = "1.1.64"
44
description = "一个用于管理和处理阅读源(Legado 阅读 APP 的书源和 RSS 源)的 Python 工具库"
55
readme = "README.md"
66
requires-python = ">=3.8"
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
from datetime import datetime
2+
3+
import requests
4+
from fundrive.drives.github import GithubDrive
5+
from funfake.headers import Headers
6+
import os
7+
import json
8+
9+
faker = Headers()
10+
11+
12+
class UpdateEntrance:
13+
def __init__(self):
14+
self.drive = GithubDrive()
15+
self.drive.login(
16+
repo_owner="farfarfun",
17+
repo_name="funread-cache",
18+
branch="master",
19+
)
20+
21+
def random_icon(self):
22+
url = "https://api.thecatapi.com/v1/images/search?size=full"
23+
response = requests.get(url, headers=faker.generate()).json()
24+
return response[0]["url"]
25+
26+
def update_book(self, dir_path="funread/legado/snapshot/lasted"):
27+
dl = []
28+
for dir_info in self.drive.get_dir_list(dir_path):
29+
dl.append(
30+
{
31+
"title": dir_info["name"],
32+
"pic": self.random_icon(),
33+
"url": f"https://farfarfun.github.io/funread-cache/{dir_info['fid']}/index.html",
34+
"description": "this is content",
35+
}
36+
)
37+
38+
dl.append(
39+
{
40+
"title": "源仓库(新)",
41+
"url": "https://link3.cc/yckceo",
42+
}
43+
)
44+
45+
dl.append({"title": "开源阅读-语雀文档", "url": "https://www.yuque.com/legado"})
46+
dl.append({"title": "喵公子书源", "url": "http://yuedu.miaogongzi.net/gx.html"})
47+
dl.append({"title": "「阅读」APP 源-aoaostar", "url": "https://legado.aoaostar.com/"})
48+
dl.append({"title": "yiove", "url": "https://shuyuan.yiove.com/"})
49+
50+
#
51+
for line in dl:
52+
if "pic" not in line:
53+
line["pic"] = self.random_icon()
54+
if "time" not in line:
55+
line["time"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
56+
57+
data1 = {
58+
"name": "test",
59+
"next": "https://gitee.com/farfarfun/funread-cache/raw/master/funread/legado/snapshot/lasted/funread.json",
60+
"list": dl,
61+
}
62+
self.drive.upload_file(
63+
content=json.dumps(data1),
64+
fid=os.path.dirname(dir_info["fid"]),
65+
filepath=None,
66+
filename=f"source.json",
67+
)
68+
69+
def update_main(self):
70+
rss = {
71+
"源": "https://gitee.com/farfarfun/funread-cache/raw/master/funread/legado/snapshot/lasted/source.json",
72+
"源(备)": "https://github.com/farfarfun/funread-cache/raw/master/funread/legado/snapshot/lasted/source.json",
73+
}
74+
75+
data2 = [
76+
{
77+
"lastUpdateTime": int(datetime.now().timestamp()),
78+
"sourceName": "funread",
79+
"sourceIcon": self.random_icon(),
80+
"sourceUrl": "https://github.com/farfarfun",
81+
"loadWithBaseUrl": False,
82+
"singleUrl": False,
83+
"sortUrl": "\n".join([f"{k}::{v}" for k, v in rss.items()]),
84+
"ruleArticles": "$.list[*]",
85+
"ruleNextArticles": "$.next",
86+
"ruleTitle": "$.title",
87+
"rulePubDate": "⏰{{$.time}}",
88+
"ruleImage": "$.pic",
89+
"ruleLink": "$.url",
90+
"sourceGroup": "VIP",
91+
"customOrder": -9999999,
92+
"enabled": True,
93+
}
94+
]
95+
self.drive.upload_file(
96+
content=json.dumps(data2),
97+
fid="funread/legado/snapshot/lasted",
98+
filepath=None,
99+
filename=f"funread.json",
100+
)
101+
102+
def run(self):
103+
self.update_book()
104+
self.update_main()
105+
106+
107+
UpdateEntrance().run()

0 commit comments

Comments
 (0)