Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/src/processing/service-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const services = {
bilibili: {
patterns: [
"video/:comId",
"video/:comId?p=:episode",
"_shortLink/:comShortLink",
"_tv/:lang/video/:tvId",
"_tv/video/:tvId"
Expand Down
8 changes: 4 additions & 4 deletions api/src/processing/services/bilibili.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ function extractBestQuality(dashData) {
return [ bestVideo, bestAudio ];
}

async function com_download(id) {
let html = await fetch(`https://bilibili.com/video/${id}`, {
async function com_download(id, episode = 1) {
const html = await fetch(`https://bilibili.com/video/${id}?p=${episode}`, {
headers: {
"user-agent": genericUserAgent
}
Expand Down Expand Up @@ -86,14 +86,14 @@ async function tv_download(id) {
};
}

export default async function({ comId, tvId, comShortLink }) {
export default async function ({ comId, tvId, comShortLink, episode }) {
if (comShortLink) {
const patternMatch = await resolveRedirectingURL(`https://b23.tv/${comShortLink}`);
comId = patternMatch?.comId;
}

if (comId) {
return com_download(comId);
return com_download(comId, episode);
} else if (tvId) {
return tv_download(tvId);
}
Expand Down
5 changes: 5 additions & 0 deletions api/src/processing/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ function cleanURL(url) {
limitQuery('xsec_token');
}
break;
case "bilibili":
if (url.searchParams.get('p')) {
limitQuery('p');
}
break;
}

if (stripQuery) {
Expand Down