Auto commit from /home/doc/genesis-tools
This commit is contained in:
parent
77463904be
commit
5f5ec0827b
File diff suppressed because it is too large
Load Diff
65
miscellaneous/smartstevie.py
Normal file
65
miscellaneous/smartstevie.py
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import requests
|
||||||
|
import time
|
||||||
|
from mastodon import Mastodon
|
||||||
|
|
||||||
|
# === CONFIGURATION ===
|
||||||
|
ICECAST_JSON_URL = "http://cast3.my-control-panel.com:7454/status-json.xsl"
|
||||||
|
SONG_TRIGGER = "Spiderbait - Stevie"
|
||||||
|
MASTODON_BASE_URL = "https://chatwithus.live"
|
||||||
|
MASTODON_TOKEN = "rimxBLi-eaJAcwagkmoj6UoW7Lc473tQY0cOM041Euw" # replace with your token
|
||||||
|
TOOT_TEXT = "AH BUU BUU BUU BUU"
|
||||||
|
|
||||||
|
# --- END CONFIG ---
|
||||||
|
|
||||||
|
masto = Mastodon(
|
||||||
|
access_token=MASTODON_TOKEN,
|
||||||
|
api_base_url=MASTODON_BASE_URL
|
||||||
|
)
|
||||||
|
|
||||||
|
last_seen = False
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
resp = requests.get(ICECAST_JSON_URL, timeout=10)
|
||||||
|
data = resp.json()
|
||||||
|
# Correct place to look is data["icestats"]["source"]
|
||||||
|
sources = data.get("icestats", {}).get("source")
|
||||||
|
|
||||||
|
if sources is None:
|
||||||
|
print("No sources found in Icecast status.")
|
||||||
|
time.sleep(30)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# If it's a list, find a source with a title or currently playing track
|
||||||
|
if isinstance(sources, list):
|
||||||
|
main_source = None
|
||||||
|
for src in sources:
|
||||||
|
if src.get("title") or src.get("yp_currently_playing"):
|
||||||
|
main_source = src
|
||||||
|
break
|
||||||
|
if not main_source:
|
||||||
|
main_source = sources[0]
|
||||||
|
elif isinstance(sources, dict):
|
||||||
|
main_source = sources
|
||||||
|
else:
|
||||||
|
print("No valid sources found.")
|
||||||
|
time.sleep(30)
|
||||||
|
continue
|
||||||
|
|
||||||
|
now_playing = main_source.get("title") or main_source.get("yp_currently_playing", "")
|
||||||
|
now_playing = now_playing.strip()
|
||||||
|
print("Now playing:", now_playing)
|
||||||
|
|
||||||
|
# Only toot if the song is playing and it wasn't seen last poll
|
||||||
|
if SONG_TRIGGER.lower() in now_playing.lower():
|
||||||
|
if not last_seen:
|
||||||
|
masto.status_post(TOOT_TEXT, visibility='public')
|
||||||
|
print(f"Tooted: {TOOT_TEXT}")
|
||||||
|
last_seen = True
|
||||||
|
else:
|
||||||
|
last_seen = False
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}")
|
||||||
|
|
||||||
|
time.sleep(30) # check every 30 seconds
|
37
miscellaneous/spiderbait.py
Normal file
37
miscellaneous/spiderbait.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import random
|
||||||
|
import time
|
||||||
|
import requests
|
||||||
|
|
||||||
|
# === CONFIG ===
|
||||||
|
MASTODON_INSTANCE = "https://chatwithus.live" # e.g., https://chatwithus.live
|
||||||
|
ACCESS_TOKEN = "rimxBLi-eaJAcwagkmoj6UoW7Lc473tQY0cOM041Euw"
|
||||||
|
|
||||||
|
MIN_WAIT = 10 # minimum seconds to wait between posts (e.g., 10)
|
||||||
|
MAX_WAIT = 3 * 60 * 60 # maximum seconds to wait (e.g., 3 hours)
|
||||||
|
|
||||||
|
def random_buu():
|
||||||
|
n = random.randint(2, 12)
|
||||||
|
return "AH " + " ".join(["BUU"] * n)
|
||||||
|
|
||||||
|
def toot_buu():
|
||||||
|
msg = random_buu()
|
||||||
|
print("Tooting:", msg)
|
||||||
|
url = f"{MASTODON_INSTANCE}/api/v1/statuses"
|
||||||
|
headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"}
|
||||||
|
payload = {"status": msg}
|
||||||
|
resp = requests.post(url, headers=headers, data=payload)
|
||||||
|
if resp.status_code == 200:
|
||||||
|
print("Success!")
|
||||||
|
else:
|
||||||
|
print(f"Failed: {resp.status_code} {resp.text}")
|
||||||
|
|
||||||
|
def main():
|
||||||
|
while True:
|
||||||
|
wait_time = random.randint(MIN_WAIT, MAX_WAIT)
|
||||||
|
print(f"Waiting {wait_time} seconds until next BUU...")
|
||||||
|
time.sleep(wait_time)
|
||||||
|
toot_buu()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user