loskutov / deadbeef-lyricbar

A simple plugin for DeaDBeeF audio player that fetches and shows the song’s lyrics
MIT License
29 stars 8 forks source link

Feature request: save/load lyrics in local file #11

Closed sergei-mironov closed 5 years ago

sergei-mironov commented 5 years ago

A freature request from me: is it possible to support fetching lyrics from local file? Say, from the file named like the song file, but with 'txt' extension.

I believe that sometimes people need to modify the lyrics, for example:

So I imagine following modifications:

loskutov commented 5 years ago

I was actually planning to add an option to fetch lyrics using a user-provided script: that could obviously serve your purpose (at least the "load lyrics from the local file" part) with a simple one-liner. However, I'm not sure when I'm ready to release it; as of now, I can suggest the following workarounds:

sergei-mironov commented 5 years ago

Both of your suggestions are helpful. I didn't know about beets, thanks. For me, beets seems to be a too complex approach, but I'll investigate how could one use it as a tool. FYI, I also managed to setup shell commands to open corresponding txt in external viewer. It works in general, but there are a number of deadbeef bugs, like not exiting until the viewer is closed. Going to report them soon.

Yes, I think that script-based lyrics loading would be nice! Then my wish is to support a kind of optional 'edit' button for editing text in a script-dependent way.

I believe that at the end user wants to control how their data is stored, so imo we more like tools which take our storage preferences into account..

loskutov commented 5 years ago

I've implemented the external fetchers support; it can be configured inside the plugin configuration, the script execution command can use the whole power of DeaDBeeF title formatting. However, no updates on editing yet.

sergei-mironov commented 5 years ago

Looks great, thanks! image

sergei-mironov commented 5 years ago

For reference: my script loads lyrics from local collection. The plugin is configured as getlyrics.sh "%artist%" "%title%" and ~/.local/bin/getlyrics.sh looks like follows:

#!/bin/sh
echo "$0: $@" >&2

LYRICSDIR="$HOME/doc/Music/Chords/"
ARTIST="`echo "$1" | sed 's@^[Tt]he @@'`"
TITLE="$2"

F="$LYRICSDIR/$ARTIST - $TITLE.txt"

if test -f "$F" ; then
  cat "$F"
fi
sergei-mironov commented 5 years ago

Oh, just discovered, that plugin doesn't re-run script for cached lyrics. It may or may not be a problem, depending of requirements. In my eyes it is more a disadvantage because it is not clear how to update the cache if it happens to exist (but I can clean the cache with my script).

sergei-mironov commented 5 years ago

Maybe I found a problem. Load scripts dont work when deadbeef was run not from a terminal. If run from a terminal, everything is fine. Probably some stdin/stdout problem, could you please check?

loskutov commented 5 years ago

I couldn't reproduce your issue, but I've rewritten the script spawning routine, please check if it helped.

loskutov commented 5 years ago

About the caching part: you can right-click your track → Remove Lyrics From Cache.

sergei-mironov commented 5 years ago

Well, OK. 2 news:

loskutov commented 5 years ago

Fixed in ad0de52.