Compare commits

...

14 Commits

Author SHA1 Message Date
c668c24e6f ignore pid file 2026-04-11 11:37:28 -04:00
ebfb990aca auth fallback as wawi plugin sometimes forgets passwords 2026-04-11 11:34:39 -04:00
f8300c9a1f add image for wacup title format 2026-04-08 19:21:39 -04:00
f04cdc5890 add screenshot for title format config 2026-04-08 19:20:45 -04:00
feaf149186 update readme re wawi 2026-04-08 19:14:55 -04:00
e6796aa2e2 loop video 2026-04-08 19:10:52 -04:00
a0c67b4403 fix video 2026-04-08 19:10:03 -04:00
8c6b30fe14 fix video 2026-04-08 19:09:18 -04:00
9f7b980b5c fix video 2026-04-08 19:08:27 -04:00
299d7a4030 Add screenshot/video 2026-04-08 19:06:05 -04:00
79da23eaac Add WACUP download links and testing environment details 2026-04-08 18:47:31 -04:00
7b59cf4ed7 Credit Phil Himsworth and update Wawi download instructions 2026-04-08 18:39:12 -04:00
475794f95b Merge remote main and resolve README.md conflict 2026-04-08 18:36:53 -04:00
45c3288676 Initial commit 2026-04-08 18:31:25 -04:00
7 changed files with 244 additions and 37 deletions

178
.gitignore vendored Normal file
View File

@@ -0,0 +1,178 @@
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Ruff stuff:
.ruff_cache/
# PyPI configuration file
.pypirc
# PID/run file
*.pid

View File

@@ -85,6 +85,9 @@ busctl --user call org.mpris.MediaPlayer2.winamp /org/mpris/MediaPlayer2 org.mpr
- **`winamp_mpris_old.py`**: A previous iteration of the bridge. - **`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. - **`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 ## Development Conventions
- **D-Bus Interface:** Defined via XML introspection string within the `WinampMPRIS` class. - **D-Bus Interface:** Defined via XML introspection string within the `WinampMPRIS` class.

View File

@@ -8,19 +8,26 @@ A Python-based bridge that provides an MPRIS2 interface for Winamp/WACUP on Linu
- **Playback Controls**: Supports Play, Pause, Next, Previous, and Stop via the Winamp Web Interface. - **Playback Controls**: Supports Play, Pause, Next, Previous, and Stop via the Winamp Web Interface.
- **Live Position Tracking**: Extrapolates playback position for smooth progress bars in your desktop's media widget. - **Live Position Tracking**: Extrapolates playback position for smooth progress bars in your desktop's media widget.
- **Robustness**: Gracefully handles Winamp being offline and automatically reconnects when it starts. - **Robustness**: Gracefully handles Winamp being offline and automatically reconnects when it starts.
- **Systemd Integration**: Can be run as a background user service. - **Systemd Integration**: Can be run as a background user service conforming to XDG standards.
- **XDG Compliance**: Installs to `~/.local/bin`, logs to `~/.local/state/winamp-mpris/`, and stores PID in `$XDG_RUNTIME_DIR`.
## Prerequisites ## Prerequisites
### 1. Winamp Web Interface Plugin ### 1. Winamp / WACUP
The bridge communicates with Winamp through the **Winamp Web Interface** plugin. The bridge is designed to work with both classic Winamp and [WACUP](https://getwacup.org.uk/) (Winamp Community Update Project).
- **Download**: [Winamp Web Interface v7.5.10](https://winampheritage.com/plugin/winamp-web-interface/92511) - **Download WACUP**: [https://getwacup.org.uk/preview/](https://getwacup.org.uk/preview/)
- **Testing Environment**: This bridge was primarily tested using **WACUP** installed via [Bottles](https://usebottles.com/) using the `soda-9.0-1` runner.
### 2. Winamp Web Interface Plugin
The bridge communicates with Winamp through the **Winamp Web Interface** plugin (Wawi), originally written by **Phil Himsworth** (2001-2002).
The Wawi v7.5.13 installer `Wawi_7-5-13.exe` is included in this repository. More info can be found at [Winamp Heritage (v7.5.10)](https://winampheritage.com/plugin/winamp-web-interface/92511).
- **Installation**: Install the plugin in Winamp/WACUP. - **Installation**: Install the plugin in Winamp/WACUP.
- **Configuration**: - **Configuration**:
1. Open Winamp Preferences -> Plug-ins -> General Purpose. 1. Open Winamp Preferences -> Plug-ins -> General Purpose.
2. Configure "Winamp Web Interface". 2. Configure "Winamp Web Interface".
3. Set a **Username** (default: `winamp`) and **Password** (default: `llama`). 3. Set a **Username** (default: `winamp`) and **Password** (default: `llama`).
4. Ensure the server is running (default port: `5666`). 4. Ensure the server is running (default port: `5666`).
5. In the **Users** tab, ensure the user has **Play** permissions.
### 2. Winamp/WACUP Title Formatting ### 2. Winamp/WACUP Title Formatting
To ensure the bridge can extract correct metadata, you must configure Winamp to show specific information in its window title. To ensure the bridge can extract correct metadata, you must configure Winamp to show specific information in its window title.
@@ -30,6 +37,7 @@ To ensure the bridge can extract correct metadata, you must configure Winamp to
%artist%%album%%title% | %playback_time%/%length% - Winamp %artist%%album%%title% | %playback_time%/%length% - Winamp
``` ```
*(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 `-`)*.
![](WACUP-Title-Format.png)
### 3. Linux Dependencies ### 3. Linux Dependencies
Install the required Python libraries, `wmctrl`, and `libnotify` (for notifications): Install the required Python libraries, `wmctrl`, and `libnotify` (for notifications):
@@ -43,43 +51,33 @@ sudo dnf install wmctrl libnotify # or sudo apt install wmctrl libnotify
## Installation & Setup ## Installation & Setup
1. **Clone or copy the script** to a local directory (e.g., `~/Scripts/winamp-mpris/`). The project includes an XDG-compliant installer:
2. **Configure Credentials**: If you changed the default username/password in the plugin, update the `AUTH` variable in `winamp_mpris.py`.
### Running Manually
```bash ```bash
python3 winamp_mpris.py chmod +x install.sh
./install.sh
``` ```
### Testing and Debugging This will:
You can use `busctl` to interact with the MPRIS interface: 1. Install the script to `~/.local/bin/winamp-mpris`.
2. Install and enable the systemd user service `winamp-mpris.service`.
3. Start the bridge immediately.
### Logs and Monitoring
- **Logs**: `tail -f ~/.local/state/winamp-mpris/bridge.log`
- **Systemd Logs**: `journalctl --user -u winamp-mpris.service -f`
- **PID File**: `$XDG_RUNTIME_DIR/winamp-mpris.pid`
### Testing with busctl
You can manually interact with the MPRIS interface:
```bash ```bash
# Get playback status # Get playback status
busctl --user get-property org.mpris.MediaPlayer2.winamp /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player PlaybackStatus 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
# Send commands # 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 PlayPause
``` ```
### Running as a systemd User Service
1. **Install the service file**:
```bash
mkdir -p ~/.config/systemd/user/
cp winamp-mpris.service ~/.config/systemd/user/
```
2. **Reload and Enable**:
```bash
systemctl --user daemon-reload
systemctl --user enable --now winamp-mpris.service
```
3. **Monitor Logs**:
```bash
journalctl --user -u winamp-mpris.service -f
```
## Technical Details ## Technical Details
- **D-Bus Bus**: `org.mpris.MediaPlayer2.winamp` - **D-Bus Bus**: `org.mpris.MediaPlayer2.winamp`
@@ -88,6 +86,10 @@ busctl --user call org.mpris.MediaPlayer2.winamp /org/mpris/MediaPlayer2 org.mpr
## Troubleshooting ## Troubleshooting
- **Controls not working**: Ensure the Winamp Web Interface is accessible at `http://localhost:5666` and the credentials in the script match your plugin settings. - **401 Unauthorized**: Ensure the Winamp Web Interface credentials match those in `winamp-mpris` and that the user has "Play" permissions in the plugin's Users tab.
- **Controls not working**: Ensure the Winamp Web Interface is accessible at `http://localhost:5666`.
- **No Metadata**: Ensure `wmctrl -l` can see the Winamp window and the title matches the expected format. - **No Metadata**: Ensure `wmctrl -l` can see the Winamp window and the title matches the expected format.
- **KDE Plasma 6**: If using Plasma 6 on Wayland, you may need to grant "Remote Control" permissions when prompted to allow `wmctrl` to read window titles accurately. - **KDE Plasma 6**: If using Plasma 6 on Wayland, you may need to grant "Remote Control" permissions when prompted.
## Demo
<video controls autoplay muted loop src="Screencast_20260408_184805.mp4"></video>

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
WACUP-Title-Format.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

View File

@@ -14,6 +14,7 @@ from bs4 import BeautifulSoup
# --- CONFIGURATION & XDG PATHS --- # --- CONFIGURATION & XDG PATHS ---
BASE_URL = "http://localhost:5666" BASE_URL = "http://localhost:5666"
AUTH = ('winamp', 'llama') AUTH = ('winamp', 'llama')
POSSIBLE_CREDS = [('winamp', 'llama'), ('winamp', ''), None]
APP_ID = "org.mpris.MediaPlayer2.winamp" APP_ID = "org.mpris.MediaPlayer2.winamp"
DEFAULT_ART = "https://webamp.org/favicon.ico" DEFAULT_ART = "https://webamp.org/favicon.ico"
@@ -39,6 +40,29 @@ logging.basicConfig(
) )
logger = logging.getLogger("winamp-mpris") logger = logging.getLogger("winamp-mpris")
def authenticated_get(url, timeout=2):
"""Helper to perform GET with authentication fallback."""
global AUTH
try:
r = requests.get(url, auth=AUTH, timeout=timeout)
if r.status_code != 401:
return r
except requests.RequestException as e:
raise e
for cred in POSSIBLE_CREDS:
if cred == AUTH:
continue
try:
r = requests.get(url, auth=cred, timeout=timeout)
if r.status_code != 401:
logger.info(f"Authentication fallback successful: switched to {cred}")
AUTH = cred
return r
except requests.RequestException:
continue
return r
def write_pid_file(): def write_pid_file():
try: try:
with open(PID_FILE, "w") as f: with open(PID_FILE, "w") as f:
@@ -127,9 +151,9 @@ class WinampMPRIS:
def _request(self, endpoint): def _request(self, endpoint):
logger.info(f"COMMAND RECEIVED: {endpoint}") logger.info(f"COMMAND RECEIVED: {endpoint}")
try: try:
r = requests.get(f"{BASE_URL}/{endpoint}", auth=AUTH, timeout=2) r = authenticated_get(f"{BASE_URL}/{endpoint}", timeout=2)
if r.status_code == 401: if r.status_code == 401:
msg = "401 Unauthorized: Check gen_httpsrv.dll plugin config. Ensure user 'winamp' has correct password and 'Play' permissions in Users tab." msg = "401 Unauthorized: All authentication attempts failed (winamp:llama, winamp:, anon). Check plugin config."
logger.warning(f"ERROR: {msg}") logger.warning(f"ERROR: {msg}")
subprocess.run(["notify-send", "-u", "critical", "-t", "10000", "Winamp Bridge Auth Error", msg]) subprocess.run(["notify-send", "-u", "critical", "-t", "10000", "Winamp Bridge Auth Error", msg])
elif r.status_code != 200: elif r.status_code != 200:
@@ -334,7 +358,7 @@ def update_loop(player):
# 2. Poll Web UI (Status and Time source) # 2. Poll Web UI (Status and Time source)
try: try:
r = requests.get(f"{BASE_URL}/main", auth=AUTH, timeout=1) r = authenticated_get(f"{BASE_URL}/main", timeout=1)
if r.status_code == 200: if r.status_code == 200:
offline_logged = False offline_logged = False
auth_error_logged = False auth_error_logged = False
@@ -396,12 +420,12 @@ def update_loop(player):
player._album = "" player._album = ""
elif r.status_code == 401: elif r.status_code == 401:
if not auth_error_logged: if not auth_error_logged:
msg = "401 Unauthorized: Check gen_httpsrv.dll plugin config. Ensure user 'winamp' has correct password and 'Play' permissions in Users tab." msg = "401 Unauthorized: All authentication attempts failed (winamp:llama, winamp:, anon). Check plugin config."
logger.warning(f"ERROR: {msg}") logger.warning(f"ERROR: {msg}")
subprocess.run(["notify-send", "-u", "critical", "-t", "10000", "Winamp Bridge Auth Error", msg]) subprocess.run(["notify-send", "-u", "critical", "-t", "10000", "Winamp Bridge Auth Error", msg])
auth_error_logged = True auth_error_logged = True
player._status = "Stopped" player._status = "Stopped"
except requests.exceptions.RequestException: except requests.RequestException:
if not window_title: if not window_title:
if not offline_logged: if not offline_logged:
logger.info("Winamp Web Interface offline and no window found.") logger.info("Winamp Web Interface offline and no window found.")