# 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: ```bash 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 in `winamp_mpris.py`) ### Running the Bridge ### Manual Run To start the bridge manually, run: ```bash 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. 1. **Install the service file**: ```bash mkdir -p ~/.config/systemd/user/ cp winamp-mpris.service ~/.config/systemd/user/ ``` 2. **Reload systemd and enable the service**: ```bash systemctl --user daemon-reload systemctl --user enable --now winamp-mpris.service ``` 3. **Check the status**: ```bash 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. ### Testing and Debugging You can use `busctl` to interact with the MPRIS interface: ```bash # Get playback status busctl --user get-property org.mpris.MediaPlayer2.winamp /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player PlaybackStatus # Get current position (in microseconds) busctl --user get-property org.mpris.MediaPlayer2.winamp /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player Position # Get metadata busctl --user get-property org.mpris.MediaPlayer2.winamp /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player Metadata # Send commands busctl --user call org.mpris.MediaPlayer2.winamp /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player PlayPause busctl --user call org.mpris.MediaPlayer2.winamp /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player Next ``` ## 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. > [!NOTE] > The source code in `Wawi Source/` and `gen_httpSrv_systray/` is provided for reference only. The bridge currently interacts with the compiled binaries. ## Development Conventions - **D-Bus Interface:** Defined via XML introspection string within the `WinampMPRIS` class. - **Polling:** Metadata is updated by polling the web interface every 2 seconds in a daemon thread. - **Property Changes:** Uses the `PropertiesChanged` signal 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.