With a little work this could be made to interface with your station's web page or with cloud services.
#! /usr/bin/python3
"""idjcmon3.py demo code for Python3
This can be extended to issue e-mail alerts if IDJC freezes or perform Twitter
updates when the music changes.
Requires IDJC 0.8.11 or higher.
Takes the profile you wish to monitor as the command line parameter.
"""
import sys
from gi.repository import GObject
from gi.repository import GLib
from idjcmonitor import *
def launch_handler(monitor, profile, pid):
print(f"Hello to IDJC '{profile}' with process ID {pid}.")
def quit_handler(monitor, profile, pid):
print(f"Goodbye to IDJC '{profile}' with process ID {pid}.")
def streamstate_handler(monitor, which, state, where):
print(f"Stream {which} is {('down', 'up')[state]} on connection {where}.")
def recordstate_handler(monitor, which, state, where):
print(f"Recording of {which} has {('stopped', 'started')[state]}"
f" to {where}")
def metadata_handler(monitor, artist, title, album, songname,
music_filename):
print(f"Metadata is: artist: {artist}, title: {title},"
f" album: {album}, filename: {music_filename}")
def frozen_handler(monitor, profile, pid, frozen):
print(f"IDJC '{profile}' with process ID {pid} "
f"is {('no longer frozen', 'frozen')[frozen]}")
def effect_started_handler(monitor, title, pathname, player):
print(f"Effect player {player} is playing {title}")
def effect_stopped_handler(monitor, player):
print(f"Effect player {player} has stopped")
try:
profile = sys.argv[1]
except IndexError:
profile = "default"
monitor = IDJCMonitor(profile)
monitor.connect("launch", launch_handler)
monitor.connect("quit", quit_handler)
monitor.connect("streamstate-changed", streamstate_handler)
monitor.connect("recordstate-changed", recordstate_handler)
monitor.connect("metadata-changed", metadata_handler)
monitor.connect("frozen", frozen_handler)
monitor.connect("effect-started", effect_started_handler)
monitor.connect("effect-stopped", effect_stopped_handler)
try:
GLib.MainLoop().run()
except KeyboardInterrupt:
print("Goodbye from idjcmon")
|