Last active
May 3, 2022 07:56
-
-
Save dewomser/76ed3313c83674acc140b60f294364c4 to your computer and use it in GitHub Desktop.
Höre gerade und twittere mit Cover-Bildchen. Bashscript für KDE + Clementine Audioplayer
This file contains hidden or 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 | |
#//config | |
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 | |
cp ${a[0]} $HOME/bin/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=$(twurl -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 | |
twurl -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 | |
twurl -u $user -H upload.twitter.com "/1.1/media/upload.json" -d "command=FINALIZE&media_id=$mis" | jq . | |
#//text hinzufügen | |
twurl -u $user "/1.1/statuses/update.json" -d "media_ids=$mis&status=$text" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wird auf Github in einem eigenen repository weiterentwickelt:
https://github.com/dewomser/Tweet_and_toot_music_is_playing