-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New plugin to fetch lyrics and create .lrc files #385
base: 2.0
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with the availability of lyrics, but this looks to be a useful utility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only comment is that I think that to make it clear that it is an alternative and not an overriding option, non-synced lyrics need to be called (in the UI and in code) something other than just "Lyrics" i.e. either "standard lyrics" or "unsynced lyrics".
Otherwise, great job.
Sorry for the delay. Thank you both for the reviews! 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this. This is great, and I like how this is ready for synced lyrics as well. I really would want to see more lyrics capabilities in Picard itself (specifically handling of separate lrc files). But in the meantime this plugin helps a lot for existing versions. And lrclib.net is great.
"folderpath": lambda file: os.path.dirname(file), # pylint: disable=unnecessary-lambda | ||
"filename": lambda file: os.path.splitext(os.path.basename(file))[0], | ||
"filename_ext": lambda file: os.path.basename(file), # pylint: disable=unnecessary-lambda | ||
"directory": lambda file: os.path.basename(os.path.dirname(file)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor stylistic comment: in Picard code we tend to use single quoted strings for identifiers or keys (see https://github.com/metabrainz/picard/blob/master/CONTRIBUTING.md#strings-quoting-single-or-double-quotes)
So here we would write:
'directory': lambda file: os.path.basename(os.path.dirname(file))
Same goes for option names above.
Or in code like metadata.get("title")
below, where we usually write:
metadata.get('title')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just few non-blocking comments, overall the code looks good and the feature is very welcome.
Nicely done.
with open(filename, 'w') as file: | ||
file.write(lyrics) | ||
log.debug(f"Created new lyrics file at {filename}") | ||
except OSError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason of the exception might be useful in the error message, and it should be log.error()
not log.debug()
below.
pass | ||
else: | ||
file.metadata["lyrics"] = lyrics | ||
except FileNotFoundError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may as well handle OSError
in case the file exists but cannot be read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt it would be that hard to add support for synched lyrics in Picard so it would be nice to have that supported here too.
Could you code to check Picard for Synced Lyrics support and enable / disable functionality accordingly?
@Sophist-UK The synced lyrics support was actually implemented by @twodoorcoupe in metabrainz/picard#2373 . This is currently not yet in any release version. At the time this gets released the plugin will be needed to be updated anyway. So that part can be updated once it is actually available to users. And maybe we might even have native support for lrc files inside Picard by then |
Thank you guys.
Yeah that's what I would like to focus on next, whenever I find the time.
Unfortunately it's only for id3 for now. For other formats I did not know how to map the tag, though I think once that is decided it would be easy to implement. |
Hello! I wanted to get back into working on the lyrics stuff, so I needed a good way to fetch lyrics and thought to make this plugin.
Besides getting lyrics from lrclib, you can also export/import lyrics to/from an .lrc file.
I saw there are already a couple of unofficial plugins that fetch lyrics with lrclib, but I thought it might be useful to have one in the official list, and I also needed something to easily create lrc files.
These are the available options:
For naming the lrc file, one can also use tags plus some special variables like in the Post Tagging Actions plugin.