minor refactoring (discord_presence needs full rewrite, obviously) + discord_presence enhancement: read correct station from ff to remove the need to manually edit the script every-fucking-time
This commit is contained in:
31
ff_brotab.py
Normal file
31
ff_brotab.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""Radio Info (FF Tab Info Grabber)"""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import logging
|
||||
import os
|
||||
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
bin_path = os.path.join(os.path.expanduser("~"), ".local", "bin", "bt")
|
||||
|
||||
|
||||
def query_ff() -> tuple[str, str] | None:
|
||||
res: str | None = subprocess.check_output(
|
||||
f"{bin_path} query -title 'CODEY STUFF*'", shell=True
|
||||
).decode() # Utilize brotab to get open tab info
|
||||
if not res:
|
||||
logging.debug("brotab: No matching (radio) tab found")
|
||||
return None
|
||||
tab_name = res.split("\t", maxsplit=1)[
|
||||
1
|
||||
] # Discard brotab output before first \t (tab character)
|
||||
station = tab_name.split("[")[-1].split("]", maxsplit=1)[
|
||||
0
|
||||
] # Extract station from page title
|
||||
track = tab_name.split(" - Radio - ")[1].split(f"[{station}]")[
|
||||
0
|
||||
] # Extract track from page title
|
||||
return (station, track)
|
||||
|
||||
|
||||
print(query_ff())
|
Reference in New Issue
Block a user