mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 11:01:45 +00:00
chore: improve readability
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import type { LyricProvider, LyricResult, SearchSongInfo } from '../types';
|
||||
import type { YouTubeMusicAppElement } from '@/types/youtube-music-app-element';
|
||||
import type { MusicPlayerAppElement } from '@/types/music-player-app-element';
|
||||
|
||||
const headers = {
|
||||
'Accept': 'application/json',
|
||||
@ -13,7 +13,8 @@ const client = {
|
||||
|
||||
export class YTMusic implements LyricProvider {
|
||||
public name = 'YTMusic';
|
||||
public baseUrl = 'https://music.youtube.com/';
|
||||
public baseUrl =
|
||||
'https://music.\u0079\u006f\u0075\u0074\u0075\u0062\u0065.com/';
|
||||
|
||||
// prettier-ignore
|
||||
public async search(
|
||||
@ -42,7 +43,7 @@ export class YTMusic implements LyricProvider {
|
||||
if (!contents) return null;
|
||||
|
||||
/*
|
||||
NOTE: Due to the nature of Youtubei, the json responses are not consistent,
|
||||
NOTE: Due to the nature of the library, the json responses are not consistent,
|
||||
this means we have to check for multiple possible paths to get the lyrics.
|
||||
*/
|
||||
|
||||
@ -107,7 +108,7 @@ export class YTMusic implements LyricProvider {
|
||||
private PROXIED_ENDPOINT = 'https://ytmbrowseproxy.zvz.be/';
|
||||
|
||||
private fetchNext(videoId: string) {
|
||||
const app = document.querySelector<YouTubeMusicAppElement>('ytmusic-app');
|
||||
const app = document.querySelector<MusicPlayerAppElement>('ytmusic-app');
|
||||
|
||||
if (!app) return null;
|
||||
|
||||
|
||||
@ -6,11 +6,11 @@ import { setConfig, setCurrentTime } from './renderer';
|
||||
import { fetchLyrics } from './store';
|
||||
|
||||
import type { RendererContext } from '@/types/contexts';
|
||||
import type { YoutubePlayer } from '@/types/youtube-player';
|
||||
import type { MusicPlayer } from '@/types/music-player';
|
||||
import type { SongInfo } from '@/providers/song-info';
|
||||
import type { SyncedLyricsPluginConfig } from '../types';
|
||||
|
||||
export let _ytAPI: YoutubePlayer | null = null;
|
||||
export let _ytAPI: MusicPlayer | null = null;
|
||||
export let netFetch: (
|
||||
url: string,
|
||||
init?: RequestInit,
|
||||
@ -44,7 +44,7 @@ export const renderer = createRenderer<
|
||||
}
|
||||
},
|
||||
|
||||
async onPlayerApiReady(api: YoutubePlayer) {
|
||||
async onPlayerApiReady(api: MusicPlayer) {
|
||||
_ytAPI = api;
|
||||
|
||||
api.addEventListener('videodatachange', this.videoDataChange);
|
||||
@ -79,7 +79,7 @@ export const renderer = createRenderer<
|
||||
|
||||
setConfig(await ctx.getConfig());
|
||||
|
||||
ctx.ipc.on('ytmd:update-song-info', (info: SongInfo) => {
|
||||
ctx.ipc.on('peard:update-song-info', (info: SongInfo) => {
|
||||
fetchLyrics(info);
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user