9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
import { cli } from '@jackwener/opencli/registry';
|
|
cli({
|
|
site: 'bilibili',
|
|
name: 'hot',
|
|
access: 'read',
|
|
description: 'B站热门视频',
|
|
domain: 'www.bilibili.com',
|
|
args: [
|
|
{ name: 'limit', type: 'int', default: 20, help: 'Number of videos' },
|
|
],
|
|
columns: ['rank', 'title', 'author', 'play', 'danmaku', 'bvid', 'url'],
|
|
pipeline: [
|
|
{ navigate: 'https://www.bilibili.com' },
|
|
{ evaluate: `(async () => {
|
|
const res = await fetch('https://api.bilibili.com/x/web-interface/popular?ps=\${{ args.limit }}&pn=1', {
|
|
credentials: 'include'
|
|
});
|
|
const data = await res.json();
|
|
return (data?.data?.list || []).map((item) => ({
|
|
title: item.title,
|
|
author: item.owner?.name,
|
|
play: item.stat?.view,
|
|
danmaku: item.stat?.danmaku,
|
|
bvid: item.bvid,
|
|
url: item.bvid ? 'https://www.bilibili.com/video/' + item.bvid : '',
|
|
}));
|
|
})()
|
|
` },
|
|
{ map: {
|
|
rank: '${{ index + 1 }}',
|
|
title: '${{ item.title }}',
|
|
author: '${{ item.author }}',
|
|
play: '${{ item.play }}',
|
|
danmaku: '${{ item.danmaku }}',
|
|
bvid: '${{ item.bvid }}',
|
|
url: '${{ item.url }}',
|
|
} },
|
|
{ limit: '${{ args.limit }}' },
|
|
],
|
|
});
|