Compare commits
3 Commits
044ec67aa3
...
c8df3d0460
| Author | SHA1 | Date | |
|---|---|---|---|
| c8df3d0460 | |||
| 5afee97259 | |||
| ebbcbeeaa7 |
@@ -67,8 +67,8 @@ BE SURE TO USE A [BLUESKY APP PASSWORD](https://blueskyfeeds.com/faq-app-passwor
|
|||||||
- [x] sign in to at protocol
|
- [x] sign in to at protocol
|
||||||
- [x] delete posts in batch
|
- [x] delete posts in batch
|
||||||
- [x] only delete posts with media
|
- [x] only delete posts with media
|
||||||
- [ ] remove likes
|
- [x] undo likes
|
||||||
- [ ] remove reposts
|
- [ ] undo reposts
|
||||||
- [ ] unfollow accounts
|
- [ ] unfollow accounts
|
||||||
- [ ] remove bookmarks
|
- [ ] remove bookmarks
|
||||||
- [ ] make `all` run the other commands
|
- [ ] make `all` run the other commands
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from typing import Callable, Dict, Optional
|
|||||||
from skywipe.configure import Configuration
|
from skywipe.configure import Configuration
|
||||||
from skywipe.posts import delete_posts
|
from skywipe.posts import delete_posts
|
||||||
from skywipe.medias import delete_posts_with_medias
|
from skywipe.medias import delete_posts_with_medias
|
||||||
|
from skywipe.likes import undo_likes
|
||||||
|
|
||||||
|
|
||||||
CommandHandler = Callable[[], None]
|
CommandHandler = Callable[[], None]
|
||||||
@@ -63,7 +64,7 @@ def run_medias():
|
|||||||
|
|
||||||
|
|
||||||
def run_likes():
|
def run_likes():
|
||||||
print("Command 'likes' is not yet implemented.")
|
undo_likes()
|
||||||
|
|
||||||
|
|
||||||
def run_reposts():
|
def run_reposts():
|
||||||
|
|||||||
69
skywipe/likes.py
Normal file
69
skywipe/likes.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
"""Like undoing module for Skywipe"""
|
||||||
|
|
||||||
|
import time
|
||||||
|
from atproto import models
|
||||||
|
from skywipe.auth import Auth
|
||||||
|
from skywipe.configure import Configuration
|
||||||
|
|
||||||
|
|
||||||
|
LIKE_COLLECTION = "app.bsky.feed.like"
|
||||||
|
|
||||||
|
|
||||||
|
def undo_likes():
|
||||||
|
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 like deletion with batch_size={batch_size}, delay={delay}s")
|
||||||
|
|
||||||
|
did = client.me.did
|
||||||
|
cursor = None
|
||||||
|
total_undone = 0
|
||||||
|
|
||||||
|
while True:
|
||||||
|
list_params = models.ComAtprotoRepoListRecords.Params(
|
||||||
|
repo=did,
|
||||||
|
collection=LIKE_COLLECTION,
|
||||||
|
limit=batch_size,
|
||||||
|
cursor=cursor
|
||||||
|
)
|
||||||
|
|
||||||
|
response = client.com.atproto.repo.list_records(params=list_params)
|
||||||
|
|
||||||
|
records = response.records
|
||||||
|
if not records:
|
||||||
|
break
|
||||||
|
|
||||||
|
for record in records:
|
||||||
|
try:
|
||||||
|
record_uri = record.uri
|
||||||
|
rkey = record_uri.rsplit("/", 1)[-1]
|
||||||
|
delete_data = {
|
||||||
|
"repo": did,
|
||||||
|
"collection": LIKE_COLLECTION,
|
||||||
|
"rkey": rkey
|
||||||
|
}
|
||||||
|
client.com.atproto.repo.delete_record(data=delete_data)
|
||||||
|
total_undone += 1
|
||||||
|
if verbose:
|
||||||
|
print(f"Undone like: {record_uri}")
|
||||||
|
except Exception as e:
|
||||||
|
record_uri = getattr(record, "uri", "unknown")
|
||||||
|
if verbose:
|
||||||
|
print(f"Error undoing like {record_uri}: {e}")
|
||||||
|
|
||||||
|
cursor = response.cursor
|
||||||
|
if not cursor:
|
||||||
|
break
|
||||||
|
|
||||||
|
if delay > 0:
|
||||||
|
time.sleep(delay)
|
||||||
|
|
||||||
|
print(f"Undone {total_undone} likes.")
|
||||||
Reference in New Issue
Block a user