Skip to content
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

plugin: Synced Lyrics #2207

Merged
merged 41 commits into from
Jul 31, 2024
Merged

plugin: Synced Lyrics #2207

merged 41 commits into from
Jul 31, 2024

Conversation

Non0reo
Copy link
Contributor

@Non0reo Non0reo commented Jul 8, 2024

Hi 👋

I made this plugin to make lyrics synchronous with the music.
I used LRCLIB to get lyrics as it's also another open-source project with an easy-to-use API.

I took code from the lyrics-genius to have a base for my plugin. I modified a part of it so it is compatible with new version of Youtube Music (while adding functionalities do fetch, change, and display lyrics)

@JellyBrick JellyBrick added the enhancement New feature or request label Jul 10, 2024
@ArjixWasTaken
Copy link
Contributor

ArjixWasTaken commented Jul 11, 2024

Thanks for this amazing plugin! ❤️

Just curious, would it be fine if I merged the ideology of my draft plugin refined-lyrics (that has nothing implemented yet 😭) with yours?

By that I mean, if I extended your plugin with the features I planned to have in mine.

  • multiple lyric sources
  • chinese to pinyin
  • japanese to romaji
  • etc

It turns out that I have been way too busy and I've been procrastinating a lot to the point that I can't focus on that plugin.

Copy link
Collaborator

@Su-Yong Su-Yong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend the plugin works with restartNeeded: false. but it's okay, I'm not forcing that. anyway, It seems to be great.

src/plugins/synced-lyrics/index.ts Show resolved Hide resolved
@Non0reo
Copy link
Contributor Author

Non0reo commented Jul 12, 2024

Hi, thanks for your feedbacks

Yeah I have no problems merging your work here 👍
I also planed to add a feature to get plain lyrics from genius when the song does not have any lyrics (and making essentially what lyrics-genius did). Is it pertinent to implement it ? And have you worked on something similar, where in this case I should not bother to implement that ?

@JellyBrick
Copy link
Collaborator

You can get lyrics from YT using youtubei.js

src/plugins/synced-lyrics/index.ts Outdated Show resolved Hide resolved
src/plugins/synced-lyrics/menu.ts Outdated Show resolved Hide resolved
@Non0reo
Copy link
Contributor Author

Non0reo commented Jul 14, 2024

You can get lyrics from YT using youtubei.js

My plan was actually to have an additional source of lyrics and not only lyrics from YouTube as well as giving lyrics of a song even if it's a video. But it seems to be pretty annoying to scrape genius.com, so I don't think that I will try to implement this feature (unless I find a better way to scrape the html from the site)

Comment on lines 27 to 28
// MAGIC: Since the transition takes 300ms, we need to add a delay of 300ms to the current time
currentTime = secToMilisec(t) + 300;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, since this change, the lyrics seems to be displayed too early now. But if the way it worked before would have been a source of error we can keep it like that

@JellyBrick JellyBrick linked an issue Jul 14, 2024 that may be closed by this pull request
2 tasks
@MulverineX MulverineX mentioned this pull request Jul 15, 2024
4 tasks
@chiqors
Copy link

chiqors commented Jul 17, 2024

is this PR ready to test?

@Non0reo Non0reo requested a review from JellyBrick July 17, 2024 20:09
@ArjixWasTaken

This comment was marked as off-topic.

@Non0reo

This comment was marked as off-topic.

@Non0reo
Copy link
Contributor Author

Non0reo commented Jul 17, 2024

@chiqors I theory this plugin is functional

@ArjixWasTaken
Copy link
Contributor

ArjixWasTaken commented Jul 17, 2024

@Non0reo

I am doing some small refactoring, is it ok if I push my changes once done?
Or should I make a PR to your fork?

--

I'll go ahead and make it a PR to your fork.
Done, the PR is here!

@ArjixWasTaken
Copy link
Contributor

ArjixWasTaken commented Jul 18, 2024

In case you did not already do this, I'd suggest you use eslint and prettier, that way the code not only follows our formatting standards, it is also easier to review in pull requests.

PS: I was the one to mark the two comments about the text alignment as off-topic, please do not take offense.

@ArjixWasTaken
Copy link
Contributor

LGTM

Additions like more lyric providers can be done in a separate PR.

So I think we should iron out:

  • translatable strings
  • maybe make more things configurable?
  • when in combination with album theme plugin, the lyrics are really hard to read (when an ad is playing for example)

Are there more stuff left to iron out?

@Non0reo
Copy link
Contributor Author

Non0reo commented Jul 18, 2024

Great for your contribution (you made me realized that my code was not that well written 😅)
For me the plugin seems great as it is, and in addition in what you already said I think we should investigate the followings:

  • Add other lyrics provider (and maybe add plain lyrics provider as I mentioned here)
  • When clicking on the Discover tab and then clicking on the Lyrics tab, the mutation isn't detected and the lyrics don't update correctly
  • Clicking on shuffle playlist button in an album does not trigger the ytmd:update-song-info and thus does not fetch the lyrics. I will create an issue for this one

Appart from that, everything is okay

@ArjixWasTaken
Copy link
Contributor

ArjixWasTaken commented Jul 18, 2024

When clicking on the Discover tab and then clicking on the Lyrics tab, the mutation isn't detected and the lyrics don't update correctly

In my now closed PR for refined-lyrics I made it always enable the lyrics tab, and it always called my code to replace the html within.

https://github.com/ArjixWasTaken/youtube-music/blob/refined-lyrics/src/plugins/refined-lyrics/contexts/renderer.ts

Maybe you can steal use that?
Although the way you and I implemented these, is way too different ngl.

For one, I was using SolidJS instead of generating html.


I can make another PR to migrate this to use SolidJS instead!

@Non0reo
Copy link
Contributor Author

Non0reo commented Jul 18, 2024

Oh cleaver ! I'm not really familiar with SolidJS, and also because you already fixed this issue I think that your PR would be better than my code

@ArjixWasTaken
Copy link
Contributor

ArjixWasTaken commented Jul 19, 2024

looks like I pushed to the wrong origin...
that was part 1, it temporarily broke the plugin as the SolidJS part is not implemented

Update: Working on it right now

@ArjixWasTaken
Copy link
Contributor

ArjixWasTaken commented Jul 21, 2024

@Non0reo I finally migrated the UI code to use SolidJS, there are some kinks I need to iron out though, like the text size is too small, notify the user that no lyrics were found, etc.

@ArjixWasTaken ArjixWasTaken self-assigned this Jul 21, 2024
@ArjixWasTaken
Copy link
Contributor

Other than fixing the styling, I don't think there is much to change for an initial version.

@ArjixWasTaken
Copy link
Contributor

I'll re-review this tomorrow and try to get it merged.

- Change type assertion code
- Replace span to `yt-formatted-string`
- Add refetch button
@JellyBrick
Copy link
Collaborator

need i18n

@ArjixWasTaken
Copy link
Contributor

Added i18n, well, for english at least.

@ArjixWasTaken

This comment was marked as resolved.

@Non0reo
Copy link
Contributor Author

Non0reo commented Jul 30, 2024

I don't know if you're working on it but the text size seems too small. Maybe I did something wrong with my version or something like that though

Also, when the app start for the first time the lyrics arent fetched properly

@ArjixWasTaken
Copy link
Contributor

ArjixWasTaken commented Jul 30, 2024

I don't know if you're working on it but the text size seems too small

The css may need to be updated

Edit: Nope, looks fine for me
image

Also, when the app start for the first time the lyrics arent fetched properly

That is a known bug that I am trying to fix, although your screenshot is different from what I was experiencing
Edit: It is actually a general ytm bug unrelated to this PR.

@ArjixWasTaken
Copy link
Contributor

@JellyBrick any more thoughts?

@JellyBrick JellyBrick merged commit 8ce91b1 into th-ch:master Jul 31, 2024
6 checks passed
@JellyBrick
Copy link
Collaborator

I have a question. What happens if I run lyric-genius and synced lyrics at the same time?

@ArjixWasTaken
Copy link
Contributor

I have a question. What happens if I run lyric-genius and synced lyrics at the same time?

is lyrics-genius even working?
either way, I think it would be better if we removed lyrics genius once synced-lyrics has multiple lyric providers

I'll handle that on my upcoming PR

iryis pushed a commit to iryis/th-ch-ytmusic that referenced this pull request Aug 1, 2024
* Added Plugin File

* Added Logic

* Known issue

* Finished Backend part

* Before cleanup

* Added Style
Removed log

* Fixed time and visibility issues

* Changed lyrics style

* Changed way lyrics are selected

* Fix

* Added style lyrics options

* Cleanup

* Fix lyrics styling
Changed how lyrics status are changed

* Moved code to make file more readable

* Change Tab Size

* Fixed issue with overlapping lyrics

* Removed debug console.log

* Added style adaptation for music videos

* Changed file indent

* Revered back to original pnpm file

* Removed unnecessary option

* Fix lyrics status bug
Removed leftover logs

* Started to implement fetching for genius lyrics

* feat(synced-lyrics): add `addedVersion` field

* Made changes according to feedbacks

* fix: add a delay of 300ms to the current time

- Since the transition takes 300ms, we need to add a delay of 300ms to the current time

* Removed test about genius.com scraping

* Removed 300ms delay

* chore: cleaned up the code

* Specified path and variable

* chore: always enable lyrics tab

* chore: use SolidJS to render the lyrics

* chore: remove useless signal

* chore: feature-parity with original PR (+some nice stuff)

* recreate lock file

* show json decode error

* feat(synced-lyrics): improve ui
- Change type assertion code
- Replace span to `yt-formatted-string`
- Add refetch button

* chore: make the lyric styling a solidjs effect

* feat: i18n

* chore: apply suggestion

---------

Co-authored-by: Su-Yong <[email protected]>
Co-authored-by: JellyBrick <[email protected]>
Co-authored-by: Angelos Bouklis <[email protected]>
@sH1222J
Copy link

sH1222J commented Aug 4, 2024

As a user who enjoys listening to K-pop and J-pop, there are almost no applied lyrics.

@JellyBrick
Copy link
Collaborator

@heyluft
Copy link

heyluft commented Aug 24, 2024

The lyrics for the song are on lrclib, but it doesnt work with the app, it just says 'No lyrics found for this song' 'Refetch lyrics'.

@ArjixWasTaken
Copy link
Contributor

ArjixWasTaken commented Aug 24, 2024

@heyluft this is not the place to hold such discussion, please either open an issue, or comment on an existing issue.

For example there is an existing issue similar to this, that I have made a PR to address it.

That issue and PR are specifically about tracks featuring multiple artists.
If your issue persists on tracks that do not feature multiple artists, then please make a new issue.

And always make sure to give example songs that have lyrics on lrclib but do not display in the app.

@Rairof
Copy link

Rairof commented Aug 24, 2024

I have a question. What happens if I run lyric-genius and synced lyrics at the same time?

is lyrics-genius even working? either way, I think it would be better if we removed lyrics genius once synced-lyrics has multiple lyric providers

I'll handle that on my upcoming PR

Would be great if users could just select the lyric provider manually as well through in plugin settings but by default it should probably be auto selected to whatever source is best whenever multiple lyrics source is implemented <3

@ArjixWasTaken
Copy link
Contributor

Would be great if users could just select the lyric provider manually as well through in plugin settings but by default it should probably be auto selected to whatever source is best whenever multiple lyrics source is implemented <3

I'd imagine a priority order would be best.

@Rairof
Copy link

Rairof commented Aug 24, 2024

I'd imagine a priority order would be best.

Affirmative sir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants