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 count = 0
loaded = [] loaded = []
uploads = [] uploads = []
for entry in rss.load_content(): while entries := rss.load_content():
loaded.append(entry['id']) for entry in entries:
uploads.append({ loaded.append(entry['id'])
'q': entry['title'], uploads.append({
'a': entry['content'] 'q': entry['title'],
}) 'a': entry['content']
count += 1 })
if len(loaded) >= 100 and upload2fastgpt(uploads): count += 1
if len(loaded) >= 100 and upload2fastgpt(uploads):
rss.update(loaded)
loaded = []
uploads = []
if len(loaded) > 0 and upload2fastgpt(uploads):
rss.update(loaded) rss.update(loaded)
loaded = []
uploads = []
if len(loaded) > 0 and upload2fastgpt(uploads):
rss.update(loaded)
print(f"Total entries loaded: {count}") print(f"Total entries loaded: {count}")
return f"Total entries loaded: {count}" return f"Total entries loaded: {count}"