mirror of
https://github.com/YuzuZensai/NekoMelody.git
synced 2026-01-31 14:57:58 +00:00
✨ feat: Switched to playwright
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
"music-metadata": "^8.3.0",
|
"music-metadata": "^8.3.0",
|
||||||
"play-audio": "^0.5.2",
|
"play-audio": "^0.5.2",
|
||||||
"play-dl": "github:YuzuZensai/play-dl-test#test",
|
"play-dl": "github:YuzuZensai/play-dl-test#test",
|
||||||
"puppeteer": "^23.1.0",
|
"playwright": "^1.46.1",
|
||||||
"readable-web-to-node-stream": "^3.0.2",
|
"readable-web-to-node-stream": "^3.0.2",
|
||||||
"speaker": "^0.5.5",
|
"speaker": "^0.5.5",
|
||||||
"yt-dlp-wrap": "^2.3.12"
|
"yt-dlp-wrap": "^2.3.12"
|
||||||
|
|||||||
789
pnpm-lock.yaml
generated
789
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
|
import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
|
||||||
import puppeteer, { Browser } from "puppeteer";
|
import playwright, { Browser } from "playwright";
|
||||||
|
|
||||||
let browser: Browser | null = null;
|
let browser: Browser | null = null;
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ export async function getStream(
|
|||||||
|
|
||||||
export async function getYouTubeFormats(id: string) {
|
export async function getYouTubeFormats(id: string) {
|
||||||
if (!browser) {
|
if (!browser) {
|
||||||
browser = await puppeteer.launch({
|
browser = await playwright["chromium"].launch({
|
||||||
headless: true,
|
headless: true,
|
||||||
args: [
|
args: [
|
||||||
"--disable-gpu",
|
"--disable-gpu",
|
||||||
@@ -82,10 +82,11 @@ export async function getYouTubeFormats(id: string) {
|
|||||||
|
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.goto(`https://www.youtube.com/watch?v=${id}&has_verified=1`, {
|
await page.goto(`https://www.youtube.com/watch?v=${id}&has_verified=1`, {
|
||||||
waitUntil: "networkidle2",
|
waitUntil: "domcontentloaded",
|
||||||
});
|
});
|
||||||
const body = await page.evaluate(() => document.body.innerHTML);
|
const body = await page.evaluate(() => document.body.innerHTML);
|
||||||
page.close();
|
await page.close();
|
||||||
|
await browser.close();
|
||||||
|
|
||||||
const match = body.match(
|
const match = body.match(
|
||||||
/var ytInitialPlayerResponse = (.*?)(?=;\s*<\/script>)/,
|
/var ytInitialPlayerResponse = (.*?)(?=;\s*<\/script>)/,
|
||||||
|
|||||||
Reference in New Issue
Block a user