mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-27 17:08:28 +00:00
api/processing/url: improve vk url parsing
This commit is contained in:
parent
997b06ed0e
commit
ff06a10b5c
@ -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"],
|
||||
|
@ -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>.*/
|
||||
|
Loading…
Reference in New Issue
Block a user