Profile downloader: favorites list in the web UI; mark story filenames
- favorites.txt (git-ignored): profiles listed there show as buttons in the web UI that load the profile with one click - stories are saved as '<date> <id> story.<ext>' so they stand apart from posts
This commit is contained in:
1 parent
d12483d53c
commit
3dc4b0757f
5 files changed
+99
-9
No files matched your search
@@ -45,6 +45,25 @@ def config():
|
||||
return jsonify(default_cookies=core.DEFAULT_COOKIES if os.path.isfile(core.DEFAULT_COOKIES) else "")
|
||||
|
||||
|
||||
FAVORITES_FILE = os.path.join(core.ROOT, "favorites.txt")
|
||||
|
||||
|
||||
@app.get("/api/favorites")
|
||||
def favorites():
|
||||
"""Profiles listed in favorites.txt: one username, link or ID per line, # for comments.
|
||||
Read on every request, so edits show up after reloading the page."""
|
||||
entries = []
|
||||
try:
|
||||
with open(FAVORITES_FILE, encoding="utf-8-sig") as f:
|
||||
for line in f:
|
||||
entry = line.strip()
|
||||
if entry and not entry.startswith("#") and entry not in entries:
|
||||
entries.append(entry)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
return jsonify(favorites=entries)
|
||||
|
||||
|
||||
def _cookies_from(body: dict):
|
||||
if not body.get("use_cookies", True):
|
||||
return None
|
||||
|
||||
Reference in new issue
Block a user