Skip to content

Instantly share code, notes, and snippets.

@nipotan
Created December 8, 2023 02:31
Show Gist options
  • Save nipotan/0c5d4433a7fbe74d5f0556f9778303d6 to your computer and use it in GitHub Desktop.
Save nipotan/0c5d4433a7fbe74d5f0556f9778303d6 to your computer and use it in GitHub Desktop.
あなたの推し様が配信開始したら LINE に通知が来るやつ
#!/bin/sh
LIVER_ID=17861268
LIVER_NAME=ゆかりん
LINE_NOTIFY_TOKEN=SEtYoUrpeRsOnaLLInEnOtiFysaCceSStOkeNaTHEre
function get_last_started_at () {
live_status_file=$HOME/.mixch_${LIVER_ID}_started_at
if [ ! -f $live_status_file ]
then
touch $live_status_file
fi
cat $live_status_file
}
function set_last_started_at () {
last_started_at=$1
live_status_file=$HOME/.mixch_${LIVER_ID}_started_at
/bin/echo $last_started_at > $live_status_file
}
function get_current_started_at () {
curl -s -A 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36' \
https://mixch.tv/u/$LIVER_ID/live \
| grep '__INITIAL_JS_STATE__ = ' \
| cut -d= -f2 \
| sed 's/;$//' \
| jq '.liveInfo.created'
}
function send_line_notify () {
msg=$'\n'"${LIVER_NAME}がミクチャ配信を始めたよ!観に行こう!"$'\n'"https://mixch.tv/u/$LIVER_ID/live"
curl -s -X POST -H "Authorization: Bearer $LINE_NOTIFY_TOKEN" \
--data-urlencode "message=${msg}" \
https://notify-api.line.me/api/notify > /dev/null
}
current_started_at=$(get_current_started_at)
if [ "$current_started_at" != "null" ]
then
last_started_at=$(get_last_started_at)
if [ "$last_started_at" != "$current_started_at" ]
then
send_line_notify
fi
fi
set_last_started_at $current_started_at
@nipotan
Copy link
Author

nipotan commented Dec 8, 2023

とりあえず雑に

* * * * * /path/to/mixch-live-notify.sh > /dev/null 2>&1

みたいに設定すれば良いと思います。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment