Skip to content

Instantly share code, notes, and snippets.

@dewomser
Last active May 22, 2023 22:39
Show Gist options
  • Save dewomser/73683e37f55962d230f987331626f572 to your computer and use it in GitHub Desktop.
Save dewomser/73683e37f55962d230f987331626f572 to your computer and use it in GitHub Desktop.
tweet_music mit vlc ist kaputt. Twurl wurde im Mai 2023 von Twitter abgeschaltet.
#!/bin/bash
#//config
#Path twurlis not EXPORT
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
twurlp="/usr/bin/ruby /home/karl/.local/share/gem/ruby/3.0.0/bin/twurl"
#twurlp="twurl"
#twurl-user
user="dewomser"
#//Musikinfo von Clementie Audioplayer holen
readarray -t a <<< "$(qdbus org.mpris.MediaPlayer2.vlc /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
lolo1=$(urldecode ${a[0]})
cp "$lolo1" "$PWD"/cover.jpg
# Daten an den Twitterclient
a[5]="https://www.youtube.com/results?search_query=${a[2]} ${a[4]}"
lolo="${a[5]// /+}"
text1=$"ich höre gerade:"
text="$text1
${a[1]}
${a[2]}
${a[4]}
$lolo"
#exit
#// 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"
@dewomser
Copy link
Author

dewomser commented May 26, 2022

Initial

Test Tweet your music with VLC
mit
function urldecode
VLC verhält sich störrisch
Test hat funktioniert.

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