mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 11:51:47 +00:00
33 lines
873 B
TypeScript
33 lines
873 B
TypeScript
import type { YouTubeMusicAppElement } from '@/types/youtube-music-app-element';
|
|
import type { QueueElement } from '@/types/queue';
|
|
|
|
type QueueRendererResponse = {
|
|
queueDatas: {
|
|
content: unknown;
|
|
}[];
|
|
responseContext: unknown;
|
|
trackingParams: string;
|
|
};
|
|
|
|
export const getMusicQueueRenderer = async (
|
|
videoIds: string[],
|
|
): Promise<QueueRendererResponse | null> => {
|
|
const queue = document.querySelector<QueueElement>('#queue');
|
|
const app = document.querySelector<YouTubeMusicAppElement>('ytmusic-app');
|
|
if (!app) return null;
|
|
|
|
const store = queue?.queue.store.store;
|
|
if (!store) return null;
|
|
|
|
return await app.networkManager.fetch<
|
|
QueueRendererResponse,
|
|
{
|
|
queueContextParams: string;
|
|
videoIds: string[];
|
|
}
|
|
>('/music/get_queue', {
|
|
queueContextParams: store.getState().queue.queueContextParams,
|
|
videoIds,
|
|
});
|
|
};
|