Compare commits
3 Commits
ae6663572c
...
5868c1649b
| Author | SHA1 | Date | |
|---|---|---|---|
| 5868c1649b | |||
| a14184cddc | |||
| 6587f8c39c |
@@ -58,9 +58,9 @@ BE SURE TO USE A [BLUESKY APP PASSWORD](https://blueskyfeeds.com/faq-app-passwor
|
|||||||
- [x] undo likes
|
- [x] undo likes
|
||||||
- [x] undo reposts
|
- [x] undo reposts
|
||||||
- [x] delete quotes
|
- [x] delete quotes
|
||||||
- [ ] unfollow accounts
|
- [x] unfollow accounts
|
||||||
- [ ] remove bookmarks
|
- [x] remove bookmarks
|
||||||
- [ ] make `all` run the other commands
|
- [x] make `all` run the other commands
|
||||||
- [ ] add simple progress and logging
|
- [ ] add simple progress and logging
|
||||||
- [ ] add safeguards like confirmations and clear dry-run info
|
- [ ] add safeguards like confirmations and clear dry-run info
|
||||||
|
|
||||||
|
|||||||
75
skywipe/bookmarks.py
Normal file
75
skywipe/bookmarks.py
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
"""Bookmark deletion module for Skywipe"""
|
||||||
|
|
||||||
|
import time
|
||||||
|
from atproto import models
|
||||||
|
from .auth import Auth
|
||||||
|
from .configure import Configuration
|
||||||
|
|
||||||
|
|
||||||
|
def delete_bookmarks():
|
||||||
|
auth = Auth()
|
||||||
|
client = auth.login()
|
||||||
|
config = Configuration()
|
||||||
|
config_data = config.load()
|
||||||
|
|
||||||
|
batch_size = config_data.get("batch_size", 10)
|
||||||
|
delay = config_data.get("delay", 1)
|
||||||
|
verbose = config_data.get("verbose", False)
|
||||||
|
|
||||||
|
if verbose:
|
||||||
|
print(
|
||||||
|
f"Starting bookmark deletion with batch_size={batch_size}, delay={delay}s")
|
||||||
|
|
||||||
|
cursor = None
|
||||||
|
total_deleted = 0
|
||||||
|
|
||||||
|
while True:
|
||||||
|
get_params = models.AppBskyBookmarkGetBookmarks.Params(
|
||||||
|
limit=batch_size,
|
||||||
|
cursor=cursor
|
||||||
|
)
|
||||||
|
|
||||||
|
response = client.app.bsky.bookmark.get_bookmarks(params=get_params)
|
||||||
|
|
||||||
|
bookmarks = response.bookmarks
|
||||||
|
if not bookmarks:
|
||||||
|
break
|
||||||
|
|
||||||
|
for bookmark in bookmarks:
|
||||||
|
try:
|
||||||
|
bookmark_uri = None
|
||||||
|
if hasattr(bookmark, "uri"):
|
||||||
|
bookmark_uri = bookmark.uri
|
||||||
|
else:
|
||||||
|
for attr_name in ("subject", "record", "post", "item"):
|
||||||
|
if hasattr(bookmark, attr_name):
|
||||||
|
nested = getattr(bookmark, attr_name)
|
||||||
|
if hasattr(nested, "uri"):
|
||||||
|
bookmark_uri = nested.uri
|
||||||
|
break
|
||||||
|
|
||||||
|
if not bookmark_uri:
|
||||||
|
if verbose:
|
||||||
|
print(f"Skipping bookmark: unable to find uri")
|
||||||
|
continue
|
||||||
|
|
||||||
|
delete_data = models.AppBskyBookmarkDeleteBookmark.Data(
|
||||||
|
uri=bookmark_uri
|
||||||
|
)
|
||||||
|
client.app.bsky.bookmark.delete_bookmark(data=delete_data)
|
||||||
|
total_deleted += 1
|
||||||
|
if verbose:
|
||||||
|
print(f"Deleted bookmark: {bookmark_uri}")
|
||||||
|
except Exception as e:
|
||||||
|
bookmark_uri = getattr(bookmark, "uri", "unknown")
|
||||||
|
if verbose:
|
||||||
|
print(f"Error deleting bookmark {bookmark_uri}: {e}")
|
||||||
|
|
||||||
|
cursor = response.cursor
|
||||||
|
if not cursor:
|
||||||
|
break
|
||||||
|
|
||||||
|
if delay > 0:
|
||||||
|
time.sleep(delay)
|
||||||
|
|
||||||
|
print(f"Deleted {total_deleted} bookmarks.")
|
||||||
@@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
from typing import Callable, Dict, Optional
|
from typing import Callable, Dict, Optional
|
||||||
from .configure import Configuration
|
from .configure import Configuration
|
||||||
from .posts import delete_posts
|
from .posts import delete_all_posts
|
||||||
from .medias import delete_posts_with_medias
|
from .medias import delete_posts_with_medias
|
||||||
from .likes import undo_likes
|
from .likes import undo_likes
|
||||||
from .reposts import undo_reposts
|
from .reposts import undo_reposts
|
||||||
from .quotes import delete_quotes
|
from .quotes import delete_quotes_posts
|
||||||
|
from .follows import unfollow_all
|
||||||
|
from .bookmarks import delete_bookmarks
|
||||||
|
|
||||||
|
|
||||||
CommandHandler = Callable[[], None]
|
CommandHandler = Callable[[], None]
|
||||||
@@ -58,7 +60,7 @@ def run_configure():
|
|||||||
|
|
||||||
|
|
||||||
def run_posts():
|
def run_posts():
|
||||||
delete_posts()
|
delete_all_posts()
|
||||||
|
|
||||||
|
|
||||||
def run_medias():
|
def run_medias():
|
||||||
@@ -74,25 +76,26 @@ def run_reposts():
|
|||||||
|
|
||||||
|
|
||||||
def run_quotes():
|
def run_quotes():
|
||||||
delete_quotes()
|
delete_quotes_posts()
|
||||||
|
|
||||||
|
|
||||||
def run_follows():
|
def run_follows():
|
||||||
print("Command 'follows' is not yet implemented.")
|
unfollow_all()
|
||||||
|
|
||||||
|
|
||||||
def run_bookmarks():
|
def run_bookmarks():
|
||||||
print("Command 'bookmarks' is not yet implemented")
|
delete_bookmarks()
|
||||||
|
|
||||||
|
|
||||||
def run_all():
|
def run_all():
|
||||||
registry.execute("posts")
|
commands = ["posts", "likes", "reposts", "follows", "bookmarks"]
|
||||||
registry.execute("medias")
|
|
||||||
registry.execute("likes")
|
for cmd in commands:
|
||||||
registry.execute("reposts")
|
try:
|
||||||
registry.execute("quotes")
|
registry.execute(cmd)
|
||||||
registry.execute("follows")
|
except Exception as e:
|
||||||
registry.execute("bookmarks")
|
print(f"Error running '{cmd}': {e}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
registry.register("configure", run_configure,
|
registry.register("configure", run_configure,
|
||||||
@@ -103,5 +106,5 @@ registry.register("likes", run_likes, "only likes")
|
|||||||
registry.register("reposts", run_reposts, "only reposts")
|
registry.register("reposts", run_reposts, "only reposts")
|
||||||
registry.register("quotes", run_quotes, "only quotes")
|
registry.register("quotes", run_quotes, "only quotes")
|
||||||
registry.register("follows", run_follows, "only follows")
|
registry.register("follows", run_follows, "only follows")
|
||||||
registry.register("bookmarks", run_follows, "only bookmarks")
|
registry.register("bookmarks", run_bookmarks, "only bookmarks")
|
||||||
registry.register("all", run_all, "target everything")
|
registry.register("all", run_all, "target everything")
|
||||||
|
|||||||
Reference in New Issue
Block a user