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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
106edfd
Added Plugin File
Non0reo Jun 18, 2024
d147faf
Added Logic
Non0reo Jun 19, 2024
5b607bb
Known issue
Non0reo Jun 19, 2024
d8bf721
Finished Backend part
Non0reo Jun 21, 2024
87beda8
Before cleanup
Non0reo Jun 24, 2024
eb45d42
Added Style
Non0reo Jun 24, 2024
6644fea
Fixed time and visibility issues
Non0reo Jun 28, 2024
ac913af
Changed lyrics style
Non0reo Jun 28, 2024
956125c
Changed way lyrics are selected
Non0reo Jun 28, 2024
05659ec
Fix
Non0reo Jun 28, 2024
b31d09f
Added style lyrics options
Non0reo Jul 4, 2024
0a30627
Cleanup
Non0reo Jul 7, 2024
f1bbdfe
Fix lyrics styling
Non0reo Jul 7, 2024
3579e2a
Moved code to make file more readable
Non0reo Jul 7, 2024
f6d1dd5
Change Tab Size
Non0reo Jul 7, 2024
f079947
Fixed issue with overlapping lyrics
Non0reo Jul 7, 2024
22da4aa
Removed debug console.log
Non0reo Jul 7, 2024
80ec52e
Added style adaptation for music videos
Non0reo Jul 8, 2024
6e17a9a
Changed file indent
Non0reo Jul 8, 2024
362d6d2
Revered back to original pnpm file
Non0reo Jul 8, 2024
d6d3ea0
Removed unnecessary option
Non0reo Jul 8, 2024
7c794b5
Fix lyrics status bug
Non0reo Jul 10, 2024
141e9cd
Started to implement fetching for genius lyrics
Non0reo Jul 13, 2024
6168dad
feat(synced-lyrics): add `addedVersion` field
Su-Yong Jul 12, 2024
f6113f3
Made changes according to feedbacks
Non0reo Jul 14, 2024
8ee1cdd
fix: add a delay of 300ms to the current time
JellyBrick Jul 14, 2024
c88e6af
Removed test about genius.com scraping
Non0reo Jul 14, 2024
604f79e
Removed 300ms delay
Non0reo Jul 17, 2024
e190797
chore: cleaned up the code
ArjixWasTaken Jul 18, 2024
93654cd
Specified path and variable
Non0reo Jul 19, 2024
ead228f
chore: always enable lyrics tab
ArjixWasTaken Jul 19, 2024
eed166d
chore: use SolidJS to render the lyrics
ArjixWasTaken Jul 21, 2024
2eb52ff
chore: remove useless signal
ArjixWasTaken Jul 21, 2024
e15cc1d
chore: feature-parity with original PR (+some nice stuff)
ArjixWasTaken Jul 28, 2024
df90e80
recreate lock file
ArjixWasTaken Jul 28, 2024
043862a
show json decode error
ArjixWasTaken Jul 28, 2024
3e6fc5a
feat(synced-lyrics): improve ui
Su-Yong Jul 28, 2024
fb79977
Merge branch 'master' into th-ch-master
JellyBrick Jul 28, 2024
bb3a4d6
chore: make the lyric styling a solidjs effect
ArjixWasTaken Jul 28, 2024
80380df
feat: i18n
ArjixWasTaken Jul 28, 2024
12d9647
chore: apply suggestion
ArjixWasTaken Jul 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions electron.vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { resolve, dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

import { UserConfig } from 'vite';
import { defineConfig, defineViteConfig } from 'electron-vite';
import builtinModules from 'builtin-modules';
import viteResolve from 'vite-plugin-resolve';
import Inspect from 'vite-plugin-inspect';
import solidPlugin from 'vite-plugin-solid';

import { pluginVirtualModuleGenerator } from './vite-plugins/plugin-importer.mjs';
import pluginLoader from './vite-plugins/plugin-loader.mjs';

import type { UserConfig } from 'vite';
import { i18nImporter } from './vite-plugins/i18n-importer.mjs';
import solidPlugin from 'vite-plugin-solid';

const __dirname = dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -52,7 +52,10 @@ export default defineConfig({

if (mode === 'development') {
commonConfig.plugins?.push(
Inspect({ build: true, outputDir: join(__dirname, '.vite-inspect/backend') }),
Inspect({
build: true,
outputDir: join(__dirname, '.vite-inspect/backend'),
}),
);
return commonConfig;
}
Expand Down Expand Up @@ -96,7 +99,10 @@ export default defineConfig({

if (mode === 'development') {
commonConfig.plugins?.push(
Inspect({ build: true, outputDir: join(__dirname, '.vite-inspect/preload') }),
Inspect({
build: true,
outputDir: join(__dirname, '.vite-inspect/preload'),
}),
);
return commonConfig;
}
Expand Down Expand Up @@ -143,7 +149,10 @@ export default defineConfig({

if (mode === 'development') {
commonConfig.plugins?.push(
Inspect({ build: true, outputDir: join(__dirname, '.vite-inspect/renderer') }),
Inspect({
build: true,
outputDir: join(__dirname, '.vite-inspect/renderer'),
}),
);
return commonConfig;
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
"@foobar404/wave": "2.0.5",
"@jellybrick/electron-better-web-request": "1.0.4",
"@jellybrick/mpris-service": "2.1.4",
"@skyra/jaro-winkler": "^1.1.1",
"@xhayper/discord-rpc": "1.1.4",
"async-mutex": "0.5.0",
"butterchurn": "3.0.0-beta.4",
Expand Down
23 changes: 16 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 30 additions & 13 deletions src/i18n/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,19 +418,19 @@
"presets": "Presets",
"skip-existing": "Skip existing files",
"download-finish-settings": {
"label": "Download on finish",
"submenu": {
"enabled": "Enabled",
"mode": "Time mode",
"seconds": "Seconds",
"percent": "Percent",
"advanced": "Advanced"
},
"prompt": {
"title": "Configure when to download",
"last-seconds": "Last x seconds",
"last-percent": "After x percent"
}
"label": "Download on finish",
"submenu": {
"enabled": "Enabled",
"mode": "Time mode",
"seconds": "Seconds",
"percent": "Percent",
"advanced": "Advanced"
},
"prompt": {
"title": "Configure when to download",
"last-seconds": "Last x seconds",
"last-percent": "After x percent"
}
}
},
"name": "Downloader",
Expand Down Expand Up @@ -668,6 +668,23 @@
"description": "Automatically Skips non-music parts like intro/outro or parts of music videos where the song isn't playing",
"name": "SponsorBlock"
},
"synced-lyrics": {
"description": "Provides synced lyrics to songs, using providers like LRClib.",
"name": "Synced Lyrics",
"errors": {
"fetch": "⚠️ - An error occurred while fetching the lyrics. Please try again later.",
"not-found": "⚠️ - No lyrics found for this song."
},
"warnings": {
"instrumental": "⚠️ - This is an instrumental song",
"inexact": "⚠️ - The lyrics for this song may not be exact",
"duration-mismatch": "⚠️ - The lyrics may be out of sync due to a duration mismatch."
},
"refetch-btn": {
"normal": "Refetch lyrics",
"fetching": "Fetching..."
}
},
"taskbar-mediacontrol": {
"description": "Control playback from your Windows taskbar",
"name": "Taskbar Media Control"
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/lyrics-genius/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const onRendererLoad = ({
applyLyricsTabState();
}
};

const applyLyricsTabState = () => {
if (lyrics) {
tabs.lyrics.removeAttribute('disabled');
Expand All @@ -86,6 +87,7 @@ export const onRendererLoad = ({
tabs.lyrics.setAttribute('aria-disabled', '');
}
};

const lyricsTabHandler = () => {
const tabContainer = document.querySelector('ytmusic-tab-renderer');
if (!tabContainer) return;
Expand Down
28 changes: 28 additions & 0 deletions src/plugins/synced-lyrics/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import style from './style.css?inline';
import { createPlugin } from '@/utils';

import { SyncedLyricsPluginConfig } from './types';

import { menu } from './menu';
import { renderer } from './renderer';

import { t } from '@/i18n';

export default createPlugin({
name: () => t('plugins.synced-lyrics.name'),
description: () => t('plugins.synced-lyrics.description'),
authors: ['Non0reo', 'ArjixWasTaken'],
restartNeeded: true,
Su-Yong marked this conversation as resolved.
Show resolved Hide resolved
addedVersion: '3.4.X',
config: {
preciseTiming: true,
showLyricsEvenIfInexact: true,
showTimeCodes: false,
defaultTextString: '♪',
lineEffect: 'scale',
} as SyncedLyricsPluginConfig,

menu,
renderer,
stylesheets: [style],
});
138 changes: 138 additions & 0 deletions src/plugins/synced-lyrics/menu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import { MenuItemConstructorOptions } from 'electron';

import { MenuContext } from '@/types/contexts';
import { SyncedLyricsPluginConfig } from './types';

export const menu = async ({
getConfig,
setConfig,
}: MenuContext<SyncedLyricsPluginConfig>): Promise<
MenuItemConstructorOptions[]
> => {
const config = await getConfig();

return [
{
label: 'Make the lyrics perfectly synced',
toolTip:
'Calculate to the milisecond the display of the next line (can have a small impact on performance)',
type: 'checkbox',
checked: config.preciseTiming,
click(item) {
setConfig({
preciseTiming: item.checked,
});
},
},
{
label: 'Line effect',
toolTip: 'Choose the effect to apply to the current line',
type: 'submenu',
submenu: [
{
label: 'Scale',
toolTip: 'Scale the current line',
type: 'radio',
checked: config.lineEffect === 'scale',
click() {
setConfig({
lineEffect: 'scale',
});
},
},
{
label: 'Offset',
toolTip: 'Offset on the right the current line',
type: 'radio',
checked: config.lineEffect === 'offset',
click() {
setConfig({
lineEffect: 'offset',
});
},
},
{
label: 'Focus',
toolTip: 'Make only the current line white',
type: 'radio',
checked: config.lineEffect === 'focus',
click() {
setConfig({
lineEffect: 'focus',
});
},
},
],
},
{
label: 'Default character between lyrics',
toolTip: 'Choose the default string to use for the gap between lyrics',
type: 'submenu',
submenu: [
{
label: '♪',
type: 'radio',
checked: config.defaultTextString === '♪',
click() {
setConfig({
defaultTextString: '♪',
});
},
},
{
label: '[SPACE]',
type: 'radio',
checked: config.defaultTextString === ' ',
click() {
setConfig({
defaultTextString: ' ',
});
},
},
{
label: '...',
type: 'radio',
checked: config.defaultTextString === '...',
click() {
setConfig({
defaultTextString: '...',
});
},
},
{
label: '———',
type: 'radio',
checked: config.defaultTextString === '———',
click() {
setConfig({
defaultTextString: '———',
});
},
},
],
},
{
label: 'Show time codes',
toolTip: 'Show the time codes next to the lyrics',
type: 'checkbox',
checked: config.showTimeCodes,
click(item) {
setConfig({
showTimeCodes: item.checked,
});
},
},
{
label: 'Show lyrics even if inexact',
toolTip:
'If the song is not found, the plugin tries again with a different search query.\nThe result from the second attempt may not be exact.',
type: 'checkbox',
checked: config.showLyricsEvenIfInexact,
click(item) {
setConfig({
showLyricsEvenIfInexact: item.checked,
});
},
},
];
};
Loading
Loading