Sign inSign up

arinono/plex-notifier

By arinono

•Updated about 6 years ago

Image
0

445

arinono/plex-notifier repository overview

Build Tests codecov Version


⁠Plex Notifier

Small program to send Discord notifications when plex webhook sends events.

Here is the Plex docs about webhooks: https://support.plex.tv/articles/115002267687-webhooks/⁠

Supported events:

  • media.play
  • media.pause
  • media.resume
  • media.stop
  • media.scrobble
  • library.new

⁠Notification examples

⁠media.play

media.play notification

⁠media.resume

media.resume notification

⁠library.new

library.new notification


⁠Setting up the bot

⁠Register your plex webhook

First, your need to add a webhook URL in your Plex account settings (a PlexPass suscription is required):

Settings Webhooks

Settings Webhooks Add

The URL has to match this format http(s)://<your-server-ip>/plex.

Then in order to enable the library.new notifications, you need to enable push notifications on your Plex server settings.

Enable Push Notifications

⁠Install the Discord bot

Hit this URL http://<your-server-ip>/discord in your browser, this will redirect you to the Discord page to authorize and install the bot.


⁠Starting the notifier

REQUIRED ENVIRONMENT VARIABLES:

  • SELF_DOMAIN: Points to this program. This is used by Discord to get posters, hosted here in /images.
  • DISCORD_CHANNEL_ID: Is your Discord Channel ID.

You can find it by right-clicking on your discord channel, then:

Discord Guild ID

# Getting the help
$> server -h
    --[no-]media      Enable plex media.* events.
                      (defaults to on)
    --[no-]library    Enable plex library.new event.
                      (defaults to on)
-v, --verbose         Add more logging.
-h, --help
⁠Using Docker image:
$> docker run -e DISCORD_CHANNEL_ID="<your-channel-id>" -e SELF_DOMAIN="http(s)://<your-server-ip>" -p 8080:8080 arinono/plex-notifier [arguments]
⁠Manually

Coming soon, I need to add binary to releases.


⁠Development or use your own Discord Bot

If you want to start the project locally, or build it to use your own Discord bot you can:

# Run all the tests with coverage
$> DISABLE_NOTIFIER=true DISCORD_CHANNEL_ID="<your-channel-id>" DISCORD_CLIENT_ID="<your-client-id>" DISCORD_BOT_TOKEN="<your-bot-token>" derry run test-full

# Run a single file
$> DISABLE_NOTIFIER=true DISCORD_CHANNEL_ID="<your-channel-id>" DISCORD_CLIENT_ID="<your-client-id>" DISCORD_BOT_TOKEN="<your-bot-token>" derry run test -- test/<file>.dart

# Start locally
$> SELF_DOMAIN="http(s)://<your-server-ip>" DISCORD_CHANNEL_ID="<your-channel-id>" dart -DDISCORD_CLIENT_ID="<your-discord-app-id>" -DDISCORD_BOT_TOKEN="<your-discord-bot-token>" bin/main.dart

# Build the executable
$> dart2native -DDISCORD_CLIENT_ID="<your-discord-app-id>" -DDISCORD_BOT_TOKEN="<your-discord-bot-token>" bin/main.dart -o build/server

# or build the Docker image
$> docker build --build-arg DISCORD_BOT_TOKEN="<your-discord-bot-token>" --build-arg DISCORD_CLIENT_ID="<your-discord-app-id>" -t <image-name> .

# Run the docker image
$> docker run -e SELF_DOMAIN="http(s)://<your-server-ip>" -e DISCORD_CHANNEL_ID="<your-channel-id>" -p 8080:8080 <image-name> [args]

⁠TODO and ideas

Todo:

  • Automate release process and release the v1.0.0
  • Error managment coming from Discord (gateway error reconnect and resume connection on error)
  • Write some tests and add CI pipelines
  • Document the code

Ideas:

  • Maybe add support for other tools (slack, ...)
  • Maybe add a way for Discord users to subscribe to library.on.deck notifications.
  • Publish the bot here⁠ ?

Tag summary

Content type

Image

Digest

Size

11.7 MB

Last updated

about 6 years ago

docker pull arinono/plex-notifier