mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 11:01:45 +00:00
fix: use networkManager.fetch instead of fetch
This commit is contained in:
@ -6,7 +6,7 @@ import { t } from '@/i18n';
|
||||
import type { ConnectionEventUnion } from '@/plugins/music-together/connection';
|
||||
import type { Profile, VideoData } from '../types';
|
||||
import type { QueueItem } from '@/types/datahost-get-state';
|
||||
import type { QueueElement } from '@/types/queue';
|
||||
import type { QueueElement, Store } from '@/types/queue';
|
||||
|
||||
const getHeaderPayload = (() => {
|
||||
let payload: {
|
||||
@ -266,7 +266,8 @@ export class Queue {
|
||||
}
|
||||
|
||||
if (this.originalDispatch)
|
||||
this.queue.queue.store.store.dispatch = this.originalDispatch;
|
||||
this.queue.queue.store.store.dispatch = this
|
||||
.originalDispatch as Store['dispatch'];
|
||||
}
|
||||
|
||||
injection() {
|
||||
@ -295,7 +296,11 @@ export class Queue {
|
||||
videoId: it!.videoId,
|
||||
ownerId: this.owner!.id,
|
||||
}) satisfies VideoData,
|
||||
event.payload!.items!,
|
||||
(
|
||||
event.payload! as {
|
||||
items: QueueItem[];
|
||||
}
|
||||
).items,
|
||||
);
|
||||
const index = this._videoList.length + videoList.length - 1;
|
||||
|
||||
@ -334,7 +339,11 @@ export class Queue {
|
||||
videoId: it!.videoId,
|
||||
ownerId: this.owner!.id,
|
||||
}) satisfies VideoData,
|
||||
event.payload!.items!,
|
||||
(
|
||||
event.payload! as {
|
||||
items: QueueItem[];
|
||||
}
|
||||
).items,
|
||||
),
|
||||
},
|
||||
});
|
||||
@ -407,7 +416,13 @@ export class Queue {
|
||||
},
|
||||
},
|
||||
};
|
||||
this.originalDispatch?.call(fakeContext, event);
|
||||
this.originalDispatch?.call(
|
||||
fakeContext,
|
||||
event as {
|
||||
type: string;
|
||||
payload?: { items?: QueueItem[] | undefined } | undefined;
|
||||
},
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import type { LyricProvider, LyricResult, SearchSongInfo } from '../types';
|
||||
import type { YouTubeMusicAppElement } from '@/types/youtube-music-app-element';
|
||||
|
||||
const headers = {
|
||||
'Accept': 'application/json',
|
||||
@ -102,19 +103,17 @@ export class YTMusic implements LyricProvider {
|
||||
.padStart(2, '0')}.${remaining.toString().padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
private ENDPOINT = 'https://youtubei.googleapis.com/youtubei/v1/';
|
||||
// RATE LIMITED (2 req per sec)
|
||||
private PROXIED_ENDPOINT = 'https://ytmbrowseproxy.zvz.be/';
|
||||
|
||||
private fetchNext(videoId: string) {
|
||||
return fetch(this.ENDPOINT + 'next?prettyPrint=false', {
|
||||
headers,
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
videoId,
|
||||
context: { client },
|
||||
}),
|
||||
}).then((res) => res.json()) as Promise<NextData>;
|
||||
const app = document.querySelector<YouTubeMusicAppElement>('ytmusic-app');
|
||||
|
||||
if (!app) return null;
|
||||
|
||||
return app.networkManager.fetch('/next?prettyPrint=false', {
|
||||
videoId,
|
||||
}) as Promise<NextData>;
|
||||
}
|
||||
|
||||
private fetchBrowse(browseId: string) {
|
||||
|
||||
Reference in New Issue
Block a user