getSpotifyAccessToken
@dthyresson
Script
getSpotifyAccess Token Request an access token for use with the Spotify Web API. Requires environment variables from your Spotify Developers account. SPOTIFY_CLIENT_ID SPOTIFY_CLIENT_SECRET Uses Blob storage to cache the spotify_accessToken based on when the expires_in value in the Spotify Access Token response. Example import { getSpotifyAccessToken } from "https://esm.town/v/dthyresson/getSpotifyAccessToken";
const accessToken = await getSpotifyAccessToken();
console.debug(accessToken)
provideBlob
@postpostscript
HTTP (deprecated)
provideBlob: Return Response Quickly and Poll for the Expensive Parts Example: See @postpostscript/provideBlobExample for full example. You will need to fork this val to use provideBlob on your projects as it uses @std/blob for storage import { Image } from "https://deno.land/x/imagescript@1.2.17/mod.ts";
import { htmlResponse } from "https://esm.town/v/postpostscript/html";
import { provideBlob } from "https://esm.town/v/postpostscript/provideBlob";
export default async function(req: Request) {
const image = provideBlob(async () => {
const png = new Image(100, 100);
png.drawCircle(50, 50, 50, 100);
return png.encode();
}).jsPromise();
return htmlResponse`
<div id="image"></div>
<script>
${image}.then(blob => {
const $img = document.createElement("img")
$img.src = URL.createObjectURL(blob)
document.getElementById("image").appendChild($img)
})
</script>
`;
}
scraper_template
@gwoods22
Script
Website Scraper Template A basic website scraper template that can be ran on an interval to check for changes. It uses blob storage to save whatever data you'd like to compare the website to. Uses my sendNotification val to alert yourself of the change. Steps to use Add the scrapeURL you would like to scrape and pick a name for your blob storage blobKey . Change the "selector" value to fit your needs. cheerio is used to find the part of the page you'd like to check. Adjust the if statement to detect changes and update your blob Craft a message to be sent with sendNotification() function
August 13, 2024