mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fix showing old lyrics if new lyrics couldn't be resolved
This commit is contained in:
@ -15,13 +15,22 @@ module.exports = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let hasLyrics = true;
|
||||||
|
|
||||||
const html = ipcRenderer.sendSync(
|
const html = ipcRenderer.sendSync(
|
||||||
"search-genius-lyrics",
|
"search-genius-lyrics",
|
||||||
extractedSongInfo
|
extractedSongInfo
|
||||||
);
|
);
|
||||||
if (!html) {
|
if (!html) {
|
||||||
|
// Delete previous lyrics if tab is open and couldn't get new lyrics
|
||||||
|
checkLyricsContainer(() => {
|
||||||
|
hasLyrics = false;
|
||||||
|
setTabsOnclick(undefined);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
} else if (is.dev()) {
|
}
|
||||||
|
|
||||||
|
if (is.dev()) {
|
||||||
console.log("Fetched lyrics from Genius");
|
console.log("Fetched lyrics from Genius");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,11 +51,7 @@ module.exports = () => {
|
|||||||
|
|
||||||
enableLyricsTab();
|
enableLyricsTab();
|
||||||
|
|
||||||
for (tab of [tabs.upNext, tabs.discover]) {
|
setTabsOnclick(enableLyricsTab);
|
||||||
if (tab) {
|
|
||||||
tab.onclick = enableLyricsTab;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
checkLyricsContainer();
|
checkLyricsContainer();
|
||||||
|
|
||||||
@ -74,12 +79,22 @@ module.exports = () => {
|
|||||||
|
|
||||||
function setLyrics(lyricsContainer) {
|
function setLyrics(lyricsContainer) {
|
||||||
lyricsContainer.innerHTML = `<div id="contents" class="style-scope ytmusic-section-list-renderer description ytmusic-description-shelf-renderer genius-lyrics">
|
lyricsContainer.innerHTML = `<div id="contents" class="style-scope ytmusic-section-list-renderer description ytmusic-description-shelf-renderer genius-lyrics">
|
||||||
${lyrics}
|
${hasLyrics ? lyrics : 'Subtitles could not be retrieved'}
|
||||||
|
|
||||||
<yt-formatted-string class="footer style-scope ytmusic-description-shelf-renderer" style="text-align: initial"></yt-formatted-string>
|
<yt-formatted-string class="footer style-scope ytmusic-description-shelf-renderer" style="text-align: initial"></yt-formatted-string>
|
||||||
</div>`;
|
</div>`;
|
||||||
lyricsContainer.querySelector('.footer').textContent = 'Source: Genius';
|
if (hasLyrics) {
|
||||||
enableLyricsTab();
|
lyricsContainer.querySelector('.footer').textContent = 'Source: Genius';
|
||||||
|
enableLyricsTab();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTabsOnclick(callback) {
|
||||||
|
for (tab of [tabs.upNext, tabs.discover]) {
|
||||||
|
if (tab) {
|
||||||
|
tab.onclick = callback;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableLyricsTab() {
|
function enableLyricsTab() {
|
||||||
|
|||||||
Reference in New Issue
Block a user