FichteFoll / discordrp-mpris

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

Details field now has limited length #24

Closed luizffgv closed 2 years ago

luizffgv commented 3 years ago

Using textwrap.shorten

I'm not experienced with Python so this might be far from ideal.

Fixes #20

luizffgv commented 3 years ago

I followed the suggestions and updated the pull request. Also, the max_artist_len setting was removed since the details field shortens it if necessary. max_title_len is kept, so large titles don't hide the artists' names

FichteFoll commented 3 years ago

Well, if the limit is 128 bytes and not 128 characters, then we don't save anything by using , since that needs 3 bytes in UTF-8. I was under the assumption that we were limited to characters.

I'll have to test this locally some time, so I'm holding off the merge until then.

luizffgv commented 3 years ago

Well, if the limit is 128 bytes and not 128 characters, then we don't save anything by using , since that needs 3 bytes in UTF-8. I was under the assumption that we were limited to characters.

If I remember correctly the docs say 128 characters but that was not the behavior I observed. That's weird, since the minimum length seems to be actually measured in characters.

That's probably something you will want to test later.

FichteFoll commented 2 years ago

Rebased as f902f6aa88d19b3d9c7c14eb6fa8a91f7454b588 and reworked with 7aefbd9cbcdeafbd40172fa92e07d85e65bb59a4.

Turns out it's indeed characters and not bytes, as I confirmed with a few experiments. Furthermore, I added some dynamic weighting based on the format used, so that we don't need to hard-code the maximum title length to 64. See the commit for details.

I also tagged 0.3.1 with the changes.