Closed raffaem closed 4 months ago
You mean the the name of the provider when you get the lyrics? If so, you can capture the provider name from the logs.
import io
import logging
import syncedlyrics
syncedlyrics.logger.setLevel(logging.INFO)
stream = io.StringIO()
syncedlyrics.logger.addHandler(logging.StreamHandler(stream))
syncedlyrics.search("...")
provider = stream.getvalue().split("on ")[1].strip()
print(provider)
stream.close()
I think this is slower.
What about a new class Lyrics
that holds both lyrics and provider, a function lookup
that return Lyrics
, and the search
function just call lookup
and return just the lyrics?
I know it's a bit messy but I don't want to break the simple API since the main goal is to get the lyrics. It's not slow either if you benchmark it.
t1 = time.time()
provider = stream.getvalue().split("on ")[1].strip()
t2 = time.time()
print(round(t2 - t1, 5))
print(provider)
0.0
Musixmatch
I would like to get the provider for the lyrics, but I don't know how without breaking the API.
Maybe have another function, and the existing function calling the new function and returning just the lyrics out of it?