videodownloader
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
This directory contains code that is shared between the frontend and backend of the Video Downloader application.
utils.ts- Utility functions for formatting, sanitizing, and other common operations
These utilities can be imported in both frontend and backend code. For example:
// In backend code
import { formatDuration } from "../shared/utils.ts";
// In frontend code (via import in HTML)
import { formatDuration } from "/shared/utils.ts";
formatDuration(seconds)- Format seconds to MM:SS or HH:MM:SSformatFileSize(bytes)- Format bytes to human-readable size (KB, MB, GB)extractHostname(url)- Extract clean hostname from URLsanitizeFilename(filename)- Make filenames safe for downloadingdetectPlatform(url)- Detect which video platform a URL belongs to