Skip to content

nitin2122/mp4yt

Repository files navigation

mp4yt logo

mp4yt

Free, open-source video & audio downloader for 1000+ platforms.
Download YouTube, TikTok, Instagram, Twitter/X, Reddit, and more β€” in 4K, HD, or MP3.
Zero tracking. Zero storage. Direct CDN streams.

Live Site Built with Astro Cloudflare Workers Tailwind CSS

License Last Commit Stars Forks


🌐 What is mp4yt?

mp4yt.com is a high-performance, open-source web application that lets you download videos and extract audio (MP3) from 1000+ social platforms β€” including YouTube, TikTok, Instagram, Twitter/X, Reddit, Soundcloud, Twitch, Vimeo, Pinterest, LinkedIn, Dailymotion, and many more.

Built with Astro v6, Tailwind CSS v4, and a blazing-fast Cloudflare Workers edge backend, the platform delivers direct, safe, and lightning-fast media streams from CDNs straight to your device β€” with zero intermediate storage and zero user tracking.


✨ Features

Feature Description
πŸš€ 1000+ Supported Sites YouTube, TikTok (no watermark), Instagram Reels, Twitter/X, Reddit, Twitch Clips, Soundcloud, Vimeo, Pinterest, LinkedIn, Dailymotion, Facebook, and hundreds more.
⚑ Multi-Instance Failover Dynamically routes across 8+ Cobalt downloader instances. If one goes down, the next picks up automatically β€” near 100% uptime.
πŸŽ₯ 144p β†’ 4K + MP3 Offers downloads from 144p, 240p, 360p, 480p, 720p, 1080p, 1440p (2K), 2160p (4K), plus high-fidelity MP3 audio extraction.
πŸ›‘οΈ CORS-Bypassing Proxy Edge-proxied /download-stream endpoint handles CORS and injects Content-Disposition headers so files download directly β€” works on iPhone, Android, and PC.
πŸ€– Smart SEO / Link Previews /watch endpoint detects 30+ bots (Twitterbot, Discordbot, Googlebot, TelegramBot, etc.) and serves dynamic OpenGraph + Twitter Card metadata with real thumbnails and titles. Human visitors get seamlessly redirected.
πŸ”Œ Keep-Alive Cron A serverless Cron Trigger pings all Cobalt endpoints every 5 minutes to keep backend services warm and monitor latency.
πŸ’Ž Premium UI Vercel-inspired design β€” dark/light theme with FOUC prevention, glassmorphic cards, smooth micro-animations, monospaced tech accents, and fluid responsive typography.
πŸ“± PWA Support Offline caching, app manifest, and Service Worker (sw.js) β€” installable on Android, iOS, and Desktop.
πŸ“Š Google Analytics Integrated GA4 tracking (G-LNH5RT5R2G) for traffic insights.
πŸ” SEO Optimized Dedicated landing pages for each platform, JSON-LD structured data, sitemap.xml, robots.txt, and keyword-rich meta tags.

🎯 Supported Platforms

YouTube TikTok Instagram Twitter / X Reddit Facebook
Twitch Soundcloud Vimeo Pinterest LinkedIn Dailymotion
...and 1000+ more via the Cobalt extraction engine

Each major platform has a dedicated SEO landing page (e.g., /tiktok, /instagram, /twitter) optimized for search engine rankings.


πŸ—οΈ Architecture

The application cleanly separates concerns between a static Astro frontend and a high-performance Cloudflare Workers edge backend.

graph TD
    User["πŸ‘€ User / Browser"] -->|Page Views| CF["☁️ Cloudflare CDN & Edge"]
    Crawler["πŸ€– Bot / Crawler"] -->|Shared Link /watch?url=...| CF

    CF -->|Static Assets| Assets["πŸ“¦ Astro Build Output ./dist"]
    CF -->|Dynamic API| Worker["⚑ Cloudflare Worker worker.js"]

    Worker -->|/api/extract| Failover["πŸ”„ Multi-Instance Failover"]
    Worker -->|/download-stream| Stream["πŸ“₯ Stream from Upstream CDN"]
    Worker -->|/watch bot path| SEO["🏷️ Dynamic OpenGraph SSR"]

    Failover -->|Primary| Primary["🟒 Self-Hosted Cobalt"]
    Failover -->|Fallback 1–7| Community["πŸ”΅ Community Cobalt Instances"]
Loading

How It Works

  1. User pastes a URL β†’ The frontend sends a GET /api/extract?url=... request to the Worker.
  2. Worker tries Cobalt instances β†’ Starting with the primary self-hosted instance, falling back across 7+ community servers until one succeeds.
  3. Parallel quality extraction β†’ All quality variants (144p–4K + MP3) are fetched concurrently for maximum speed.
  4. Metadata scraping β†’ The Worker simultaneously scrapes the source page for title, thumbnail, and description.
  5. User picks a format β†’ The frontend displays available formats; user clicks download.
  6. Edge-proxied stream β†’ /download-stream proxies the CDN stream through Cloudflare, injecting proper headers for direct file download on any device.

πŸ› οΈ Tech Stack

Layer Technology Purpose
Frontend Framework Astro v6 Static Site Generation (SSG) β€” pre-compiled, zero-JS-by-default pages
Styling Tailwind CSS v4 Utility-first CSS with fluid responsive design
Edge Backend Cloudflare Workers Serverless API routing, proxy streaming, SEO bot handling
Download Engine Cobalt Open-source media extraction from 1000+ platforms
Deployment Wrangler CLI Build, upload assets, deploy Worker + Cron Triggers
Analytics Google Analytics 4 Traffic and user engagement tracking
PWA Service Worker + Web Manifest Offline support and installability

πŸ“‚ Project Structure

mp4yt/
β”œβ”€β”€ public/                          # Static assets served directly
β”‚   β”œβ”€β”€ favicon.svg                  # SVG favicon
β”‚   β”œβ”€β”€ favicon.ico                  # ICO fallback
β”‚   β”œβ”€β”€ favicon-96x96.png            # PNG favicon
β”‚   β”œβ”€β”€ apple-touch-icon.png         # iOS home screen icon
β”‚   β”œβ”€β”€ web-app-manifest-192x192.png # PWA icon (192px)
β”‚   β”œβ”€β”€ web-app-manifest-512x512.png # PWA icon (512px)
β”‚   β”œβ”€β”€ og-default.png               # Default OpenGraph social preview image
β”‚   β”œβ”€β”€ site.webmanifest             # PWA manifest
β”‚   β”œβ”€β”€ sitemap.xml                  # SEO sitemap
β”‚   β”œβ”€β”€ robots.txt                   # Crawler rules
β”‚   └── sw.js                        # Service Worker for offline caching
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ assets/                      # SVG graphics and vector assets
β”‚   β”œβ”€β”€ layouts/
β”‚   β”‚   └── Layout.astro             # Base HTML shell β€” GA, SEO, PWA, theme FOUC
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ Navbar.astro             # Sticky header with dark/light toggle
β”‚   β”‚   β”œβ”€β”€ Hero.astro               # Main URL input + download engine (39KB of UI logic)
β”‚   β”‚   β”œβ”€β”€ PlatformHero.astro       # Platform-specific hero variant
β”‚   β”‚   β”œβ”€β”€ PlatformSwitcher.astro   # Visual platform selection carousel
β”‚   β”‚   β”œβ”€β”€ SupportedSites.astro     # Grid of supported platform cards
β”‚   β”‚   β”œβ”€β”€ Features.astro           # Feature highlight cards
β”‚   β”‚   β”œβ”€β”€ HowItWorks.astro         # Step-by-step usage guide
β”‚   β”‚   β”œβ”€β”€ SEOContent.astro         # Long-form SEO content section
β”‚   β”‚   β”œβ”€β”€ FAQ.astro                # Accordion FAQ section
β”‚   β”‚   β”œβ”€β”€ Footer.astro             # Site footer with links
β”‚   β”‚   └── Welcome.astro            # Welcome/intro section
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ index.astro              # Homepage
β”‚   β”‚   β”œβ”€β”€ 404.astro                # Custom 404 error page
β”‚   β”‚   β”œβ”€β”€ 500.astro                # Custom 500 error page
β”‚   β”‚   β”œβ”€β”€ about-us.astro           # About page
β”‚   β”‚   β”œβ”€β”€ contact-us.astro         # Contact page
β”‚   β”‚   β”œβ”€β”€ privacy-policy.astro     # Privacy policy
β”‚   β”‚   β”œβ”€β”€ terms-and-conditions.astro # Terms of service
β”‚   β”‚   β”œβ”€β”€ dmca.astro               # DMCA takedown request page
β”‚   β”‚   β”œβ”€β”€ youtube.astro β†’ index    # YouTube-specific SEO landing
β”‚   β”‚   β”œβ”€β”€ tiktok.astro             # TikTok-specific SEO landing
β”‚   β”‚   β”œβ”€β”€ instagram.astro          # Instagram-specific SEO landing
β”‚   β”‚   β”œβ”€β”€ twitter.astro            # Twitter/X-specific SEO landing
β”‚   β”‚   β”œβ”€β”€ facebook.astro           # Facebook-specific SEO landing
β”‚   β”‚   β”œβ”€β”€ reddit.astro             # Reddit-specific SEO landing
β”‚   β”‚   β”œβ”€β”€ twitch.astro             # Twitch-specific SEO landing
β”‚   β”‚   β”œβ”€β”€ soundcloud.astro         # Soundcloud-specific SEO landing
β”‚   β”‚   β”œβ”€β”€ vimeo.astro              # Vimeo-specific SEO landing
β”‚   β”‚   β”œβ”€β”€ pinterest.astro          # Pinterest-specific SEO landing
β”‚   β”‚   β”œβ”€β”€ linkedin.astro           # LinkedIn-specific SEO landing
β”‚   β”‚   └── dailymotion.astro        # Dailymotion-specific SEO landing
β”‚   └── styles/
β”‚       └── global.css               # Tailwind v4 base + custom theme styles
β”‚
β”œβ”€β”€ worker.js                        # Cloudflare Worker β€” API, proxy, SEO, cron (585 lines)
β”œβ”€β”€ wrangler.toml                    # Cloudflare Workers deployment config
β”œβ”€β”€ astro.config.mjs                 # Astro config with Tailwind plugin + dev proxies
β”œβ”€β”€ package.json                     # Dependencies and scripts
└── tsconfig.json                    # TypeScript configuration

βš™οΈ Environment Variables

Configured in wrangler.toml (local dev) or via the Cloudflare dashboard (production):

Variable Type Description
COBALT_API_URL string URL of the primary self-hosted Cobalt API instance
COBALT_FALLBACK_INSTANCES string Comma-separated list of fallback Cobalt instance URLs

The Worker also includes a hardcoded list of 7 community Cobalt instances (sourced from cobalt.directory) as a final fallback layer.


πŸ’» Getting Started

Prerequisites

  • Node.js v22.12.0+
  • npm (included with Node.js)
  • Wrangler CLI (npm install -g wrangler) β€” for Worker development/deployment

Installation

git clone https://github.com/nitin2122/mp4yt.git
cd mp4yt
npm install

Development

Command Description
npm run dev Start Astro dev server at http://localhost:4321
npm run dev:worker Start Cloudflare Worker dev server at http://localhost:8787
npm run dev:full Run both concurrently (frontend + Worker backend)
npm run build Build static assets to ./dist
npm run deploy Build + deploy to Cloudflare Workers

Tip: During development, Astro's dev server proxies /api/*, /download-stream, and /watch to the Worker dev server automatically via astro.config.mjs.


πŸš€ Deployment

This project deploys as a unified Cloudflare Workers application β€” the static Astro site and the Worker backend run together on Cloudflare's edge network.

# 1. Login to Cloudflare
npx wrangler login

# 2. Build and deploy
npm run deploy

Wrangler will:

  1. Run npm run build to compile the Astro site into dist/
  2. Upload static assets to Cloudflare's edge
  3. Deploy worker.js with the ASSETS binding
  4. Configure the */5 * * * * cron trigger for keep-alive pings

Live deployment:(https://mp4yt.com)


πŸ”‘ API Endpoints

Endpoint Method Description
/api/extract?url=<URL> GET Extract download links for all available qualities (144p–4K + MP3) from the given URL
/download-stream?url=<CDN_URL>&filename=<name> GET Proxy-stream a media file through Cloudflare edge with proper download headers
/watch?url=<URL> GET SEO endpoint β€” serves OpenGraph metadata to bots, redirects humans to the app

πŸ“‘ Worker Endpoints Detail

/api/extract

  • Validates the input URL against private/internal network patterns
  • Fires parallel requests across all quality tiers (144p–4K + audio)
  • Uses multi-instance Cobalt failover (primary β†’ env fallbacks β†’ hardcoded community)
  • Scrapes source page metadata (title, thumbnail, description) concurrently
  • Returns deduplicated format list with stream URLs

/download-stream

  • Proxies upstream CDN responses through Cloudflare
  • Injects Content-Disposition: attachment for direct downloads
  • Supports HTTP Range requests for resumable downloads
  • Sanitizes filenames for cross-platform compatibility

/watch

  • Detects 30+ bot user agents via regex
  • For bots: Renders full OpenGraph + Twitter Card HTML with real video metadata
  • For humans: 302 redirects to /#url=<encoded_url> for instant app loading

πŸ“œ License & Disclaimer

This project is built for educational and demonstration purposes. The download engine is powered by Cobalt.

Users are responsible for complying with the terms of service of the respective platforms they extract media from. The authors do not host, store, or distribute any copyrighted content.


Made with ❀️ by Nitin Jangir

About

Free, open-source video & audio downloader for 1000+ platforms. Download YouTube, TikTok, Instagram, Twitter/X videos in 4K or MP3. Built with Astro v6 + Cloudflare Workers.

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages