76 .toString("base64");
77
78 const response = await fetch(`https://api.switch-bot.com/${path}`, {
79 headers: {
80 "Authorization": token,
244});
245
246export default app.fetch;
1import ValTown from "https://esm.sh/@valtown/sdk@0.22.0";
2import { fetchValInfo } from "https://esm.town/v/pomdtr/fetchValInfo?v=2";
3
4export async function selfDestruct(importMetaUrl: string) {
5 const { id } = await fetchValInfo(importMetaUrl);
6 const { vals } = new ValTown();
7
2import ValTown from "npm:@valtown/sdk";
3
4export function fetchValInfo(importMetaURL: string) {
5 const vt = new ValTown();
6 const { author, name } = extractValInfo(importMetaURL);
2
3```ts
4import { fetchValInfo } from "https://esm.town/v/pomdtr/fetchValInfo"
5
6const val = await fetchValInfo(import.meta.url)
7
8console.log(val.id)
11## What's the difference with `extractValInfo` ?
12
13@pomdtr/extractValInfo get metadata synchronously by analysing the val import url, while @pomdtr/fetchValInfo perform an http call to the val.town REST api.
14
15Only use `fetchValInfo` if you need some metadata that are not available from `extractValInfo`.
3export default async function scrapeBookMyShow() {
4 const url = "https://in.bookmyshow.com/explore/home/mumbai"; // Example URL, you may need to adjust this
5 const response = await fetch(url, {
6 headers: {
7 "User-Agent":
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
13 * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
14 * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15 * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16 * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
137});
138
139export default modifyFetchHandler(passwordAuth(app.fetch));
8
9async function search(imdbId: string) {
10 const searchResult = await fetch(`${primewireBase}/api/v1/show?key=${primewireApiKey}&imdb_id=${imdbId}`);
11 return await searchResult.json().then((searchResult) => {
12 return searchResult.id;
56 const searchResult = await search(imdbId);
57
58 const title = await fetch(`${primewireBase}/movie/${searchResult}`);
59 const titleResp = await title.text();
60 const embeds = await getStreams(titleResp);
69 const searchResult = await search(imdbId);
70
71 const _season = await fetch(`${primewireBase}/tv/${searchResult}`, {});
72 const season = await _season.text();
73 const seasonPage = load(season);
81 if (!episodeLink) throw new NotFoundError("No episode links found");
82
83 const _title = await fetch(`${primewireBase}/${episodeLink}`);
84 const title = await _title.text();
85 const embeds = await getStreams(title);
11 const start = performance.now();
12 try {
13 const res = await fetch(url);
14 end = performance.now();
15 status = res.status;
22 } catch (e) {
23 end = performance.now();
24 reason = `couldn't fetch: ${e}`;
25 ok = false;
26 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);
578
579 // just launch it, don't wait for the result
580 // const taskRunResponse = await fetch(`${URL}/taskrun`, {
581 const taskRunResponse = fetch(`${URL}/taskrun`, {
582 method: 'POST',
583 headers: {
674}
675
676export default app.fetch;
677export { ModelProvider, modelProvider, ai, test };
678