Release v1.6.0: Add youtube-downloader skill
- Add youtube-downloader v1.0.0 - Update marketplace to v1.6.0 - Comprehensive YouTube video/audio downloading with yt-dlp - Android client workaround for nsig extraction issues - Audio-only MP3 conversion - Format selection and network error handling - Demo GIF and comprehensive documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
"email": "daymadev89@gmail.com"
|
||||
},
|
||||
"metadata": {
|
||||
"description": "Professional Claude Code skills for GitHub operations, document conversion, diagram generation, statusline customization, Teams communication, repomix utilities, skill creation, CLI demo generation, LLM icon access, Cloudflare troubleshooting, UI design system extraction, and professional presentation creation",
|
||||
"version": "1.5.0",
|
||||
"description": "Professional Claude Code skills for GitHub operations, document conversion, diagram generation, statusline customization, Teams communication, repomix utilities, skill creation, CLI demo generation, LLM icon access, Cloudflare troubleshooting, UI design system extraction, professional presentation creation, and YouTube video downloading",
|
||||
"version": "1.6.0",
|
||||
"homepage": "https://github.com/daymade/claude-code-skills"
|
||||
},
|
||||
"plugins": [
|
||||
@@ -129,6 +129,16 @@
|
||||
"category": "productivity",
|
||||
"keywords": ["presentation", "powerpoint", "pptx", "slides", "marp", "charts", "data-visualization", "pyramid-principle"],
|
||||
"skills": ["./ppt-creator"]
|
||||
},
|
||||
{
|
||||
"name": "youtube-downloader",
|
||||
"description": "Download YouTube videos and audio using yt-dlp with robust error handling. Use when users request downloading YouTube videos, extracting audio from YouTube, or need help with yt-dlp download issues like nsig extraction failures or network problems",
|
||||
"source": "./",
|
||||
"strict": false,
|
||||
"version": "1.0.0",
|
||||
"category": "utilities",
|
||||
"keywords": ["youtube", "yt-dlp", "video-download", "audio-extraction", "mp3", "download", "youtube-dl"],
|
||||
"skills": ["./youtube-downloader"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
46
CHANGELOG.md
46
CHANGELOG.md
@@ -25,6 +25,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Security
|
||||
- None
|
||||
|
||||
## [1.6.0] - 2025-10-26
|
||||
|
||||
### Added
|
||||
- **New Skill**: youtube-downloader - YouTube video and audio downloading with yt-dlp
|
||||
- Download YouTube videos and playlists with robust error handling
|
||||
- Audio-only download with MP3 conversion
|
||||
- Android client workaround for nsig extraction issues (automatic)
|
||||
- Format listing and custom format selection
|
||||
- Network error handling for proxy/restricted environments
|
||||
- Bundled Python script: `download_video.py` with yt-dlp availability check
|
||||
- Comprehensive troubleshooting documentation for common yt-dlp issues
|
||||
- Demo tape file and GIF showing download workflow
|
||||
|
||||
### Changed
|
||||
- Updated marketplace.json from 12 to 13 skills
|
||||
- Updated marketplace version from 1.5.0 to 1.6.0
|
||||
- Enhanced marketplace metadata description to include YouTube downloading capability
|
||||
- Updated CLAUDE.md with complete 13-skill listing
|
||||
- Updated CLAUDE.md marketplace version to v1.6.0
|
||||
- Updated README.md to reflect 13 available skills
|
||||
- Updated README.md badges (skills count, version)
|
||||
- Added youtube-downloader to manual installation instructions
|
||||
- Added youtube-downloader use case section in README
|
||||
- Added youtube-downloader to documentation quick links
|
||||
- Added yt-dlp to requirements section
|
||||
|
||||
## [1.5.0] - 2025-10-26
|
||||
|
||||
### Added
|
||||
- **New Skill**: ppt-creator - Professional presentation creation with dual-path PPTX generation
|
||||
- Pyramid Principle structure (conclusion → reasons → evidence)
|
||||
- Assertion-evidence slide framework
|
||||
- Automatic data synthesis and chart generation (matplotlib)
|
||||
- Dual-path PPTX creation (Marp CLI + document-skills:pptx)
|
||||
- Complete orchestration: content → data → charts → PPTX with charts
|
||||
- 45-60 second speaker notes per slide
|
||||
- Quality scoring with auto-refinement (target: 75/100)
|
||||
|
||||
### Changed
|
||||
- Updated marketplace.json from 11 to 12 skills
|
||||
- Updated marketplace version from 1.4.0 to 1.5.0
|
||||
|
||||
## [1.4.0] - 2025-10-25
|
||||
|
||||
### Added
|
||||
@@ -136,7 +178,9 @@ We use [Semantic Versioning](https://semver.org/):
|
||||
4. Create git tag: `git tag -a v1.x.x -m "Release v1.x.x"`
|
||||
5. Push tag: `git push origin v1.x.x`
|
||||
|
||||
[Unreleased]: https://github.com/daymade/claude-code-skills/compare/v1.4.0...HEAD
|
||||
[Unreleased]: https://github.com/daymade/claude-code-skills/compare/v1.6.0...HEAD
|
||||
[1.6.0]: https://github.com/daymade/claude-code-skills/compare/v1.5.0...v1.6.0
|
||||
[1.5.0]: https://github.com/daymade/claude-code-skills/compare/v1.4.0...v1.5.0
|
||||
[1.4.0]: https://github.com/daymade/claude-code-skills/compare/v1.3.0...v1.4.0
|
||||
[1.3.0]: https://github.com/daymade/claude-code-skills/compare/v1.2.0...v1.3.0
|
||||
[1.2.0]: https://github.com/daymade/claude-code-skills/compare/v1.1.0...v1.2.0
|
||||
|
||||
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
## Repository Overview
|
||||
|
||||
This is a Claude Code skills marketplace containing 12 production-ready skills organized in a plugin marketplace structure. Each skill is a self-contained package that extends Claude's capabilities with specialized knowledge, workflows, and bundled resources.
|
||||
This is a Claude Code skills marketplace containing 13 production-ready skills organized in a plugin marketplace structure. Each skill is a self-contained package that extends Claude's capabilities with specialized knowledge, workflows, and bundled resources.
|
||||
|
||||
**Essential Skill**: `skill-creator` is the most important skill in this marketplace - it's a meta-skill that enables users to create their own skills. Always recommend it first for users interested in extending Claude Code.
|
||||
|
||||
@@ -118,7 +118,7 @@ Skills for public distribution must NOT contain:
|
||||
## Marketplace Configuration
|
||||
|
||||
The marketplace is configured in `.claude-plugin/marketplace.json`:
|
||||
- Contains 12 plugins, each mapping to one skill
|
||||
- Contains 13 plugins, each mapping to one skill
|
||||
- Each plugin has: name, description, version, category, keywords, skills array
|
||||
- Marketplace metadata: name, owner, version, homepage
|
||||
|
||||
@@ -128,7 +128,7 @@ The marketplace is configured in `.claude-plugin/marketplace.json`:
|
||||
|
||||
1. **Marketplace Version** (`.claude-plugin/marketplace.json` → `metadata.version`)
|
||||
- Tracks the marketplace catalog as a whole
|
||||
- Current: v1.5.0
|
||||
- Current: v1.6.0
|
||||
- Bump when: Adding/removing skills, major marketplace restructuring
|
||||
- Semantic versioning: MAJOR.MINOR.PATCH
|
||||
|
||||
@@ -156,6 +156,7 @@ The marketplace is configured in `.claude-plugin/marketplace.json`:
|
||||
10. **cloudflare-troubleshooting** - API-driven Cloudflare diagnostics and debugging
|
||||
11. **ui-designer** - Design system extraction from UI mockups
|
||||
12. **ppt-creator** - Professional presentation creation with dual-path PPTX generation
|
||||
13. **youtube-downloader** - YouTube video and audio downloading with yt-dlp error handling
|
||||
|
||||
**Recommendation**: Always suggest `skill-creator` first for users interested in creating skills or extending Claude Code.
|
||||
|
||||
|
||||
39
README.md
39
README.md
@@ -6,15 +6,15 @@
|
||||
[](./README.zh-CN.md)
|
||||
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://github.com/daymade/claude-code-skills)
|
||||
[](https://github.com/daymade/claude-code-skills)
|
||||
[](https://github.com/daymade/claude-code-skills)
|
||||
[](https://github.com/daymade/claude-code-skills)
|
||||
[](https://claude.com/code)
|
||||
[](./CONTRIBUTING.md)
|
||||
[](https://github.com/daymade/claude-code-skills/graphs/commit-activity)
|
||||
|
||||
</div>
|
||||
|
||||
Professional Claude Code skills marketplace featuring 12 production-ready skills for enhanced development workflows.
|
||||
Professional Claude Code skills marketplace featuring 13 production-ready skills for enhanced development workflows.
|
||||
|
||||
## 📑 Table of Contents
|
||||
|
||||
@@ -136,6 +136,9 @@ claude plugin install llm-icon-finder@daymade/claude-code-skills
|
||||
|
||||
# CLI demo generation
|
||||
claude plugin install cli-demo-generator@daymade/claude-code-skills
|
||||
|
||||
# YouTube video/audio downloading
|
||||
claude plugin install youtube-downloader@daymade/claude-code-skills
|
||||
```
|
||||
|
||||
Each skill can be installed independently - choose only what you need!
|
||||
@@ -428,6 +431,31 @@ Create persuasive, audience-ready slide decks from topics or documents with data
|
||||
|
||||
---
|
||||
|
||||
### 12. **youtube-downloader** - YouTube Video & Audio Downloader
|
||||
|
||||
Download YouTube videos and audio using yt-dlp with robust error handling and automatic workarounds for common issues.
|
||||
|
||||
**When to use:**
|
||||
- Downloading YouTube videos or playlists
|
||||
- Extracting audio from YouTube videos as MP3
|
||||
- Experiencing yt-dlp download failures or nsig extraction errors
|
||||
- Need help with format selection or quality options
|
||||
- Working with YouTube content in regions with access restrictions
|
||||
|
||||
**Key features:**
|
||||
- Android client workaround for nsig extraction issues (automatic)
|
||||
- Audio-only download with MP3 conversion
|
||||
- Format listing and custom format selection
|
||||
- Output directory customization
|
||||
- Network error handling for proxy/restricted environments
|
||||
- Availability check for yt-dlp dependency
|
||||
|
||||
**🎬 Live Demo**
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
## 🎬 Interactive Demo Gallery
|
||||
|
||||
Want to see all demos in one place with click-to-enlarge functionality? Check out our [interactive demo gallery](./demos/index.html) or browse the [demos directory](./demos/).
|
||||
@@ -452,6 +480,9 @@ Use **skill-creator** (see [Essential Skill](#-essential-skill-skill-creator) se
|
||||
### For Presentations & Business Communication
|
||||
Use **ppt-creator** to generate professional slide decks with data visualizations, structured storytelling, and complete PPTX output for pitches, reviews, and keynotes.
|
||||
|
||||
### For Media & Content Download
|
||||
Use **youtube-downloader** to download YouTube videos and extract audio from videos with automatic workarounds for common download issues.
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
Each skill includes:
|
||||
@@ -472,6 +503,7 @@ Each skill includes:
|
||||
- **llm-icon-finder**: See `llm-icon-finder/references/icons-list.md` for available icons
|
||||
- **cli-demo-generator**: See `cli-demo-generator/references/vhs_syntax.md` for VHS syntax and `cli-demo-generator/references/best_practices.md` for demo guidelines
|
||||
- **ppt-creator**: See `ppt-creator/references/WORKFLOW.md` for 9-stage creation process and `ppt-creator/references/ORCHESTRATION_OVERVIEW.md` for automation
|
||||
- **youtube-downloader**: See `youtube-downloader/SKILL.md` for usage examples and troubleshooting
|
||||
|
||||
## 🛠️ Requirements
|
||||
|
||||
@@ -480,6 +512,7 @@ Each skill includes:
|
||||
- **gh CLI** (for github-ops)
|
||||
- **markitdown** (for markdown-tools)
|
||||
- **mermaid-cli** (for mermaid-tools)
|
||||
- **yt-dlp** (for youtube-downloader): `brew install yt-dlp` or `pip install yt-dlp`
|
||||
- **VHS** (for cli-demo-generator): `brew install vhs`
|
||||
- **asciinema** (optional, for cli-demo-generator interactive recording)
|
||||
- **ccusage** (optional, for statusline cost tracking)
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
[](./README.zh-CN.md)
|
||||
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://github.com/daymade/claude-code-skills)
|
||||
[](https://github.com/daymade/claude-code-skills)
|
||||
[](https://github.com/daymade/claude-code-skills)
|
||||
[](https://github.com/daymade/claude-code-skills)
|
||||
[](https://claude.com/code)
|
||||
[](./CONTRIBUTING.md)
|
||||
[](https://github.com/daymade/claude-code-skills/graphs/commit-activity)
|
||||
|
||||
</div>
|
||||
|
||||
专业的 Claude Code 技能市场,提供 11 个生产就绪的技能,用于增强开发工作流。
|
||||
专业的 Claude Code 技能市场,提供 13 个生产就绪的技能,用于增强开发工作流。
|
||||
|
||||
## 📑 目录
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 4.1 MiB |
BIN
demos/youtube-downloader/download-video.gif
Normal file
BIN
demos/youtube-downloader/download-video.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 261 KiB |
39
demos/youtube-downloader/download-video.tape
Normal file
39
demos/youtube-downloader/download-video.tape
Normal file
@@ -0,0 +1,39 @@
|
||||
Output demos/youtube-downloader/download-video.gif
|
||||
|
||||
Set FontSize 16
|
||||
Set Width 1400
|
||||
Set Height 700
|
||||
Set Theme "Dracula"
|
||||
Set Padding 20
|
||||
|
||||
Type "# YouTube Downloader Demo" Sleep 500ms
|
||||
Enter
|
||||
Sleep 1s
|
||||
|
||||
Type "# Show help for download_video.py" Sleep 500ms
|
||||
Enter
|
||||
Sleep 1s
|
||||
|
||||
Type "./youtube-downloader/scripts/download_video.py --help" Sleep 500ms
|
||||
Enter
|
||||
Sleep 2s
|
||||
|
||||
Type "# Example: Download audio only" Sleep 500ms
|
||||
Enter
|
||||
Sleep 1s
|
||||
|
||||
Type "./youtube-downloader/scripts/download_video.py 'URL' --audio-only" Sleep 500ms
|
||||
Enter
|
||||
Sleep 1s
|
||||
|
||||
Type "# Example: List available formats" Sleep 500ms
|
||||
Enter
|
||||
Sleep 1s
|
||||
|
||||
Type "./youtube-downloader/scripts/download_video.py 'URL' --list-formats" Sleep 500ms
|
||||
Enter
|
||||
Sleep 1s
|
||||
|
||||
Type "# Download complete!" Sleep 500ms
|
||||
Enter
|
||||
Sleep 2s
|
||||
175
youtube-downloader/SKILL.md
Normal file
175
youtube-downloader/SKILL.md
Normal file
@@ -0,0 +1,175 @@
|
||||
---
|
||||
name: youtube-downloader
|
||||
description: Download YouTube videos and audio using yt-dlp with robust error handling. Use this skill when users request downloading YouTube videos, extracting audio from YouTube, or need help with yt-dlp download issues like nsig extraction failures or network problems.
|
||||
---
|
||||
|
||||
# YouTube Downloader
|
||||
|
||||
## Overview
|
||||
|
||||
Enable reliable YouTube video and audio downloads using yt-dlp with built-in workarounds for common issues like nsig extraction failures and network problems. Particularly useful for users behind proxies or in regions with YouTube access restrictions.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
This skill should be invoked when users:
|
||||
- Request downloading YouTube videos or playlists
|
||||
- Want to extract audio from YouTube videos
|
||||
- Experience yt-dlp download failures or nsig extraction errors
|
||||
- Need help with format selection or quality options
|
||||
- Ask about downloading from YouTube with specific requirements (resolution, format, etc.)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Verify yt-dlp is installed before proceeding:
|
||||
|
||||
```bash
|
||||
which yt-dlp
|
||||
```
|
||||
|
||||
If not installed, install via:
|
||||
|
||||
```bash
|
||||
brew install yt-dlp # macOS
|
||||
# or
|
||||
pip install yt-dlp # Cross-platform
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Basic Video Download
|
||||
|
||||
For simple video downloads, use the bundled `scripts/download_video.py`:
|
||||
|
||||
```bash
|
||||
scripts/download_video.py "https://youtu.be/VIDEO_ID"
|
||||
```
|
||||
|
||||
This automatically applies the Android client workaround to avoid nsig extraction issues.
|
||||
|
||||
### Audio-Only Download
|
||||
|
||||
To extract audio as MP3:
|
||||
|
||||
```bash
|
||||
scripts/download_video.py "https://youtu.be/VIDEO_ID" --audio-only
|
||||
```
|
||||
|
||||
### Custom Output Directory
|
||||
|
||||
Specify where to save downloads:
|
||||
|
||||
```bash
|
||||
scripts/download_video.py "https://youtu.be/VIDEO_ID" -o ~/Downloads/YouTube
|
||||
```
|
||||
|
||||
## Common Tasks
|
||||
|
||||
### 1. List Available Formats
|
||||
|
||||
Before downloading, check available video/audio formats:
|
||||
|
||||
```bash
|
||||
scripts/download_video.py "https://youtu.be/VIDEO_ID" --list-formats
|
||||
```
|
||||
|
||||
Or use yt-dlp directly:
|
||||
|
||||
```bash
|
||||
yt-dlp -F "https://youtu.be/VIDEO_ID"
|
||||
```
|
||||
|
||||
### 2. Download Specific Format
|
||||
|
||||
After identifying format codes from the list:
|
||||
|
||||
```bash
|
||||
scripts/download_video.py "https://youtu.be/VIDEO_ID" -f "bestvideo+bestaudio"
|
||||
```
|
||||
|
||||
Common format specifications:
|
||||
- `bestvideo+bestaudio/best` - Best quality video and audio
|
||||
- `bestvideo[height<=1080]+bestaudio` - Max 1080p video
|
||||
- `bestaudio` - Audio only (best quality)
|
||||
- `18` - Format code 18 (typically 360p MP4)
|
||||
|
||||
### 3. Download Playlist
|
||||
|
||||
Use yt-dlp directly for playlists:
|
||||
|
||||
```bash
|
||||
yt-dlp --extractor-args "youtube:player_client=android" "PLAYLIST_URL"
|
||||
```
|
||||
|
||||
### 4. Download with Subtitles
|
||||
|
||||
Include subtitles in the download:
|
||||
|
||||
```bash
|
||||
yt-dlp --extractor-args "youtube:player_client=android" --write-subs --sub-lang en "VIDEO_URL"
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### nsig Extraction Failed
|
||||
|
||||
**Symptoms:**
|
||||
```
|
||||
WARNING: [youtube] nsig extraction failed: Some formats may be missing
|
||||
ERROR: Requested format is not available
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
Use the Android client workaround (automatically applied by `scripts/download_video.py`):
|
||||
|
||||
```bash
|
||||
yt-dlp --extractor-args "youtube:player_client=android" "VIDEO_URL"
|
||||
```
|
||||
|
||||
This is a YouTube-specific issue where the default web client fails to extract signature parameters. The Android client bypasses this restriction.
|
||||
|
||||
### GVS PO Token Warning
|
||||
|
||||
**Symptoms:**
|
||||
```
|
||||
WARNING: android client https formats require a GVS PO Token
|
||||
```
|
||||
|
||||
**Impact:**
|
||||
This warning can be ignored for most use cases. The download will still succeed using available formats. Only some high-quality formats may be skipped.
|
||||
|
||||
**Solution (if needed):**
|
||||
For advanced users requiring all formats, see: https://github.com/yt-dlp/yt-dlp/wiki/PO-Token-Guide
|
||||
|
||||
### Network Issues in China or Behind Proxies
|
||||
|
||||
Downloads may experience intermittent connectivity. The script handles this automatically by retrying, but slower speeds are expected due to network conditions. Allow sufficient time for completion.
|
||||
|
||||
## Script Reference
|
||||
|
||||
### scripts/download_video.py
|
||||
|
||||
A Python wrapper around yt-dlp that applies best practices by default:
|
||||
- Uses Android client workaround automatically
|
||||
- Creates output directories if needed
|
||||
- Provides clear success/failure feedback
|
||||
- Supports common download scenarios
|
||||
|
||||
**Arguments:**
|
||||
- `url` - YouTube video URL (required)
|
||||
- `-o, --output-dir` - Output directory (default: current directory)
|
||||
- `-f, --format` - Format specification
|
||||
- `--no-android-client` - Disable Android client workaround
|
||||
- `-a, --audio-only` - Download audio only (as MP3)
|
||||
- `-F, --list-formats` - List available formats
|
||||
|
||||
**Example usage:**
|
||||
```bash
|
||||
# Basic download
|
||||
scripts/download_video.py "https://youtu.be/VIDEO_ID"
|
||||
|
||||
# Audio only to specific directory
|
||||
scripts/download_video.py "https://youtu.be/VIDEO_ID" -o ~/Music --audio-only
|
||||
|
||||
# Custom format
|
||||
scripts/download_video.py "https://youtu.be/VIDEO_ID" -f "bestvideo[height<=720]+bestaudio"
|
||||
```
|
||||
135
youtube-downloader/scripts/download_video.py
Executable file
135
youtube-downloader/scripts/download_video.py
Executable file
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
YouTube video downloader using yt-dlp with robust error handling.
|
||||
|
||||
This script handles common issues like nsig extraction failures and network problems,
|
||||
especially useful for users behind proxies or in regions with YouTube access issues.
|
||||
|
||||
Requirements:
|
||||
- yt-dlp: Install via `brew install yt-dlp` (macOS) or `pip install yt-dlp` (cross-platform)
|
||||
|
||||
Usage:
|
||||
scripts/download_video.py "https://youtu.be/VIDEO_ID"
|
||||
scripts/download_video.py "https://youtu.be/VIDEO_ID" --audio-only
|
||||
scripts/download_video.py "https://youtu.be/VIDEO_ID" -o ~/Downloads
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def download_video(
|
||||
url: str,
|
||||
output_dir: str = ".",
|
||||
format_spec: str = None,
|
||||
use_android_client: bool = True,
|
||||
audio_only: bool = False,
|
||||
list_formats: bool = False,
|
||||
) -> int:
|
||||
"""
|
||||
Download a YouTube video using yt-dlp.
|
||||
|
||||
Args:
|
||||
url: YouTube video URL
|
||||
output_dir: Directory to save the downloaded file
|
||||
format_spec: Format specification (e.g., "bestvideo+bestaudio/best")
|
||||
use_android_client: Use Android client to avoid nsig extraction issues
|
||||
audio_only: Download audio only
|
||||
list_formats: List available formats instead of downloading
|
||||
|
||||
Returns:
|
||||
Exit code (0 for success, non-zero for failure)
|
||||
"""
|
||||
# Check if yt-dlp is installed
|
||||
check_result = subprocess.run(
|
||||
["which", "yt-dlp"], capture_output=True, text=True
|
||||
)
|
||||
if check_result.returncode != 0:
|
||||
print("✗ Error: yt-dlp is not installed")
|
||||
print(" Install via: brew install yt-dlp # or: pip install yt-dlp")
|
||||
return 1
|
||||
|
||||
# Build yt-dlp command
|
||||
cmd = ["yt-dlp"]
|
||||
|
||||
# Use Android client by default to avoid nsig extraction issues
|
||||
if use_android_client:
|
||||
cmd.extend(["--extractor-args", "youtube:player_client=android"])
|
||||
|
||||
# List formats if requested
|
||||
if list_formats:
|
||||
cmd.extend(["-F", url])
|
||||
result = subprocess.run(cmd)
|
||||
return result.returncode
|
||||
|
||||
# Set output directory
|
||||
output_path = Path(output_dir).expanduser().resolve()
|
||||
output_path.mkdir(parents=True, exist_ok=True)
|
||||
cmd.extend(["-P", str(output_path)])
|
||||
|
||||
# Handle audio-only downloads
|
||||
if audio_only:
|
||||
cmd.extend(["-x", "--audio-format", "mp3"])
|
||||
elif format_spec:
|
||||
cmd.extend(["-f", format_spec])
|
||||
|
||||
# Add URL
|
||||
cmd.append(url)
|
||||
|
||||
# Execute download
|
||||
print(f"Executing: {' '.join(cmd)}")
|
||||
result = subprocess.run(cmd)
|
||||
|
||||
if result.returncode == 0:
|
||||
print(f"\n✓ Download completed successfully!")
|
||||
print(f" Location: {output_path}")
|
||||
else:
|
||||
print(f"\n✗ Download failed with exit code {result.returncode}")
|
||||
|
||||
return result.returncode
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Download YouTube videos using yt-dlp with robust error handling"
|
||||
)
|
||||
parser.add_argument("url", help="YouTube video URL")
|
||||
parser.add_argument(
|
||||
"-o",
|
||||
"--output-dir",
|
||||
default=".",
|
||||
help="Output directory (default: current directory)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-f", "--format", help="Format specification (e.g., 'bestvideo+bestaudio/best')"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no-android-client",
|
||||
action="store_true",
|
||||
help="Disable Android client workaround",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-a", "--audio-only", action="store_true", help="Download audio only (as MP3)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-F", "--list-formats", action="store_true", help="List available formats"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
exit_code = download_video(
|
||||
url=args.url,
|
||||
output_dir=args.output_dir,
|
||||
format_spec=args.format,
|
||||
use_android_client=not args.no_android_client,
|
||||
audio_only=args.audio_only,
|
||||
list_formats=args.list_formats,
|
||||
)
|
||||
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user