Last active
August 27, 2023 01:48
-
-
Save ohac/000ea4aef51c9f8dd980fbbbecfe4e57 to your computer and use it in GitHub Desktop.
Nostr status update script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# description: Nostr status update script | |
if [ -z "$3" ]; then | |
echo "usage: ./nostr-status.sh title artist length_ms" | |
exit | |
fi | |
relays="wss://relay.damus.io wss://nos.lol wss://yabu.me" | |
PATH=$HOME/go/bin:$PATH | |
projdir=$HOME/.config/nostr-status | |
mkdir -p $projdir | |
nsechexfn=$projdir/nsechex.txt | |
if [ ! -e $nsechexfn ]; then | |
echo "edit $nsechexfn first" | |
exit | |
fi | |
title="$1" | |
artist="$2" | |
length="$(($3/1000))" | |
algiadir=$HOME/.config/algia | |
algiafn=$algiadir/config.json | |
algiafn2=$algiadir/config-status.json | |
algiaacountopt="" | |
if [ ! -e $algiafn ]; then | |
echo "skip algia" | |
else | |
if [ ! -e $algiafn2 ]; then | |
echo "use algia config.json" | |
else | |
echo "use algia config-status.json" | |
algiaacountopt="-a status" | |
fi | |
poststr1="$title - $artist #nowplaying" | |
algia $algiaacountopt post "$poststr1" \ | |
>> $projdir/algialog1 2>> $projdir/algialog2 | |
fi | |
nsechex=$(cat $nsechexfn) | |
poststr2="$title - $artist" | |
spotify="spotify:search:$(echo -n $poststr2 | tr "@#\\\\\$!%&'()" '..........' | sed 's/ /%20/g')" | |
expiration=$(($(date +%s)+$length)) | |
if [ $expiration -le 60 ]; then | |
expiration=60 | |
fi | |
nak event -k 30315 -c "$poststr2" \ | |
-t "d=music,expiration=$expiration,r=$spotify" \ | |
--sec $nsechex $relays >> $projdir/naklog1 2>> $projdir/naklog2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment