From 951aa944b42e9c60684dae9e7355486582f1cff6 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Sat, 23 Nov 2024 23:02:31 -0500 Subject: [PATCH] add lists, make blocker prettier --- bin/importlist.tcl | 31 +++++++++++++++++++++++++++---- bin/updatelists.tcl | 15 +++++++++++++-- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/bin/importlist.tcl b/bin/importlist.tcl index ea0a14b..b49bf0f 100755 --- a/bin/importlist.tcl +++ b/bin/importlist.tcl @@ -29,6 +29,11 @@ if ![info exists feeds] { set feeds [db eval {SELECT name FROM sqlite_master WHERE type = 'table' AND sql LIKE '%uri TEXT%'}] } +set count 0 +set newcount 0 + +set reqcount 0 + foreach list $lists { switch -regexp -matchvar matches -- $list { {^at://.+} {} @@ -58,11 +63,24 @@ foreach list $lists { while {[llength $items]} { foreach item $items { + incr count set repo [dict get $item subject did] - if $block { - puts "Blocking $repo from $list." - db eval {INSERT OR IGNORE INTO blocked_repos VALUES (:repo);} - } else { puts "Removing $repo from feeds." } + + set seen [db eval {SELECT count(*) FROM blocked_repos WHERE repo = :repo;}] + + if {!$seen} { + incr newcount + if {$block} { + puts "Blocking $repo ($list)." + db eval {INSERT OR IGNORE INTO blocked_repos VALUES (:repo);} + } else { + incr newcount + puts "Removing $repo ($list) from feeds." + } + } else { + } + + set repo_pat "%${repo}%" foreach table $feeds { db eval "DELETE FROM $table WHERE uri LIKE :repo_pat;" @@ -73,6 +91,10 @@ foreach list $lists { break } + incr reqcount + puts -nonewline "importing $list [string index {/-\|} [expr {$reqcount % 4}]]\r" + flush stdout + set cursor [dict get $data cursor] set http_state [http::geturl "$endpoint?list=$list&cursor=$cursor"] @@ -82,3 +104,4 @@ foreach list $lists { } } +puts "\33\[2K\r$count accounts ($newcount new) blocked from [llength $lists] lists." diff --git a/bin/updatelists.tcl b/bin/updatelists.tcl index 619a95f..47763e0 100755 --- a/bin/updatelists.tcl +++ b/bin/updatelists.tcl @@ -6,7 +6,7 @@ set uris [lassign $argv db] cd [file dirname [file dirname [dict get [info frame [info frame]] file]]] puts "importing rahaeli's lists..." -exec bin/importlist.tcl $db \ +exec bin/importlist.tcl $db >@stdout \ https://bsky.app/profile/rahaeli.bsky.social/lists/3lbh3ebjhfv24 \ https://bsky.app/profile/rahaeli.bsky.social/lists/3lbgroz3w4c2i \ https://bsky.app/profile/rahaeli.bsky.social/lists/3lasodgegrc2a \ @@ -18,6 +18,17 @@ exec bin/importlist.tcl $db \ puts "imported!" puts "importing aleteoryx's lists..." -exec bin/importlist.tcl $db \ +exec bin/importlist.tcl $db >@stdout \ https://bsky.app/profile/aleteoryx.me/lists/3lbnogsl36d2y puts "imported!" + +puts "importing skysentry's lists..." +exec bin/importlist.tcl $db >@stdout \ + https://bsky.app/profile/skysentry.bsky.social/lists/3lblifk2bf32f \ + https://bsky.app/profile/skysentry.bsky.social/lists/3lbli6wdryl2k \ + https://bsky.app/profile/skysentry.bsky.social/lists/3lbli2oiex62h \ + https://bsky.app/profile/skysentry.bsky.social/lists/3lblhu3jj5d2p \ + https://bsky.app/profile/skysentry.bsky.social/lists/3lblhqcys7h2k \ + https://bsky.app/profile/skysentry.bsky.social/lists/3lblhk24wkc2m \ + https://bsky.app/profile/skysentry.bsky.social/lists/3lblgs57oei26 +puts "imported!" -- 2.45.2