By Tom Snelling
Published 27th June 2022
The first thing you will need is a YouTube API key, so that the YT-Spammer-Purge tool can interact with your channel and videos. The GitHub repo provides a how to guide on doing this, so follow all of the steps there to generate your credentials first.
The next step is to generate the config files you will need to run the tool on Northflank. To do this, you will need to install YT-Spammer-Purge locally on your own computer. If you are on Windows, you can download the latest .exe file from the releases page. If you are on macOS or Linux, then you can follow the installation instructions on the wiki.
Once you have installed the tool locally, copy your downloaded YouTube credentials and place them in the same directory, in a file named
client_secrets.json. Once you’ve done that, run the tool and it will take you through the Google OAuth login process. You will then be presented with the main menu, where you can select option 6 to generate config files. When this is done, you can exit the program.
By default, the tool will require you to enter things like channel, video(s), mode etc. each time it is run. But this is no good if we want it to run automatically in the background — so we need to modify some configuration values to tell the tool exactly what we want it to do. In the
SpamPurgeConfig.ini file that was generated in the previous step, update the following values:
[config-meta] use_this_config = True [general] your_channel_id = <CHANNEL ID HERE> auto_close = True [scanning] scan_mode = EntireChannel max_comments = 1000 channel_to_scan = Mine [filtering] filter_mode = AutoSmart [removal] delete_without_reviewing = True
It may be easiest to Ctrl+f/Cmd+f to find the values you need to change. The section labels are displayed above so that the required values are easier to find.
You can tweak other values if you want the tool to behave differently. In this configuration, it will look at recent comments across all of your videos. However you can tell it to look at specific videos, only your recent videos, or many other options. For the full list of config options, see the ‘config file settings’ page.
Bear in mind that all of the options you choose must allow the tool to run without your input — setting any options to
Ask will mean that it cannot run autonomously as it will be awaiting your input before it can run.
In a new Northflank project, select ‘Create new’ at the top of the screen and choose ‘Job’. Once on the job creation form, select ‘cron’ as the type if you want your job to run automatically on a schedule, or ‘manual’ if you want the program to run only when you tell it to.
Give your job a sensible name, and if you selected cron, set the job schedule. Depending on the amount of traffic and comments your videos receive, you might want to run the tool once a day, once a week, or once a month. Just be aware that API limits apply — you can read more about them on the YT-Spammer-Purge wiki.
When you get to the ‘job source’ section, select external image and enter
ghcr.io/thiojoe/yt-spammer-purge:latest. This is the public Docker image for the YT-Spammer-Purge tool.
Finally, select a plan. We recommend at least
nf-compute-50 to run the tool smoothly. Hit the ‘create job’ button to finish.
You will be taken to your newly created job. In the left hand menu, select ‘Environment’ and scroll down to see the ‘secret files’ section.
You will need to add 3 files:
For each of these, click ‘add file’, enter the mount path as you see it above, and use the ‘import from file’ button to upload the 3 config files, which will all be in the same directory you ran the YT-Spammer-Purge tool in earlier.
Now that your config files are added, you should be good to go! You can manually run your job using the play button in the job header, or if you have created a cron job you can wait for the schedule to trigger the job automatically. When the job runs, you can view the running container and see the log output, where the tool will tell you how many spam comments it has detected and deleted.