Coder Social home page Coder Social logo

epgstation-slack-notification's Introduction

epgstation-slack-notification

GitHub Actions Test Status

EPGStation の通知を Slack に送るコマンドラインツール

スクリーンショット

録画予約新規追加

reserveNewAddtionCommand

録画準備開始

recordingPreStartCommand

録画開始

recordingStartCommand

エンコード終了

encodingFinishCommand

ダウンロード

Releases から OS とアーキテクチャに合ったバイナリをダウンロード。

Linux / macOS の amd64 / arm64 / armv7 のみビルドしているのでそれ以外の環境では自分でビルドする。

設定

Slack API Token の準備

メッセージの投稿に API Token を使うので準備する。 詳しくは Slack のドキュメントを参照。

作成した API Token は設定ファイルに書き込むので控えておく。

投稿するチャンネル ID の確認

投稿するチャンネルをチャンネル ID で指定するので確認して控えておく。

設定ファイルを作成

epgstation-slack-config.example.yml ファイルを epgstation-slack-config.yml へコピーして Slack の API キーとチャンネル名を書き込む。

設定ファイルはデフォルトではバイナリと同じディレクトリに配置した epgstation-slack-config.yml ファイルを利用し,オプションで指定された場合はオプションの値が優先される。

$ wget -O epgstation-slack-config.yml https://raw.githubusercontent.com/hiroxto/epgstation-slack-notification/master/epgstation-slack-config.example.yml

デフォルト以外の場所に配置した設定ファイルを利用する場合は --config, -c オプションを利用する。

$ ./epgstation-slack-notification --config /path/to/config.yml reserve-new-addition

コマンドをセットする

EPGStation の config/config.yml にコマンドをセットする。

# 録画予約の新規追加時に実行されるコマンド
reserveNewAddtionCommand: "/path/to/epgstation-slack-notification reserve-new-addition"
# 録画情報の更新時に実行されるコマンド
reserveUpdateCommand: "/path/to/epgstation-slack-notification reserve-update"
# 録画予約の削除時に実行されるコマンド
reservedeletedCommand: "/path/to/epgstation-slack-notification reserve-deleted"
# 録画準備の開始時に実行されるコマンド
recordingPreStartCommand: "/path/to/epgstation-slack-notification recording-pre-start"
# 録画準備の失敗時に実行されるコマンド
recordingPrepRecFailedCommand: "/path/to/epgstation-slack-notification recording-prep-rec-failed"
# 録画開始時に実行するコマンド
recordingStartCommand: "/path/to/epgstation-slack-notification recording-start"
# 録画終了時に実行するコマンド
recordingFinishCommand: "/path/to/epgstation-slack-notification recording-finish"
# 録画中のエラー発生時に実行するコマンド
recordingFailedCommand: "/path/to/epgstation-slack-notification recording-failed"
# エンコード終了時に実行するコマンド
encodingFinishCommand: "/path/to/epgstation-slack-notification encoding-finish"

EPGStation v1 を使っている場合はconfig/config.jsonにコマンドをセットする。

{
  "reservationAddedCommand": "/path/to/epgstation-slack-notification reservation-added",
  "recordedPreStartCommand": "/path/to/epgstation-slack-notification recorded-pre-start",
  "recordedPrepRecFailedCommand": "/path/to/epgstation-slack-notification recorded-prep-rec-failed",

  "recordedStartCommand": "/path/to/epgstation-slack-notification recorded-start",
  "recordedEndCommand": "/path/to/epgstation-slack-notification recorded-end",
  "recordedFailedCommand": "/path/to/epgstation-slack-notification recorded-failed"
}

EPGStation を再起動

設定をした後, EPGStation を再起動する。

$ pm2 restart epgstation

通知内容のカスタマイズ

通知設定の messagetemplate は Go の text/template を使って任意の内容を出力できる。

テンプレートに渡されるデータの構造と中身は dump:detail コマンドを使って確認可能。

渡されるデータはコマンド毎に分かれていて以下のように使い分けされる。

  • ReserveDetail を使うコマンド
    • reserve-new-addition
    • reserve-update
    • reserve-deleted
    • recording-pre-start
    • recording-prep-rec-failed
  • RecordingDetail を使うコマンド
    • recording-start
    • recording-finish
    • recording-failed
  • EncodingDetail を使うコマンド
    • encoding-finish

データは基本的に EPGStation のドキュメント通りの環境変数の値が入る。

EPGStation から渡される環境変数に加えて一部独自の値も持っている。

  • StartAtTime
    • 環境変数 STARTATtime.Time 型に変換した値
  • EndAtTime
    • 環境変数 ENDATtime.Time 型に変換した値
  • DurationMin
    • 環境変数 DURATION を分単位の int64 型に変換した値

設定の確認

設定内容を確認する時は dump:config コマンドを利用する。

環境変数の確認

環境変数の内容を確認する時は dump:env コマンドを利用する。

Licence

MIT Licence

epgstation-slack-notification's People

Contributors

dependabot[bot] avatar hiroxto avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

epgstation-slack-notification's Issues

録画完了時におけるドロップ/エラー/スクランブル数のレポート

録画完了時におけるドロップ/エラー/スクランブル数のレポートを行う.

実装方法

  • 環境変数LOGPATHをパースしてカウント
    • パーサを作らないといけない
  • EPGStationのAPIを使う
    • 録画情報のerrorCnt, dropCnt, scramblingCntプロパティを使う
    • /api/recorded/${RECORDEDID}
    • API叩くだけ

Slack での表記のエスケープ

チルダなどの書式設定に使う文字があるとそのまま書式に反映されてしまう。
何らかの方法でエスケープする必要がある。

test

EPGStation v2への対応

EPGStation v2への対応

設定ファイルのフォーマット変更

JSONファイルからYAMLファイルに変更.
README.mdの設定例をv1とv2で併記する.

プロパティ名の変更

実行タイミング v1でのプロパティ名 v2でのプロパティ名
録画予約の新規追加時 reservationAddedCommand reserveNewAddtionCommand
録画準備の開始時 recordedPreStartCommand recordingPreStartCommand
録画準備の失敗時 recordedPrepRecFailedCommand recordingPrepRecFailedCommand
録画開始時に実行 recordedStartCommand recordingStartCommand
録画終了時に実行 recordedEndCommand recordingFinishCommand
録画中のエラー発生時 recordedFailedCommand recordingFailedCommand

新規コマンドの追加

reserveUpdateCommand

録画情報の更新時に実行

reservedeletedCommand

録画予約の削除時に実行

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.