-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to pure python library for dbus (#82)
Using the CLI requires system-level dbus packages to be installed, which vary by distro and can sometimes cause problems even when installed if trying to run `spotifycli` in an isolated env (like installing with pipx or uv). To sidestep this issue, switch to using `jeepney`, a pure python implementation of the dbus interface. Since it is lower level, the logic ends up a little bit more complex. This could be improved, but since the changes are still quite small it didn't feel worthwhile at this point. Closes #53. I have written a script to test the output of all the supported CLI endpoints, but writing stable tests would require a bigger refactor, so I won't add it to the commit, I'll just paste it in here (since it doesn't rely on mocking the dbus response and instead requires exact setup). ```python import io import sys from contextlib import redirect_stdout from unittest.mock import patch from spotifycli.spotifycli import main def test_main(): cases = ( ("--status", "Tindersticks - Travelling Light\n"), ("--statusshort", "Tindersticks - Travelling...\n"), ("--statusposition", "Tindersticks - Travelling Light (00:07/04:51)\n"), ("--song", "Travelling Light\n"), ("--songshort", "Travelling...\n"), ("--artist", "Tindersticks\n"), ("--artistshort", "Tindersticks\n"), ("--album", "Tindersticks\n"), ("--position", "(00:07/04:51)\n"), ("--playbackstatus", "▮▮\n"), ("--lyrics", "lyrics not found\n"), ("--arturl", "https://i.scdn.co/image/ab67616d0000b273cdd1aabdf50a42ca4556d31d\n"), ) for flag, expected in cases: f = io.StringIO() with redirect_stdout(f), patch.object(sys, 'argv', ['spotifycli', '--client', 'spotify', flag]): main() result = f.getvalue() assert result == expected ```
- Loading branch information
1 parent
bd96705
commit 108c4d1
Showing
4 changed files
with
46 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
autopep8 | ||
jeepney | ||
lyricwikia | ||
pycodestyle | ||
pylint | ||
setuptools | ||
twine | ||
lyricwikia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters