api/processing/url: improve vk url parsing

This commit is contained in:
wukko 2025-06-24 17:21:32 +06:00
parent 997b06ed0e
commit ff06a10b5c
No known key found for this signature in database
GPG Key ID: 3E30B3F26C7B4AA2
2 changed files with 14 additions and 10 deletions

View File

@ -186,12 +186,13 @@ export const services = {
patterns: [
"video:ownerId_:videoId",
"clip:ownerId_:videoId",
"clips:duplicate?z=clip:ownerId_:videoId",
"videos:duplicate?z=video:ownerId_:videoId",
"video:ownerId_:videoId_:accessKey",
"clip:ownerId_:videoId_:accessKey",
"clips:duplicate?z=clip:ownerId_:videoId_:accessKey",
"videos:duplicate?z=video:ownerId_:videoId_:accessKey"
// links with a duplicate author id and/or zipper query param
"clips:duplicateId",
"videos:duplicateId",
"search/video"
],
subdomains: ["m"],
altDomains: ["vkvideo.ru", "vk.ru"],

View File

@ -17,7 +17,7 @@ function aliasURL(url) {
if (url.pathname.startsWith('/live/') || url.pathname.startsWith('/shorts/')) {
url.pathname = '/watch';
// parts := ['', 'live' || 'shorts', id, ...rest]
url.search = `?v=${encodeURIComponent(parts[2])}`
url.search = `?v=${encodeURIComponent(parts[2])}`;
}
break;
@ -61,23 +61,23 @@ function aliasURL(url) {
case "b23":
if (url.hostname === 'b23.tv' && parts.length === 2) {
url = new URL(`https://bilibili.com/_shortLink/${parts[1]}`)
url = new URL(`https://bilibili.com/_shortLink/${parts[1]}`);
}
break;
case "dai":
if (url.hostname === 'dai.ly' && parts.length === 2) {
url = new URL(`https://dailymotion.com/video/${parts[1]}`)
url = new URL(`https://dailymotion.com/video/${parts[1]}`);
}
break;
case "facebook":
case "fb":
if (url.searchParams.get('v')) {
url = new URL(`https://web.facebook.com/user/videos/${url.searchParams.get('v')}`)
url = new URL(`https://web.facebook.com/user/videos/${url.searchParams.get('v')}`);
}
if (url.hostname === 'fb.watch') {
url = new URL(`https://web.facebook.com/_shortLink/${parts[1]}`)
url = new URL(`https://web.facebook.com/_shortLink/${parts[1]}`);
}
break;
@ -92,6 +92,9 @@ function aliasURL(url) {
if (services.vk.altDomains.includes(url.hostname)) {
url.hostname = 'vk.com';
}
if (url.searchParams.get('z')) {
url = new URL(`https://vk.com/${url.searchParams.get('z')}`);
}
break;
case "xhslink":
@ -106,7 +109,7 @@ function aliasURL(url) {
url.pathname = `/share/${idPart.slice(-32)}`;
}
break;
case "redd":
/* reddit short video links can be treated by changing https://v.redd.it/<id>
to https://reddit.com/video/<id>.*/