mirror of
https://github.com/dewomser/Toot_music_is_playing.git
synced 2026-03-13 16:37:17 +01:00
29 lines
1.4 KiB
Bash
Executable file
29 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
#//config. Twitteruser wihout @
|
|
user="dewomser"
|
|
#if you need full path … find with which ruby ; which twurl
|
|
#twurlp="/usr/bin/ruby /home/foo/.local/share/gem/ruby/3.0.0/bin/twurl"
|
|
twurlp="twurl"
|
|
user="twitteruser"
|
|
#//Musikinfo von Clementie Audioplayer holen
|
|
readarray a <<< "$(qdbus org.mpris.MediaPlayer2.clementine /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata | grep -E 'artUrl|genre|artist|album:|title:'| sed -e 's/xesam://g'| sed -e 's/mpris:artUrl: file:\/\///g')"
|
|
|
|
#//Bild kopieren
|
|
# no quotes variable no format - strip \n
|
|
pfad=$(pwd)
|
|
# shellcheck disable=SC2086
|
|
cp ${a[0]} "$pfad/cover.jpg"
|
|
#cp ${a[0]} $HOME/git/twitter-pic/cover.jpg
|
|
# Daten an den Twitterclient
|
|
text="Ich höre gerade:${a[1]}${a[2]}${a[4]}"
|
|
#// Bildgröße in Byte ermitteln
|
|
byte=$(du -b cover.jpg | grep -Eo "^[0-9]+")
|
|
#// initialisieren
|
|
mis=$($twurlp -u $user -H upload.twitter.com "/1.1/media/upload.json" -d "command=INIT&media_type=image/jpg&total_bytes=$byte" | jq .media_id_string)
|
|
mis="${mis:1: -1}"
|
|
#//hochladen
|
|
$twurlp -u $user -H upload.twitter.com "/1.1/media/upload.json" -d "command=APPEND&media_id=$mis&segment_index=0" --file cover.jpg --file-field "media" | jq .
|
|
#//finalisieren
|
|
$twurlp -u $user -H upload.twitter.com "/1.1/media/upload.json" -d "command=FINALIZE&media_id=$mis" | jq .
|
|
#//text hinzufügen
|
|
$twurlp -u $user "/1.1/statuses/update.json" -d "media_ids=$mis&status=$text"
|