Compress song info if longer than MM's limit
This commit is contained in:
parent
bb895e9c9a
commit
005818457d
1 changed files with 26 additions and 1 deletions
27
mmmpd
27
mmmpd
|
@ -8,6 +8,7 @@ import datetime
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
import mpd
|
import mpd
|
||||||
|
from ipo import ipo, opi, p
|
||||||
|
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
|
|
||||||
|
@ -56,7 +57,31 @@ def song_string(song_info):
|
||||||
else:
|
else:
|
||||||
artist = song_info.get("artist") or "Unknown artist"
|
artist = song_info.get("artist") or "Unknown artist"
|
||||||
title = song_info.get("title") or "Unknown song"
|
title = song_info.get("title") or "Unknown song"
|
||||||
return f"{artist}{' – ' if artist else ''}{title}"
|
string = f"{artist}{' – ' if artist else ''}{title}"
|
||||||
|
if len(string) > 102:
|
||||||
|
string = (ipo(string) |
|
||||||
|
p(re.sub)(r"\bOrchestr[ea]\b", r"Orch.") |
|
||||||
|
p(re.sub)(r"\bFestival\b", r"Fest.") |
|
||||||
|
p(re.sub)(r"\bSymphon(y|ic)\b", r"Symph.") |
|
||||||
|
p(re.sub)(r"\bHarmon(y|ic)\b", r"Harm.") |
|
||||||
|
p(re.sub)(r"\bPhilharmon(y|ic)\b", r"Phil.") |
|
||||||
|
p(re.sub)(r"\ballegro\b", r"all.", flags=re.IGNORECASE) |
|
||||||
|
p(re.sub)(r"\bandante\b", r"and.", flags=re.IGNORECASE) |
|
||||||
|
p(re.sub)(r"\badagio\b", r"adg.", flags=re.IGNORECASE) |
|
||||||
|
p(re.sub)(r"\bma non troppo\b", r"m.n.t.", flags=re.IGNORECASE) |
|
||||||
|
p(re.sub)(r"\bviolin\b", r"vln.", flags=re.IGNORECASE) |
|
||||||
|
p(re.sub)(r"\bpiano\b", r"pno.", flags=re.IGNORECASE) |
|
||||||
|
p(re.sub)(r"\bmolto\b", r"mlt.", flags=re.IGNORECASE) |
|
||||||
|
p(re.sub)(r"\bespressivo\b", r"essprs.", flags=re.IGNORECASE) |
|
||||||
|
p(re.sub)(r"\bsostenuto\b", r"sost.", flags=re.IGNORECASE) |
|
||||||
|
p(re.sub)(r"\b[Nn]o(?:\. ?| )([0-9])", r"№\1") |
|
||||||
|
p(re.sub)(r"in ([A-Za-z]) ?sharp", r"in \1♯") |
|
||||||
|
p(re.sub)(r"in ([A-Za-z]) ?flat", r"in \1♭") |
|
||||||
|
p(re.sub)(r"in ([A-Z]([#b♭♯])?) ?major", lambda x: f"in {x[1].upper()}", flags=re.IGNORECASE) |
|
||||||
|
p(re.sub)(r"in ([A-Z]([#b♭♯])?) ?minor", lambda x: f"in {x[1].lower()}", flags=re.IGNORECASE) |
|
||||||
|
p(re.sub)(r"\band\b", r"&") |
|
||||||
|
opi)
|
||||||
|
return string
|
||||||
|
|
||||||
|
|
||||||
def formatted_status(mpd_client):
|
def formatted_status(mpd_client):
|
||||||
|
|
Loading…
Reference in a new issue