Notices where this attachment appears
-
Embed this notice
@lauralt @redneonglow @sjw There's a scrobble endpoint that is in some patched versions of Pleroma. What I'm using is kind of awful, but it's kind of just a prototype to see if it works:
while sleep 1; do cmus-remote -C status | mawk 'BEGIN{m["artist"]=m["album"]="Unknown";playing=1;duration=180} $1 == "status" && $2 != "playing" {playing=0} $1 == "position" {position=$2; if(position < 10){system("sleep 10");exit}} $1 == "file"{n=split($0, a, /\//);m["title"]=a[n]} $1 == "duration"{m["duration"] = $2} $1 != "tag"{next} {f=$2;$1=$2="";sub(/^ +/, "");gsub(/["'\''\\]+/, "");m[f]=$0} END{if(playing && position>10) { getline auth < ".p-baest-auth"; system(sprintf("curl %s -F \"album=%s\" -F \"artist=%s\" -F \"title=%s\" -F \"length=%d\" -X POST https://bae.st/api/v1/pleroma/scrobble | jq \"[.album, .artist, .id, .length, .title]\"", auth, m["album"], m["artist"], m["title"], m["duration"])); } wait = (m["duration"]-position); print m["duration"], position, wait; if(wait < 10 || position < 10)wait=10; system("sleep " wait)}'; done
A better plan would be to just open a pipe to cmus-remote instead of repeatedly invoking it, and then poll status periodically and update it when the song changes (and gets played instead of just skipping around). It's a new Activity type (I think "Audio"), so if you hit the endpoint for my account, it'll show you something like the last ten songs.