ultrabug / py3status

py3status is an extensible i3status wrapper written in python
https://ultrabug.github.io/py3status/
BSD 3-Clause "New" or "Revised" License
883 stars 259 forks source link

make self.py3.replace helper #2242

Open lasers opened 3 months ago

lasers commented 3 months ago

An alternative to PRs listed below.

I copied thresholds code. Minimal test. Allow users to be more specific.

Get placeholders_list first so we can target existing placeholders rather than all placeholders. I don't know if this PR is the optimal solution, just an alternative.

Code untested on this player.. I tested on nvidia_smi. Sorry if you ran into issues.

This is just an idea / experiment.

Please test this.

# Ought to do dict (perform on matched string placeholders)
    replacements = {
        "artist": [
            "([\(\[][^)\]]*?(bonus|demo|edit|explicit|extended|feat|mono|remaster|stereo|version)[^)\]]*?[\)\]])",
            "([\-,;/])([^\-,;/])*(bonus|demo|edit|explicit|extended|feat|mono|remaster|stereo|version).*"
        ],
    }

# Ought to do list. (perform on all string placeholders)
    replacements = [
            "([\(\[][^)\]]*?(bonus|demo|edit|explicit|extended|feat|mono|remaster|stereo|version)[^)\]]*?[\)\]])",
            "([\-,;/])([^\-,;/])*(bonus|demo|edit|explicit|extended|feat|mono|remaster|stereo|version).*"
        ]

Solves https://github.com/ultrabug/py3status/pull/2234#issuecomment-2017989862.

Closes https://github.com/ultrabug/py3status/pull/2234. Closes https://github.com/ultrabug/py3status/pull/2237. #

lasers commented 3 months ago

Ideally, we should separate this into artist and album. Who volunteer?

"([\(\[][^)\]]*?(bonus|demo|edit|explicit|extended|feat|mono|remaster|stereo|version)[^)\]]*?[\)\]])",
"([\-,;/])([^\-,;/])*(bonus|demo|edit|explicit|extended|feat|mono|remaster|stereo|version).*",