Add D-Bus command logging and notify-send alerts for failed commands
This commit is contained in:
@@ -32,13 +32,13 @@ To ensure the bridge can extract correct metadata, you must configure Winamp to
|
|||||||
*(Note: The separator between Artist, Album, and Title should be an en-dash `–` or a simple dash `-`)*.
|
*(Note: The separator between Artist, Album, and Title should be an en-dash `–` or a simple dash `-`)*.
|
||||||
|
|
||||||
### 3. Linux Dependencies
|
### 3. Linux Dependencies
|
||||||
Install the required Python libraries and `wmctrl`:
|
Install the required Python libraries, `wmctrl`, and `libnotify` (for notifications):
|
||||||
```bash
|
```bash
|
||||||
# Python dependencies
|
# Python dependencies
|
||||||
pip install requests pydbus beautifulsoup4 pygobject
|
pip install requests pydbus beautifulsoup4 pygobject
|
||||||
|
|
||||||
# System tool
|
# System tools
|
||||||
sudo dnf install wmctrl # or sudo apt install wmctrl
|
sudo dnf install wmctrl libnotify # or sudo apt install wmctrl libnotify
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installation & Setup
|
## Installation & Setup
|
||||||
|
|||||||
@@ -83,10 +83,17 @@ class WinampMPRIS:
|
|||||||
self._last_update_ts = time.time()
|
self._last_update_ts = time.time()
|
||||||
|
|
||||||
def _request(self, endpoint):
|
def _request(self, endpoint):
|
||||||
|
print(f"COMMAND RECEIVED: {endpoint}")
|
||||||
try:
|
try:
|
||||||
requests.get(f"{BASE_URL}/{endpoint}", auth=AUTH, timeout=2)
|
r = requests.get(f"{BASE_URL}/{endpoint}", auth=AUTH, timeout=2)
|
||||||
|
if r.status_code != 200:
|
||||||
|
msg = f"Failed to send '{endpoint}' to Winamp (Status {r.status_code})."
|
||||||
|
print(f"ERROR: {msg}")
|
||||||
|
subprocess.run(["notify-send", "-u", "critical", "-t", "3000", "Winamp Bridge Error", msg])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Request failed: {e}")
|
msg = f"Connection error while sending '{endpoint}': {e}"
|
||||||
|
print(f"ERROR: {msg}")
|
||||||
|
subprocess.run(["notify-send", "-u", "critical", "-t", "3000", "Winamp Bridge Offline", msg])
|
||||||
|
|
||||||
# MPRIS Methods
|
# MPRIS Methods
|
||||||
def Next(self): self._request("next")
|
def Next(self): self._request("next")
|
||||||
|
|||||||
Reference in New Issue
Block a user