1
2
3
4
5
6
7
8
9
10
11
12
13
import { get_bilibili } from "https://esm.town/v/rebelpotato/bilibili_methods";
function randint(x) {
return Math.floor(Math.random() * x);
}
const video_url = "https://api.bilibili.com/x/web-interface/dynamic/region?ps=6&rid=1";
export async function get_random_video(cookie) {
let videos = (await get_bilibili(video_url, cookie)).archives;
let video = videos[randint(videos.length)];
return video;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
December 5, 2023