~aleteoryx/tclfeed-bsky

951aa944b42e9c60684dae9e7355486582f1cff6 — Aleteoryx 28 days ago 4c1e07b
add lists, make blocker prettier
2 files changed, 40 insertions(+), 6 deletions(-)

M bin/importlist.tcl
M bin/updatelists.tcl
M bin/importlist.tcl => bin/importlist.tcl +27 -4
@@ 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."

M bin/updatelists.tcl => bin/updatelists.tcl +13 -2
@@ 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!"