Video Downloader Shared Code

This directory contains code that is shared between the frontend and backend of the Video Downloader application.

Files

  • utils.ts - Utility functions for formatting, sanitizing, and other common operations

Usage

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";

Available Utilities

  • formatDuration(seconds) - Format seconds to MM:SS or HH:MM:SS
  • formatFileSize(bytes) - Format bytes to human-readable size (KB, MB, GB)
  • extractHostname(url) - Extract clean hostname from URL
  • sanitizeFilename(filename) - Make filenames safe for downloading
  • detectPlatform(url) - Detect which video platform a URL belongs to