mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-28 17:38:31 +00:00
api/bilibili: support download episode in collection
This commit is contained in:
parent
4b9644ebdf
commit
f9e3b00ab2
@ -7,6 +7,7 @@ export const services = {
|
|||||||
bilibili: {
|
bilibili: {
|
||||||
patterns: [
|
patterns: [
|
||||||
"video/:comId",
|
"video/:comId",
|
||||||
|
"video/:comId?p=:episode",
|
||||||
"_shortLink/:comShortLink",
|
"_shortLink/:comShortLink",
|
||||||
"_tv/:lang/video/:tvId",
|
"_tv/:lang/video/:tvId",
|
||||||
"_tv/video/:tvId"
|
"_tv/video/:tvId"
|
||||||
|
@ -17,8 +17,12 @@ function extractBestQuality(dashData) {
|
|||||||
return [ bestVideo, bestAudio ];
|
return [ bestVideo, bestAudio ];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function com_download(id) {
|
async function com_download(id , episode = 1) {
|
||||||
let html = await fetch(`https://bilibili.com/video/${id}`, {
|
let fetchUrl = `https://bilibili.com/video/${id}`;
|
||||||
|
if (episode > 1) {
|
||||||
|
fetchUrl += `?p=${episode}`
|
||||||
|
}
|
||||||
|
let html = await fetch(fetchUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
"user-agent": genericUserAgent
|
"user-agent": genericUserAgent
|
||||||
}
|
}
|
||||||
@ -86,14 +90,14 @@ async function tv_download(id) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function({ comId, tvId, comShortLink }) {
|
export default async function ({comId, tvId, comShortLink, episode}) {
|
||||||
if (comShortLink) {
|
if (comShortLink) {
|
||||||
const patternMatch = await resolveRedirectingURL(`https://b23.tv/${comShortLink}`);
|
const patternMatch = await resolveRedirectingURL(`https://b23.tv/${comShortLink}`);
|
||||||
comId = patternMatch?.comId;
|
comId = patternMatch?.comId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comId) {
|
if (comId) {
|
||||||
return com_download(comId);
|
return com_download(comId, episode ? episode : 1);
|
||||||
} else if (tvId) {
|
} else if (tvId) {
|
||||||
return tv_download(tvId);
|
return tv_download(tvId);
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,11 @@ function cleanURL(url) {
|
|||||||
limitQuery('xsec_token');
|
limitQuery('xsec_token');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "bilibili":
|
||||||
|
if (url.searchParams.get('p')) {
|
||||||
|
limitQuery('p');
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stripQuery) {
|
if (stripQuery) {
|
||||||
|
Loading…
Reference in New Issue
Block a user