parent
d70754238e
commit
6e1eddad82
6 changed files with 38 additions and 9 deletions
|
@ -56,9 +56,7 @@ export default async function(host, patternMatch, url, lang, obj) {
|
|||
});
|
||||
break;
|
||||
case "bilibili":
|
||||
r = await bilibili({
|
||||
id: patternMatch.id.slice(0, 12)
|
||||
});
|
||||
r = await bilibili(patternMatch);
|
||||
break;
|
||||
case "youtube":
|
||||
let fetchInfo = {
|
||||
|
|
|
@ -1,8 +1,23 @@
|
|||
import { genericUserAgent, maxVideoDuration } from "../../config.js";
|
||||
|
||||
// TO-DO: quality picking, bilibili.tv support, and higher quality downloads (currently requires an account)
|
||||
export default async function(obj) {
|
||||
let html = await fetch(`https://bilibili.com/video/${obj.id}`, {
|
||||
export default async function({ id, shortLink }) {
|
||||
if (shortLink) {
|
||||
id = await fetch(`https://b23.tv/${shortLink}`, { redirect: 'manual' })
|
||||
.then(r => r.status > 300 && r.status < 400 && r.headers.get('location'))
|
||||
.then(url => {
|
||||
const path = new URL(url).pathname;
|
||||
if (path.startsWith('/video/'))
|
||||
return path.split('/')[2];
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
if (!id) {
|
||||
return { error: 'ErrorCouldntFetch' };
|
||||
}
|
||||
|
||||
let html = await fetch(`https://bilibili.com/video/${id}`, {
|
||||
headers: { "user-agent": genericUserAgent }
|
||||
}).then((r) => { return r.text() }).catch(() => { return false });
|
||||
if (!html) return { error: 'ErrorCouldntFetch' };
|
||||
|
@ -21,7 +36,7 @@ export default async function(obj) {
|
|||
|
||||
return {
|
||||
urls: [video[0]["baseUrl"], audio[0]["baseUrl"]],
|
||||
audioFilename: `bilibili_${obj.id}_audio`,
|
||||
filename: `bilibili_${obj.id}_${video[0]["width"]}x${video[0]["height"]}.mp4`
|
||||
audioFilename: `bilibili_${id}_audio`,
|
||||
filename: `bilibili_${id}_${video[0]["width"]}x${video[0]["height"]}.mp4`
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"config": {
|
||||
"bilibili": {
|
||||
"alias": "bilibili.com videos",
|
||||
"patterns": ["video/:id"],
|
||||
"patterns": ["video/:id", "_shortLink/:shortLink"],
|
||||
"enabled": true
|
||||
},
|
||||
"reddit": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export const testers = {
|
||||
"bilibili": (patternMatch) =>
|
||||
patternMatch.id?.length <= 12,
|
||||
patternMatch.id?.length <= 12 || patternMatch.shortLink?.length <= 16,
|
||||
|
||||
"instagram": (patternMatch) =>
|
||||
patternMatch.postId?.length <= 12
|
||||
|
|
|
@ -16,6 +16,7 @@ export function aliasURL(url) {
|
|||
url.search = `?v=${encodeURIComponent(parts[2])}`
|
||||
}
|
||||
break;
|
||||
|
||||
case "youtu":
|
||||
if (url.hostname === 'youtu.be' && parts.length >= 2) {
|
||||
/* youtu.be urls can be weird, e.g. https://youtu.be/<id>//asdasd// still works
|
||||
|
@ -25,6 +26,7 @@ export function aliasURL(url) {
|
|||
}`)
|
||||
}
|
||||
break;
|
||||
|
||||
case "pin":
|
||||
if (url.hostname === 'pin.it' && parts.length === 2) {
|
||||
url = new URL(`https://pinterest.com/url_shortener/${
|
||||
|
@ -46,6 +48,12 @@ export function aliasURL(url) {
|
|||
url = new URL(`https://twitch.tv/_/clip/${parts[1]}`);
|
||||
}
|
||||
break;
|
||||
|
||||
case "b23":
|
||||
if (url.hostname === 'b23.tv' && parts.length === 2) {
|
||||
url = new URL(`https://bilibili.com/_shortLink/${parts[1]}`)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return url
|
||||
|
|
|
@ -746,6 +746,14 @@
|
|||
"code": 200,
|
||||
"status": "stream"
|
||||
}
|
||||
}, {
|
||||
"name": "b23.tv shortlink",
|
||||
"url": "https://b23.tv/lbMyOI9",
|
||||
"params": {},
|
||||
"expected": {
|
||||
"code": 200,
|
||||
"status": "stream"
|
||||
}
|
||||
}],
|
||||
"tumblr": [{
|
||||
"name": "at.tumblr link",
|
||||
|
|
Loading…
Reference in a new issue