#!/usr/bin/env python # -*- coding: utf-8 -*- # The Rhythmbox plugin that creates a text file showing what is currently playing # https://github.com/Zattstudio/rhythmbox-nowplaying # A script that takes the contents of the text file that show what is currently playing # And then posts it as a Iceshrimp Note from secrets import * import requests # Function to build the note, the send it def send_note(): # Build the headers including the ICESHRIMP_TOKEN headers = { 'accept': 'application/json', 'Content-Type': 'application/json', 'Authorization' : f'Bearer {ICESHRIMP_TOKEN}', } # Collect the 'currently_playing' info from the text file f = open('/home/foo/.rhythmbox-current.out', 'r') currently_playing = f.read() # Build the text part of the note from the note_str = '' note_str += f"\n\n**Currently Playing**\n\n" note_str += currently_playing # Build the payload payload = { 'text': note_str, 'visibility': 'public', } # POST the payload to the ICESHRIMP_URL response = requests.post(ICESHRIMP_NOTE, headers=headers, json=payload) # Send the Note send_note()