# Iceshrimp.NET 'Update Blocklist' Scripts ## Introduction: A couple of scripts for Iceshrimp.NET blocklist maintenance Right now, there is no simple way to maintain an Iceshrimp.NET blocklist (There will be in the future but currently there is no 'Import' facility) All of the scripts below: * Check that the directory exists for the blocklist .csv files, the 'blocklist_path' * Check that the directory exists for the blocklist log files, the 'blocklist_log_path' * Collect the online list(s) * Extract / Append the data into a Pandas DataFrame * Use 'SQL Alchemy' to INSERT the info into the PostgreSQL database table 'blocked_instance' using Python The [update_blocklist_multiple.py] and [update_blocklist_multiple_v2.py] scripts allow for an optional .csv '[personal_blocklist]' to be maintained that will add extra domains to the blocklist. The [update_blocklist_multiple_v2.py] script allows a selection of domains to removed from the generated blocklist, from the 'delete_statement' options: * Remove nothing from the 'public.blocked_instance' table, importing the blocklist(s) and doing nothing else (this is the default) * Remove all of the domains from the 'public.blocked_instance' table that are followed by a single account * Remove all of the domains from the 'public.blocked_instance' table that are followed by all accounts This script will then check: * That a valid 'delete_statement' has been chosen * That the 'delete_statement' has a valid 'followerId' (if applicable) In case the 'blocked_instance' table needs recreating the schema is [here] ## Files: All of the below update the 'blocked_instance' table This is where the name(s) of instance-wide blocked domains are held These can then be set via a cron job to run daily * ### [update_blocklist_single.py] Takes a single blocklist, manipulates the list and inserts the domains to be blocked into the database Requires: * The remote URL link to a .csv blocklist file * A local path setting (the directory where the .csv file is to be stored) * The local filename for the .csv file (this can be the same as the remote name) * A local log path setting (the directory where the log file is to be stored) * A filename for the log file to be created, that shows when the UPDATE last successfully ran * ### [update_blocklist_multiple.py] Takes multiple blocklists, manipulates them and inserts the domains to be blocked into the database Requires: * A '[blocklist_multiple.txt]' file that contains URLs to the remote .csv files * An optional .csv file containing URLS to be blocked; a '[personal_blocklist.csv]' * A local path setting (the directory where the .csv file(s) are to be stored) * A local log path setting (the directory where the log file is to be stored) * A filename for the log file to be created, that shows when the UPDATE last successfully ran * ### [update_blocklist_multiple_v2.py] Does the same as the above but then removes domains from the PostgreSQL database table 'blocked_instance' Requires: * A '[blocklist_multiple.txt]' file that contains URLs to the remote .csv files * An optional .csv file containing URLS to be blocked; a '[personal_blocklist.csv]' * A local path setting (the directory where the .csv file(s) are to be stored) * A local log path setting (the directory where the log file is to be stored) * A filename for the log file to be created, that shows when the UPDATE last successfully ran * Choosing a 'delete_statement' to determine which domains are to be removed from the database table 'blocked_instance', from the options: - Remove nothing from the 'public.blocked_instance' table, importing the blocklist(s) and doing nothing else (this is the default) - Remove all of the domains from the 'public.blocked_instance' table that are followed by a single account - Remove all of the domains from the 'public.blocked_instance' table that are followed by all accounts