This script depends on chardet and pysrt. Install them via pip3:
pip3 install --user pysrt chardet
or via virtual environment.
Clone the repo and run
python3 setup.py --user install
chmod +x the script and copy it in a $PATH directory.
Run the script giving as arguments the subtitle files. In case some ads are found inside the file, the old file is moved to .bak and the new file written with the same name. Example: