3.0 KiB
3.0 KiB
Winamp MPRIS Bridge
A Python-based bridge that provides an MPRIS2 interface for Winamp on Linux, specifically optimized for KDE Plasma 6. It allows Linux desktop environments to control Winamp and display track metadata by interacting with the Winamp Web Interface plugin.
Project Overview
- Purpose: Bridges Winamp's Web Interface to the Linux MPRIS2 D-Bus specification.
- Technologies:
- Python 3: Core logic.
- pydbus: D-Bus communication.
- requests: Communicating with the Winamp Web Interface.
- BeautifulSoup4: Scraping metadata from the Web Interface's HTML.
- PyGObject (GLib): Main event loop and signal handling.
- Architecture: The script runs a background thread that polls the Winamp Web Interface (default:
http://localhost:5666) every 2 seconds, parses the HTML for metadata, and updates the D-Bus properties.
Building and Running
Prerequisites
Ensure you have the following Python libraries installed:
pip install requests pydbus beautifulsoup4 pygobject
You also need the Winamp Web Interface plugin installed and running in Winamp, configured with:
- Base URL:
http://localhost:5666 - Username:
winamp - Password:
llama(These are the current defaults inwinamp_mpris.py)
Running the Bridge
Manual Run
To start the bridge manually, run:
python3 winamp_mpris.py
Running as a systemd User Service
A systemd service file is provided to allow the bridge to run automatically in the background.
- Install the service file:
mkdir -p ~/.config/systemd/user/ cp winamp-mpris.service ~/.config/systemd/user/ - Reload systemd and enable the service:
systemctl --user daemon-reload systemctl --user enable --now winamp-mpris.service - Check the status:
systemctl --user status winamp-mpris.service
The bridge will publish itself on D-Bus as org.mpris.MediaPlayer2.winamp. It gracefully handles Winamp being offline, automatically reconnecting when the web interface becomes available.
Key Files
winamp_mpris.py: The main bridge script. Includes optimizations for Plasma 6 property change detection, live position tracking, and robust error handling.winamp-mpris.service: Systemd user service unit file.winamp_mpris_old.py: A previous iteration of the bridge.sample_Winamp Web Interface.html: A sample of the HTML returned by the Winamp Web Interface, used for reference in parsing logic.
Development Conventions
- D-Bus Interface: Defined via XML introspection string within the
WinampMPRISclass. - Polling: Metadata is updated by polling the web interface every 2 seconds in a daemon thread.
- Property Changes: Uses the
PropertiesChangedsignal to notify the desktop environment of track or status updates. - Error Handling: Basic try-except blocks handle network timeouts or parsing errors, defaulting to "Stopped" or "Offline" states.