youtube-music
youtube-music copied to clipboard
[DEPRECATED] [lyrics] "Song" type lyrics can be changed/translated now
- #1085 for more information about the different types
- I've made it so that the lyrics from the "Song" type can be intercepted and changed, useful because previously they would skip all the lyric and translation plugin options. For example, the song below would have lyrics in Japanese even if my Romanization option was enabled.
- That has changed
You don't need to create a new function, just change the selector
Those changes are fine:
- module.exports = () => {
+ module.exports = (options) => {
- if (!tabs.lyrics?.hasAttribute("disabled")) {
+ if (!(tabs.lyrics?.hasAttribute("disabled") || options.romanizedLyrics)) {
For the rest (choosing the right container in Music
type videos)
you can just change the Selector in checkLyricsContainer
like so:
function checkLyricsContainer(callback = () => {}) {
const lyricsContainers = [
document.querySelector(
'ytmusic-tab-renderer[page-type="MUSIC_PAGE_TYPE_TRACK_LYRICS"] > ytmusic-message-renderer',
),
document.querySelector(
'ytmusic-section-list-renderer[page-type="MUSIC_PAGE_TYPE_TRACK_LYRICS"] .non-expandable.description.ytmusic-description-shelf-renderer',
),
];
lyricsContainers.forEach((lyricsContainer) => {
if (lyricsContainer) {
callback();
setLyrics(lyricsContainer);
lyricsContainer.style.display = "block"; // fix youtube hiding the lyrics sometimes
}
});
}
I've tested this on my pc and it seems to work fine, here's a screenshot of the full changes:
BTW there is a bug because of the extra spacing in setLyrics
, in particular line 84 below - before the ${
https://github.com/th-ch/youtube-music/blob/3b6d66cddc5cdcda82c0798a2fba2652e7cc3df9/plugins/lyrics-genius/front.js#L81-L93
needs to be like this:
function setLyrics(lyricsContainer) {
lyricsContainer.innerHTML =
`<div id="contents" class="style-scope ytmusic-section-list-renderer description ytmusic-description-shelf-renderer genius-lyrics">
${
hasLyrics
? lyrics.trim().replace(/(?:\r\n|\r|\n)/g, "<br/>")
: "Could not retrieve lyrics from genius"
}
</div>
<yt-formatted-string class="footer style-scope ytmusic-description-shelf-renderer" style="align-self: baseline"></yt-formatted-string>`;
if (hasLyrics) {
lyricsContainer.querySelector('.footer').textContent = 'Source: Genius';
enableLyricsTab();
}
}
got it, will change soon
I tried building it myself but it doesn't work
This is a feature I really wanted. Is this an unfinished feature?
I tried building it myself but it doesn't work This is a feature I really wanted. Is this an unfinished feature?
oh i never changed it to the updated because of e;xams;x will get to it soon
Also I like your taste in music haha
@jang-geon Seems to be working on my part; it is possible since the song you're playing is from a fairly recent anime, it has not been uploaded to the database as romanji lyrics. As a result, Youtube fallbacks and uses the lyrics it can find, which are in Japanese. (Really good anime tho!)
Am glad the romanization toggle was included in the last version!
@th-ch Any luck on merging this? I hope the next release can include this change!
Any luck on merging this? I hope the next release can include this change!
Could you rewrite this PR? There have been a lot of changes to the master branch, including the change from JavaScript to TypeScript.
Can we merge this yet? We've updated it and rebased it
@DereC4 The plugin system has been completely rewritten since this PR was created. So, you'll need to rewrite your code based on the current code base.
see https://github.com/th-ch/youtube-music/tree/master/src/plugins/lyrics-genius
Can we merge this yet? We've updated it and rebased it
@DereC4 The plugin system has been completely rewritten since this PR was created. So, you'll need to rewrite your code based on the current code base.
see https://github.com/th-ch/youtube-music/tree/master/src/plugins/lyrics-genius
That's so sad because I worked on this back when I had more time and now job and classes have ramped up again. The original request only changed around 3 files though, if anyone could do the updating
I'll do the updating later this day, I've been busy the past few months so my lyric plugin got delayed.
I'll do the updating later this day, I've been busy the past few months so my lyric plugin got delayed.
sounds awesome
I am afraid, simply updating the code to use the new plugin API won't cut it. Besides, it doesn't make much sense to have a different plugin for every lyric provider. (since having multiple lyric providers is my goal)
So I will be rewriting this from scratch, ofc I'll give credit where it's due. Is it ok if I close this PR?
I am afraid, simply updating the code to use the new plugin API won't cut it. Besides, it doesn't make much sense to have a different plugin for every lyric provider. (since having multiple lyric providers is my goal)
So I will be rewriting this from scratch, ofc I'll give credit where it's due. Is it ok if I close this PR?
Yeah I'll close the PR myself but i thought the plugin itself was staying the same with Lyrics Genius. I'd really appreciate the credit though once u finish
best of luck
(hard to believe this PR has been open for almost a year)