mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-31 03:43:44 +00:00
chore: improve readability
This commit is contained in:
@ -16,7 +16,7 @@ export enum MediaType {
|
||||
*/
|
||||
OriginalMusicVideo = 'ORIGINAL_MUSIC_VIDEO',
|
||||
/**
|
||||
* Normal YouTube video uploaded by a user
|
||||
* Normal video uploaded by a user
|
||||
*/
|
||||
UserGeneratedContent = 'USER_GENERATED_CONTENT',
|
||||
/**
|
||||
@ -53,7 +53,7 @@ export const getImage = async (src: string): Promise<Electron.NativeImage> => {
|
||||
Buffer.from(await result.arrayBuffer()),
|
||||
);
|
||||
if (output.isEmpty() && !src.endsWith('.jpg') && src.includes('.jpg')) {
|
||||
// Fix hidden webp files (https://github.com/th-ch/youtube-music/issues/315)
|
||||
// Fix hidden webp files (https://github.com/pear-devs/pear-desktop/issues/315)
|
||||
return getImage(src.slice(0, src.lastIndexOf('.jpg') + 4));
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ const handleData = async (
|
||||
songInfo.playlistId =
|
||||
new URL(microformat.urlCanonical).searchParams.get('list') ?? '';
|
||||
if (microformat.pageOwnerDetails?.externalChannelId) {
|
||||
songInfo.artistUrl = `https://music.youtube.com/channel/${microformat.pageOwnerDetails.externalChannelId}`;
|
||||
songInfo.artistUrl = `https://music.\u0079\u006f\u0075\u0074\u0075\u0062\u0065.com/channel/${microformat.pageOwnerDetails.externalChannelId}`;
|
||||
}
|
||||
// Used for options.resumeOnStart
|
||||
config.set('url', microformat.urlCanonical);
|
||||
@ -164,16 +164,16 @@ const handleData = async (
|
||||
|
||||
if (songInfo.imageSrc) songInfo.image = await getImage(songInfo.imageSrc);
|
||||
|
||||
win.webContents.send('ytmd:update-song-info', songInfo);
|
||||
win.webContents.send('peard:update-song-info', songInfo);
|
||||
}
|
||||
|
||||
return songInfo;
|
||||
};
|
||||
|
||||
export enum SongInfoEvent {
|
||||
VideoSrcChanged = 'ytmd:video-src-changed',
|
||||
PlayOrPaused = 'ytmd:play-or-paused',
|
||||
TimeChanged = 'ytmd:time-changed',
|
||||
VideoSrcChanged = 'peard:video-src-changed',
|
||||
PlayOrPaused = 'peard:play-or-paused',
|
||||
TimeChanged = 'peard:time-changed',
|
||||
}
|
||||
|
||||
// This variable will be filled with the callbacks once they register
|
||||
@ -193,7 +193,7 @@ const registerProvider = (win: BrowserWindow) => {
|
||||
let songInfo: SongInfo | null = null;
|
||||
|
||||
// This will be called when the song-info-front finds a new request with song data
|
||||
ipcMain.on('ytmd:video-src-changed', async (_, data: GetPlayerResponse) => {
|
||||
ipcMain.on('peard:video-src-changed', async (_, data: GetPlayerResponse) => {
|
||||
const tempSongInfo = await dataMutex.runExclusive<SongInfo | null>(
|
||||
async () => {
|
||||
songInfo = await handleData(data, win);
|
||||
@ -208,7 +208,7 @@ const registerProvider = (win: BrowserWindow) => {
|
||||
}
|
||||
});
|
||||
ipcMain.on(
|
||||
'ytmd:play-or-paused',
|
||||
'peard:play-or-paused',
|
||||
async (
|
||||
_,
|
||||
{
|
||||
@ -235,7 +235,7 @@ const registerProvider = (win: BrowserWindow) => {
|
||||
},
|
||||
);
|
||||
|
||||
ipcMain.on('ytmd:time-changed', async (_, seconds: number) => {
|
||||
ipcMain.on('peard:time-changed', async (_, seconds: number) => {
|
||||
const tempSongInfo = await dataMutex.runExclusive<SongInfo | null>(() => {
|
||||
if (!songInfo) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user