summaryrefslogtreecommitdiff
path: root/move-to-category.py
diff options
context:
space:
mode:
Diffstat (limited to 'move-to-category.py')
-rwxr-xr-xmove-to-category.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/move-to-category.py b/move-to-category.py
new file mode 100755
index 0000000..72247ed
--- /dev/null
+++ b/move-to-category.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+# Usage:
+# move-to-category.py <instance-url> <from> <to>
+
+import miniflux
+import subprocess
+import sys
+
+MINIFLUX_INSTANCE = sys.argv[1]
+FROM = sys.argv[2]
+TO = sys.argv[3]
+PASS_ENTRY = [x.decode('utf-8') for x in subprocess.check_output(['pass', 'self-hosted/miniflux/web']).splitlines()]
+USER = [x for x in PASS_ENTRY if x.startswith("username:")][0].removeprefix("username:").strip()
+SECRET = PASS_ENTRY[0]
+
+try:
+ client = miniflux.Client(MINIFLUX_INSTANCE, USER, SECRET)
+except Exception as e: print(e)
+
+print("client connected")
+categories = client.get_categories()
+
+from_id = [x for x in categories if x["title"] == FROM][0]["id"]
+to_id = [x for x in categories if x["title"] == TO][0]["id"]
+
+feeds = client.get_category_feeds(from_id)
+print(f"got {len(feeds)} feeds")
+for feed in feeds:
+ try:
+ id = feed['id']
+ print(f"moving feed: {id}")
+ client.update_feed(id, category_id = to_id)
+ except Exception as e: print(e)