FichteFoll / discordrp-mpris

Discord Rich Presence through media players providing the mpris2 dbus interface
MIT License
86 stars 19 forks source link

Problem when using mps-youtube and question about Spotify. #4

Closed nipkownix closed 6 years ago

nipkownix commented 6 years ago

Hey man, great utility. But I'm afraid I'm having some issues with it. When using mps-youtube, which does support mpris2, discordrp-mpris exits with this error:

[nipkow@nipkow-ln ~]$ discordrp-mpris INFO:discordrp_mpris.main:Connected to Discord client WARNING:discord_rpc.async:closing connection Traceback (most recent call last): File "/usr/bin/discordrp-mpris", line 11, in load_entry_point('discordrp-mpris==0.1.1', 'console_scripts', 'discordrp-mpris')() File "/usr/lib/python3.6/site-packages/discordrp_mpris/main.py", line 236, in main loop.run_until_complete(wait_task) File "/usr/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete return future.result() File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for return fut.result() File "/usr/lib/python3.6/site-packages/discordrp_mpris/main.py", line 230, in main loop.run_until_complete(main_task) File "/usr/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete return future.result() File "/usr/lib/python3.6/site-packages/discordrp_mpris/main.py", line 222, in main_async await instance.run() File "/usr/lib/python3.6/site-packages/discordrp_mpris/main.py", line 59, in run await self.tick() File "/usr/lib/python3.6/site-packages/discordrp_mpris/main.py", line 69, in tick player = await self.find_active_player() File "/usr/lib/python3.6/site-packages/discordrp_mpris/main.py", line 148, in find_active_player groups = await self.group_players(players) File "/usr/lib/python3.6/site-packages/discordrp_mpris/main.py", line 192, in group_players state = ampris2.PlaybackStatus(await p.player.PlaybackStatus) # type: ignore AttributeError: 'org.mpris.MediaPlayer2.Player' object has no attribute 'PlaybackStatus'

Not sure if there is anything wrong with mps-youtube's mpris implementation. It seems to work fine with other applications such as Cinnamon's "audio/sound" controller.

Also, would it be possible to "disable" discordrp-mpris automatically when Spotify is running? It breaks Discord's integration with Spotify, preventing me from listening songs with friend and such.

FichteFoll commented 6 years ago

Thanks for the feedback. I'm glad people are (somehow) finding this despite myself never advertising it. :slightly_smiling_face:

Not sure if there is anything wrong with mps-youtube's mpris implementation.

From the traceback, it appears that mps-youtube doesn't fully implement the org.mpris.MediaPlayer2.Player interface. PlaybackStatus is not an optional property. Looking at the source code, it doesn't actually seem to be implementing any properties at all and only has method definitions, but I'm not familiar with the dbus package. A quick check with QDBusViewer confirms this.

2018-06-04_12-54-49

Created https://github.com/mps-youtube/mps-youtube/issues/839 upstream.

Also, would it be possible to "disable" discordrp-mpris automatically when Spotify is running?

Added a task to #2 for config to ignore certain players. Been thinking about that for a while, but time has been short which is why I didn't do any commits recently. I didn't know Spotify had an mpris2 interface to begin with, though, so that's perfectly understandable.

FichteFoll commented 6 years ago

Actually, I believe I need to be more aggressive with Spotify running because it's a unique sitation. Will re-open for now.

nipkownix commented 6 years ago

Awesome, man. I will follow the upstream issue you created as well. Thank you so much for looking into this!

FichteFoll commented 6 years ago

Added a catch for mps-youtube (and similarly weird mpris players) in d36ac87ad9b77538a202c13cc1863025653d3b1e and Spotify is ignored by default now (b12f9b30c70e893822e8e3f7d487917201d428f6). This will work reasonably well for now, as long as you set show_paused to false. Otherwise, a paused player might still fight with a playing Spotify instance.

Let me know if this works for you.

nipkownix commented 6 years ago

Everything is working smoothly now. No more crashes and Spotify is being ignored. Also, thank you for implementing the configuration options! So, am I correct in assuming that mps-youtube and similarly weird players just are not compatible with discordrp-mpris? I'm not familiar with dbus, but from what I understood, hrnr said it's a dbus-python issue, right?

FichteFoll commented 6 years ago

I'm not familiar with dbus, but from what I understood, hrnr said it's a dbus-python issue, right?

Pretty much. dbus-python doesn't seem to have an easy way to have introspectable properties, which the library I use, dbussy, relies on. The properties are there, but dbussy doesn't see them because they are not advertised and thus doesn't allow me to read (or set) them.

I could potentially read the values in a different way or maybe use a different dbus library myself, but I like dbussy and I haven't found a proper one for asyncio yet. It's also not really worth it imo.

So, am I correct in assuming that mps-youtube and similarly weird players just are not compatible with discordrp-mpris?

mps-youtube just won't work until the thing I mention above is addressed. I'm not aware of any other players not working with discordrp-mpris, but I will add them to the readme once I get to know some.