mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 12:42:06 +00:00
fix: fix #3661
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import { extractToken, getAuthorizationHeader, getClient } from './client';
|
import type { YouTubeMusicAppElement } from '@/types/youtube-music-app-element';
|
||||||
|
import type { QueueElement } from '@/types/queue';
|
||||||
|
|
||||||
type QueueRendererResponse = {
|
type QueueRendererResponse = {
|
||||||
queueDatas: {
|
queueDatas: {
|
||||||
@ -11,40 +12,15 @@ type QueueRendererResponse = {
|
|||||||
export const getMusicQueueRenderer = async (
|
export const getMusicQueueRenderer = async (
|
||||||
videoIds: string[],
|
videoIds: string[],
|
||||||
): Promise<QueueRendererResponse | null> => {
|
): Promise<QueueRendererResponse | null> => {
|
||||||
const token = extractToken();
|
const queue = document.querySelector<QueueElement>('#queue');
|
||||||
if (!token) return null;
|
const app = document.querySelector<YouTubeMusicAppElement>('ytmusic-app');
|
||||||
|
if (!app) return null;
|
||||||
|
|
||||||
const response = await fetch(
|
const store = queue?.queue.store.store;
|
||||||
'https://music.youtube.com/youtubei/v1/music/get_queue?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30&prettyPrint=false',
|
if (!store) return null;
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
credentials: 'include',
|
|
||||||
body: JSON.stringify({
|
|
||||||
context: {
|
|
||||||
client: getClient(),
|
|
||||||
request: {
|
|
||||||
useSsl: true,
|
|
||||||
internalExperimentFlags: [],
|
|
||||||
consistencyTokenJars: [],
|
|
||||||
},
|
|
||||||
user: {
|
|
||||||
lockedSafetyMode: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
videoIds,
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Origin': 'https://music.youtube.com',
|
|
||||||
'Authorization': await getAuthorizationHeader(token),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const text = await response.text();
|
return (await app.networkManager.fetch('/music/get_queue', {
|
||||||
try {
|
queueContextParams: store.getState().queue.queueContextParams,
|
||||||
return JSON.parse(text) as QueueRendererResponse;
|
videoIds,
|
||||||
} catch {}
|
})) as QueueRendererResponse | null;
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user