Skip to content

LDNVN86/SenoDownload-BE

Repository files navigation

⚡ SenoDownload Backend

High-performance video download API powered by NestJS, yt-dlp, and FFmpeg.

NestJS TypeScript yt-dlp License


🚀 Tính năng chính

⚡ YouTube Speed Optimization

Tính năng Mô tả
HLS Priority Ưu tiên định dạng HLS để bypass throttling, tải nhanh gấp 10-20x
Real-time Remux Chuyển đổi HLS (MPEG-TS) → MP4 on-the-fly bằng FFmpeg
Audio Fix Tự động sửa lỗi "Malformed AAC" và codec không tương thích

🎯 Smart Format Selection

Tính năng Mô tả
Dynamic Analysis Phân tích từ yt-dlp, không dùng config cứng
Bitrate Sorting Ưu tiên bitrate cao nhất trong cùng resolution
Codec Labels Hiển thị AV1/VP9/HDR và tag "Nhanh" cho HLS

🔧 Performance & Stability

Tính năng Mô tả
Multi-threading Tải song song với --concurrent-fragments
Memory Streaming Stream trực tiếp, không ghi file tạm
Auto Fallback Tự động chọn format khác khi gặp lỗi

� API Endpoints

Lấy thông tin video

GET /video/formats?url={video_url}

Response:

{
  "title": "Video Title",
  "thumbnail": "https://...",
  "duration": 123,
  "options": [
    {
      "label": "1080p HD (HLS MP4 - Nhanh)",
      "format_id": "616",
      "ext": "mp4",
      "resolution": "1920x1080",
      "type": "audio+video",
      "sizeLabel": "~150 MB"
    }
  ]
}

Tải video

GET /video/download?url={video_url}&format={format_id}&title={title}&size={size}

Headers trả về:

  • Content-Type: video/mp4, audio/mp4, ...
  • Content-Disposition: attachment; filename="..."
  • Content-Length: (nếu biết trước size)

🛠️ Tech Stack

  • Framework: NestJS 10.x
  • Downloader: yt-dlp (bundled via yt-dlp-exec)
  • Transcoder: FFmpeg (via ffmpeg-static)
  • Language: TypeScript 5.x (Strict mode)

� Quick Start

1. Cài đặt

npm install

2. Cấu hình

Tạo file .env:

PORT=8081
YTDL_METADATA_TIMEOUT_MS=30000 # increase on Render if you see timeout errors

3. Chạy server

# Development
npm run start:dev

# Production
npm run build && npm run start:prod

📁 Cấu trúc thư mục

src/
├── main.ts                 # Entry point
├── app.module.ts           # Root module
├── common/
│   └── pipes/              # Validation pipes
├── constants/              # Format configs
├── modules/
│   └── video/
│       ├── video.controller.ts  # API endpoints
│       ├── video.service.ts     # Core logic (900+ lines)
│       └── entities/            # Type definitions
└── utils/                  # Helper functions

🔒 Security

  • Cloudflare Turnstile: Frontend xác thực trước khi gọi API
  • URL Validation: Kiểm tra và whitelist các domain được hỗ trợ
  • Rate Limiting: Có thể cấu hình thêm ở Nginx/Cloudflare

📝 License

MIT License - Xem file LICENSE để biết thêm chi tiết.

Releases

No releases published

Packages

 
 
 

Contributors