bellingcat Python script to automatically archive social media posts, videos, and images from a Google Sheets document.
 
 
 
 
 
 
Go to file
Patrick Robertson 5b481f72ab Tidy ups to manifests for docs 2025-02-11 20:03:53 +00:00
.github/workflows Add ubuntu-latest to the matrix of test runners (#181) 2025-01-24 14:03:55 +00:00
docs Add multi-type modules to all headings on TOC 2025-02-11 19:46:57 +00:00
scripts Update modules for new core structure. 2025-01-30 08:42:23 +00:00
src/auto_archiver Tidy ups to manifests for docs 2025-02-11 20:03:53 +00:00
tests Merge branch 'load_modules' into docs_update 2025-02-11 14:10:56 +00:00
.dockerignore docker initial files 2022-10-31 17:10:55 +00:00
.gitignore Use a script to auto-generate documentation for the core modules from the manifest file 2025-02-10 22:51:04 +00:00
.pylintrc Ignore pylint statements for manifest files 2025-01-21 17:59:52 +01:00
.readthedocs.yaml Readthedocs now requires all packages for running the pre-build scripts 2025-02-11 18:38:41 +00:00
Dockerfile modifies base docker image to use browsertrix 1.4.2 (#182) 2025-01-24 13:59:29 +00:00
LICENSE Add LICENSE 2021-06-24 16:14:32 +02:00
README.md Tidy ups to manifests for docs 2025-02-11 20:03:53 +00:00
docker-compose.yaml Add docker-compose for easy building and running of docker image in dev 2025-01-15 14:36:02 +01:00
poetry.lock Upgrade certifi 2025-02-11 18:41:37 +00:00
pyproject.toml Add likify deps 2025-02-11 18:40:44 +00:00

README.md

Auto Archiver

PyPI version Docker Image Version (latest by date) Core Test Status Download Test Status

Read the article about Auto Archiver on bellingcat.com.

Python tool to automatically archive social media posts, videos, and images from a Google Sheets, the console, and more. Uses different archivers depending on the platform, and can save content to local storage, S3 bucket (Digital Ocean Spaces, AWS, ...), and Google Drive. If using Google Sheets as the source for links, it will be updated with information about the archived content. It can be run manually or on an automated basis.

Installation

For full instructions on how to install auto-archiver, view the Installation Guide

Quick run using docker:

docker pull bellingcat/auto-archiver && docker run

Orchestration

The archiver work is orchestrated by the following workflow (we call each a step):

  1. Feeder gets the links (from a spreadsheet, from the console, ...)
  2. Archiver tries to archive the link (twitter, youtube, ...)
  3. Enricher adds more info to the content (hashes, thumbnails, ...)
  4. Formatter creates a report from all the archived content (HTML, PDF, ...)
  5. Database knows what's been archived and also stores the archive result (spreadsheet, CSV, or just the console)

To setup an auto-archiver instance create an orchestration.yaml which contains the workflow you would like. We advise you put this file into a secrets/ folder and do not share it with others because it will contain passwords and other secrets.

The structure of orchestration file is split into 2 parts: steps (what steps to use) and configurations (how those steps should behave), here's a simplification:

# orchestration.yaml content
steps:
  feeder: gsheet_feeder
  archivers: # order matters
    - youtubedl_archiver
  enrichers:
    - thumbnail_enricher
  formatter: html_formatter
  storages:
    - local_storage
  databases:
    - gsheet_db

configurations:
  gsheet_feeder:
    sheet: "your google sheet name"
    header: 2 # row with header for your sheet
  # ... configurations for the other steps here ...

To see all available steps (which archivers, storages, databases, ...) exist check the example.orchestration.yaml.

All the configurations in the orchestration.yaml file (you can name it differently but need to pass it in the --config FILENAME argument) can be seen in the console by using the --help flag. They can also be overwritten, for example if you are using the cli_feeder to archive from the command line and want to provide the URLs you should do:

auto-archiver --config secrets/orchestration.yaml --cli_feeder.urls="url1,url2,url3"

Here's the complete workflow that the auto-archiver goes through:


graph TD
    s((start)) --> F(fa:fa-table Feeder)
    F -->|get and clean URL| D1{fa:fa-database Database}
    D1 -->|is already archived| e((end))
    D1 -->|not yet archived| a(fa:fa-download Archivers)
    a -->|got media| E(fa:fa-chart-line Enrichers)
    E --> S[fa:fa-box-archive Storages]
    E --> Fo(fa:fa-code Formatter)
    Fo --> S
    Fo -->|update database| D2(fa:fa-database Database)
    D2 --> e

Orchestration checklist

Use this to make sure you help making sure you did all the required steps:

  • you have a /secrets folder with all your configuration files including
    • a orchestration file eg: orchestration.yaml pointing to the correct location of other files
    • (optional if you use GoogleSheets) you have a service_account.json (see how-to)
    • (optional for telegram) a anon.session which appears after the 1st run where you login to telegram
      • if you use private channels you need to add channel_invites and set join_channels=true at least once
    • (optional for VK) a vk_config.v2.json
    • (optional for using GoogleDrive storage) gd-token.json (see help script)
    • (optional for instagram) instaloader.session file which appears after the 1st run and login in instagram
    • (optional for browsertrix) profile.tar.gz file

Example invocations

The recommended way to run the auto-archiver is through Docker. The invocations below will run the auto-archiver Docker image using a configuration file that you have specified

# all the configurations come from ./secrets/orchestration.yaml
docker run --rm -v $PWD/secrets:/app/secrets -v $PWD/local_archive:/app/local_archive bellingcat/auto-archiver --config secrets/orchestration.yaml
# uses the same configurations but for another google docs sheet 
# with a header on row 2 and with some different column names
# notice that columns is a dictionary so you need to pass it as JSON and it will override only the values provided
docker run --rm -v $PWD/secrets:/app/secrets -v $PWD/local_archive:/app/local_archive bellingcat/auto-archiver --config secrets/orchestration.yaml --gsheet_feeder.sheet="use it on another sheets doc" --gsheet_feeder.header=2 --gsheet_feeder.columns='{"url": "link"}'
# all the configurations come from orchestration.yaml and specifies that s3 files should be private
docker run --rm -v $PWD/secrets:/app/secrets -v $PWD/local_archive:/app/local_archive bellingcat/auto-archiver --config secrets/orchestration.yaml --s3_storage.private=1

The auto-archiver can also be run locally, if pre-requisites are correctly configured. Equivalent invocations are below.

# all the configurations come from ./secrets/orchestration.yaml
auto-archiver --config secrets/orchestration.yaml
# uses the same configurations but for another google docs sheet 
# with a header on row 2 and with some different column names
# notice that columns is a dictionary so you need to pass it as JSON and it will override only the values provided
auto-archiver --config secrets/orchestration.yaml --gsheet_feeder.sheet="use it on another sheets doc" --gsheet_feeder.header=2 --gsheet_feeder.columns='{"url": "link"}'
# all the configurations come from orchestration.yaml and specifies that s3 files should be private
auto-archiver --config secrets/orchestration.yaml --s3_storage.private=1