mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🎈 pref: 去除YouTube链接解析时不必要的参数
This commit is contained in:
parent
bbbfb6b45e
commit
86f4b770b8
@ -1520,12 +1520,15 @@ export class tools extends plugin {
|
|||||||
try {
|
try {
|
||||||
const urlRex = /(?:https?:\/\/)?(www\.|music\.)?youtube\.com\/[A-Za-z\d._?%&+\-=\/#]*/g;
|
const urlRex = /(?:https?:\/\/)?(www\.|music\.)?youtube\.com\/[A-Za-z\d._?%&+\-=\/#]*/g;
|
||||||
const url2Rex = /(?:https?:\/\/)?youtu\.be\/[A-Za-z\d._?%&+\-=\/#]*/g;
|
const url2Rex = /(?:https?:\/\/)?youtu\.be\/[A-Za-z\d._?%&+\-=\/#]*/g;
|
||||||
|
//移除链接中的不需要的参数
|
||||||
|
function removeParams(url) {
|
||||||
|
return url.replace(/&list=[^&]*/g, '').replace(/&start_radio=[^&]*/g, '').replace(/&index=[^&]*/g, '');
|
||||||
|
}
|
||||||
// 检测操作系统平台
|
// 检测操作系统平台
|
||||||
const isWindows = process.platform === 'win32';
|
const isWindows = process.platform === 'win32';
|
||||||
|
|
||||||
// 匹配并转义 URL 中的 & 符号(仅对 Windows 进行转义)
|
// 匹配并转义 URL 中的 & 符号(仅对 Windows 进行转义)
|
||||||
let url = urlRex.exec(e.msg)?.[0]?.replace(/&/g, isWindows ? '^&' : '&') ||
|
let url = removeParams(urlRex.exec(e.msg)?.[0] || url2Rex.exec(e.msg)?.[0]).replace(/&/g, isWindows ? '^&' : '&')
|
||||||
url2Rex.exec(e.msg)?.[0]?.replace(/&/g, isWindows ? '^&' : '&');
|
|
||||||
//非最高画质,就按照设定的来
|
//非最高画质,就按照设定的来
|
||||||
let graphics = ""
|
let graphics = ""
|
||||||
if (this.YouTubeGraphicsOptions != 0) {
|
if (this.YouTubeGraphicsOptions != 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user