mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
fix: apply fix from eslint
This commit is contained in:
@ -586,7 +586,7 @@ app.whenReady().then(async () => {
|
||||
);
|
||||
try {
|
||||
// Check if shortcut is registered and valid
|
||||
const shortcutDetails = shell.readShortcutLink(shortcutPath); // Throw error if doesn't exist yet
|
||||
const shortcutDetails = shell.readShortcutLink(shortcutPath); // Throw error if it doesn't exist yet
|
||||
if (
|
||||
shortcutDetails.target !== appLocation ||
|
||||
shortcutDetails.appUserModelId !== appID
|
||||
|
||||
@ -30,7 +30,7 @@ import {
|
||||
|
||||
import { fetchFromGenius } from '@/plugins/lyrics-genius/main';
|
||||
import { isEnabled } from '@/config/plugins';
|
||||
import { cleanupName, getImage, SongInfo } from '@/providers/song-info';
|
||||
import { cleanupName, getImage, MediaType, type SongInfo } from '@/providers/song-info';
|
||||
import { getNetFetchAsFetch } from '@/plugins/utils/main';
|
||||
import { cache } from '@/providers/decorators';
|
||||
|
||||
@ -686,6 +686,7 @@ const getMetadata = (info: TrackInfo): CustomSongInfo => ({
|
||||
?.url,
|
||||
views: info.basic_info.view_count!,
|
||||
songDuration: info.basic_info.duration!,
|
||||
mediaType: MediaType.Audio,
|
||||
});
|
||||
|
||||
// This is used to bypass age restrictions
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { JSX, splitProps } from 'solid-js';
|
||||
import { css } from 'solid-styled-components';
|
||||
|
||||
import { cache } from '@/providers/decorators';
|
||||
|
||||
const menuStyle = cache(() => css`
|
||||
|
||||
@ -4,6 +4,7 @@ import { css } from 'solid-styled-components';
|
||||
import { Transition } from 'solid-transition-group';
|
||||
import { autoUpdate, flip, offset, OffsetOptions, size } from '@floating-ui/dom';
|
||||
import { useFloating } from 'solid-floating-ui';
|
||||
|
||||
import { cache } from '@/providers/decorators';
|
||||
|
||||
const panelStyle = cache(() => css`
|
||||
|
||||
@ -9,9 +9,10 @@ import { PanelItem } from './PanelItem';
|
||||
import { IconButton } from './IconButton';
|
||||
import { WindowController } from './WindowController';
|
||||
|
||||
import { cache } from '@/providers/decorators';
|
||||
|
||||
import type { RendererContext } from '@/types/contexts';
|
||||
import type { InAppMenuConfig } from '../constants';
|
||||
import { cache } from '@/providers/decorators';
|
||||
|
||||
const titleStyle = cache(() => css`
|
||||
-webkit-app-region: drag;
|
||||
|
||||
@ -38,7 +38,7 @@ export const fetchFromGenius = async (metadata: SongInfo) => {
|
||||
const songArtist = `${cleanupName(metadata.artist)}`;
|
||||
let lyrics: string | null;
|
||||
|
||||
/* Uses Regex to test the title and artist first for said characters if romanization is enabled. Otherwise normal
|
||||
/* Uses Regex to test the title and artist first for said characters if romanization is enabled. Otherwise, normal
|
||||
Genius Lyrics behavior is observed.
|
||||
*/
|
||||
let hasAsianChars = false;
|
||||
|
||||
@ -74,7 +74,7 @@ export class Connection {
|
||||
return conn;
|
||||
}
|
||||
|
||||
async disconnect() {
|
||||
disconnect() {
|
||||
if (this._mode === 'disconnected') throw new Error('Already disconnected');
|
||||
|
||||
this._mode = 'disconnected';
|
||||
|
||||
@ -76,7 +76,7 @@ export const defaultConfig: ScrobblerPluginConfig = {
|
||||
enabled: false,
|
||||
token: undefined,
|
||||
session_key: undefined,
|
||||
api_root: 'http://ws.audioscrobbler.com/2.0/',
|
||||
api_root: 'https://ws.audioscrobbler.com/2.0/',
|
||||
api_key: '04d76faaac8726e60988e14c105d421a',
|
||||
secret: 'a5d2a36fdf64819290f6982481eaffa2',
|
||||
},
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import registerCallback, { type SongInfo } from '@/providers/song-info';
|
||||
import registerCallback, { MediaType, type SongInfo } from '@/providers/song-info';
|
||||
import { createBackend } from '@/utils';
|
||||
|
||||
import { ScrobblerPluginConfig } from './index';
|
||||
@ -52,7 +52,7 @@ export const backend = createBackend<{
|
||||
if (!songInfo.isPaused) {
|
||||
const configNonnull = this.config!;
|
||||
// Scrobblers normally have no trouble working with official music videos
|
||||
if (!configNonnull.scrobble_other_media && (songInfo.mediaType !== 'AUDIO' && songInfo.mediaType !== 'ORIGINAL_MUSIC_VIDEO')) {
|
||||
if (!configNonnull.scrobble_other_media && (songInfo.mediaType !== MediaType.Audio && songInfo.mediaType !== MediaType.OriginalMusicVideo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1,18 +1,37 @@
|
||||
import { t } from '@/i18n';
|
||||
import { createPlugin } from '@/utils';
|
||||
|
||||
export default createPlugin({
|
||||
export default createPlugin<
|
||||
unknown,
|
||||
unknown,
|
||||
{
|
||||
observer?: MutationObserver;
|
||||
waitForElem(selector: string): Promise<HTMLElement>;
|
||||
start(): void;
|
||||
stop(): void;
|
||||
}
|
||||
>({
|
||||
name: () => t('plugins.skip-disliked-songs.name'),
|
||||
description: () => t('plugins.skip-disliked-songs.description'),
|
||||
restartNeeded: false,
|
||||
renderer: {
|
||||
observer: null as MutationObserver | null,
|
||||
waitForElem(selector: string) {
|
||||
return new Promise<HTMLElement>((resolve) => {
|
||||
const interval = setInterval(() => {
|
||||
const elem = document.querySelector<HTMLElement>(selector);
|
||||
if (!elem) return;
|
||||
|
||||
clearInterval(interval);
|
||||
resolve(elem);
|
||||
});
|
||||
});
|
||||
},
|
||||
start() {
|
||||
this.waitForElem('#like-button-renderer').then((likeBtn) => {
|
||||
this.observer = new MutationObserver(() => {
|
||||
if (likeBtn?.getAttribute('like-status') == 'DISLIKE') {
|
||||
document
|
||||
.querySelector('tp-yt-paper-icon-button.next-button')
|
||||
.querySelector<HTMLButtonElement>('tp-yt-paper-icon-button.next-button')
|
||||
?.click();
|
||||
}
|
||||
});
|
||||
@ -26,16 +45,5 @@ export default createPlugin({
|
||||
stop() {
|
||||
this.observer?.disconnect();
|
||||
},
|
||||
waitForElem(selector) {
|
||||
return new Promise((resolve) => {
|
||||
const interval = setInterval(() => {
|
||||
const elem = document.querySelector(selector);
|
||||
if (!elem) return;
|
||||
|
||||
clearInterval(interval);
|
||||
resolve(elem);
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@ -3,33 +3,37 @@ import { BrowserWindow, ipcMain } from 'electron';
|
||||
|
||||
export default (win: BrowserWindow) => {
|
||||
const commands = {
|
||||
// Playback
|
||||
previous: () => win.webContents.send('ytmd:previous-video'),
|
||||
next: () => win.webContents.send('ytmd:next-video'),
|
||||
playPause: () => win.webContents.send('ytmd:toggle-play'),
|
||||
like: () => win.webContents.send('ytmd:update-like', 'LIKE'),
|
||||
dislike: () => win.webContents.send('ytmd:update-like', 'DISLIKE'),
|
||||
go10sBack: () => win.webContents.send('ytmd:seek-by', -10),
|
||||
go10sForward: () => win.webContents.send('ytmd:seek-by', 10),
|
||||
go1sBack: () => win.webContents.send('ytmd:seek-by', -1),
|
||||
go1sForward: () => win.webContents.send('ytmd:seek-by', 1),
|
||||
shuffle: () => win.webContents.send('ytmd:shuffle'),
|
||||
switchRepeat: (n = 1) => win.webContents.send('ytmd:switch-repeat', n),
|
||||
// General
|
||||
volumeMinus10: () => {
|
||||
ipcMain.once('ytmd:get-volume-return', (_, volume) => {
|
||||
win.webContents.send('ytmd:update-volume', volume - 10);
|
||||
});
|
||||
win.webContents.send('ytmd:get-volume');
|
||||
},
|
||||
volumePlus10: () => {
|
||||
ipcMain.once('ytmd:get-volume-return', (_, volume) => {
|
||||
win.webContents.send('ytmd:update-volume', volume + 10);
|
||||
});
|
||||
win.webContents.send('ytmd:get-volume');
|
||||
},
|
||||
fullscreen: () => win.webContents.send('ytmd:toggle-fullscreen'),
|
||||
muteUnmute: () => win.webContents.send('ytmd:toggle-mute'),
|
||||
// Playback
|
||||
previous: () => win.webContents.send('ytmd:previous-video'),
|
||||
next: () => win.webContents.send('ytmd:next-video'),
|
||||
playPause: () => win.webContents.send('ytmd:toggle-play'),
|
||||
like: () => win.webContents.send('ytmd:update-like', 'LIKE'),
|
||||
dislike: () => win.webContents.send('ytmd:update-like', 'DISLIKE'),
|
||||
go10sBack: () => win.webContents.send('ytmd:seek-by', -10),
|
||||
go10sForward: () => win.webContents.send('ytmd:seek-by', 10),
|
||||
go1sBack: () => win.webContents.send('ytmd:seek-by', -1),
|
||||
go1sForward: () => win.webContents.send('ytmd:seek-by', 1),
|
||||
shuffle: () => win.webContents.send('ytmd:shuffle'),
|
||||
switchRepeat: (n = 1) => win.webContents.send('ytmd:switch-repeat', n),
|
||||
// General
|
||||
volumeMinus10: () => {
|
||||
ipcMain.once('ytmd:get-volume-return', (_, volume) => {
|
||||
win.webContents.send('ytmd:update-volume', volume - 10);
|
||||
});
|
||||
win.webContents.send('ytmd:get-volume');
|
||||
},
|
||||
volumePlus10: () => {
|
||||
ipcMain.once('ytmd:get-volume-return', (_, volume) => {
|
||||
win.webContents.send('ytmd:update-volume', volume + 10);
|
||||
});
|
||||
win.webContents.send('ytmd:get-volume');
|
||||
},
|
||||
fullscreen: () => win.webContents.send('ytmd:toggle-fullscreen'),
|
||||
muteUnmute: () => win.webContents.send('ytmd:toggle-mute'),
|
||||
search: () => win.webContents.sendInputEvent({
|
||||
type: 'keyDown',
|
||||
keyCode: '/',
|
||||
}),
|
||||
};
|
||||
return {
|
||||
...commands,
|
||||
|
||||
@ -7,7 +7,7 @@ import config from '@/config';
|
||||
|
||||
import type { GetPlayerResponse } from '@/types/get-player-response';
|
||||
|
||||
enum MediaType {
|
||||
export enum MediaType {
|
||||
/**
|
||||
* Audio uploaded by the original artist
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user