Skip to content

rare-magma/imdb-exporter

Repository files navigation

imdb-exporter

Bash script that uploads the IMDb Watchlist data to influxdb on a daily basis

Dependencies

Relevant documentation

Installation

With Docker

docker-compose

  1. Configure imdb_exporter.conf (see the configuration section below).

  2. Run it.

    docker compose up --detach

docker build & run

  1. Build the docker image.

    docker build . --tag imdb-exporter
  2. Configure imdb_exporter.conf (see the configuration section below).

  3. Run it.

    docker run --rm --init --tty --interactive --volume $(pwd):/app localhost/imdb-exporter

With the Makefile

For convenience, you can install this exporter with the following command or follow the manual process described in the next paragraph.

make install
$EDITOR $HOME/.config/imdb_exporter.conf

Manually

  1. Copy imdb_exporter.sh to $HOME/.local/bin/ and make it executable.

  2. Copy imdb_exporter.conf to $HOME/.config/, configure it (see the configuration section below) and make it read only.

  3. Copy the systemd unit and timer to $HOME/.config/systemd/user/:

    cp imdb-exporter.* $HOME/.config/systemd/user/
  4. and run the following command to activate the timer:

    systemctl --user enable --now imdb-exporter.timer

It's possible to trigger the execution by running manually:

systemctl --user start imdb-exporter.service

Config file

The config file has a few options:

INFLUXDB_HOST='influxdb.example.com'
INFLUXDB_API_TOKEN='ZXhhbXBsZXRva2VuZXhhcXdzZGFzZGptcW9kcXdvZGptcXdvZHF3b2RqbXF3ZHFhc2RhCg=='
ORG='home'
BUCKET='imdb'
IMDB_WATCHLIST_ID='ls000111111'
  • INFLUXDB_HOST should be the FQDN of the influxdb server.
  • ORG should be the name of the influxdb organization that contains the IMDb data bucket defined below.
  • BUCKET should be the name of the influxdb bucket that will hold the IMDb data.
  • INFLUXDB_API_TOKEN should be the influxdb API token value.
    • This token should have write access to the BUCKET defined above.
  • IMDB_WATCHLIST_ID should be the imdb watchlist ID value.
    • This ID can be retrieved from the "Export this list" link displayed at the bottom of the watchlist page on IMDb.

Troubleshooting

Run the script manually with bash set to trace:

bash -x $HOME/.local/bin/imdb_exporter.sh

Check the systemd service logs and timer info with:

journalctl --user --unit imdb-exporter.service
systemctl --user list-timers

Exported metrics

  • imdb_stats: Watchlist item metadata

Exported metrics example

imdb_stats,title_type=movie,genres=Action\ Adventure\ Biography\ Drama\ History\ War,year=2023 position=697,imdb_id="tt13287846",title="Napoleon",imdb_rating=6.5,runtime_mins=158,imdb_votes=89277,release_date="2023-11-14",directors="Ridley Scott" 1705190400

Example grafana dashboard

In imdb-dashboard.json there is an example of the kind of dashboard that can be built with imdb-exporter data:

Grafana dashboard screenshot

Import it by doing the following:

  1. Create a dashboard
  2. Click the dashboard's settings button on the top right.
  3. Go to JSON Model and then paste there the content of the imdb-dashboard.json file.

Uninstallation

With the Makefile

For convenience, you can uninstall this exporter with the following command or follow the process described in the next paragraph.

make uninstall

Manually

Run the following command to deactivate the timer:

systemctl --user disable --now imdb-exporter.timer

Delete the following files:

~/.local/bin/imdb_exporter.sh
~/.config/imdb_exporter.conf
~/.config/systemd/user/imdb-exporter.timer
~/.config/systemd/user/imdb-exporter.service

Credits