improved rss subscribe

This commit is contained in:
mxr612 2024-08-24 13:40:12 +08:00
parent 0f28e11323
commit 3f6c5547cb

25
main.py
View File

@ -39,19 +39,20 @@ async def load_rss():
count = 0
loaded = []
uploads = []
for entry in rss.load_content():
loaded.append(entry['id'])
uploads.append({
'q': entry['title'],
'a': entry['content']
})
count += 1
if len(loaded) >= 100 and upload2fastgpt(uploads):
while entries := rss.load_content():
for entry in entries:
loaded.append(entry['id'])
uploads.append({
'q': entry['title'],
'a': entry['content']
})
count += 1
if len(loaded) >= 100 and upload2fastgpt(uploads):
rss.update(loaded)
loaded = []
uploads = []
if len(loaded) > 0 and upload2fastgpt(uploads):
rss.update(loaded)
loaded = []
uploads = []
if len(loaded) > 0 and upload2fastgpt(uploads):
rss.update(loaded)
print(f"Total entries loaded: {count}")
return f"Total entries loaded: {count}"