Skill: jpengcheng523-netizen/downloader (version 1.0.0)

--- name: downloader description: "Download a file from a URL and save it locally." --- # downloader Download a file from a given URL and save it to a specified local path. Supports any file type accessible via HTTP/HTTPS. ## When to Use ✅ **USE this skill when:** - When the user wants to download a file from a URL to the local machine. - When the user needs to save a remote resource (image, audio, video, document, etc.) locally. - When the user provides a download link and wants to store the file at a specific path. ## When NOT to Use ❌ **DON'T use this skill when:** - When the user only wants to view or read a URL content without saving to disk. ## Parameters | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | url | string | Yes | The URL of the file to download | | save_path | string | No | Local path to save the file (defaults to current directory with original filename) | ## Commands ### Basic Call ```bash python3 scripts/download.py --url 'https://example.com/file.png' ``` ### Save to a specific path ```bash python3 scripts/download.py --url 'https://example.com/file.png' --save_path './downloads/image.png' ``` ## Examples **"Help me download this image."** ```bash python3 scripts/download.py --url 'https://example.com/photo.jpg' ``` **"Download this PDF and save it to the reports folder."** ```bash python3 scripts/download.py --url 'https://example.com/report.pdf' --save_path './reports/report.pdf' ``` ## Response Script outputs JSON to stdout: - `code = 0` — success, `data` contains the local file path where the file was saved - `code != 0` — error, show `message` to the user and suggest retrying ```json { "code": 0, "message": "success", "data": "./downloads/file.png" } ``` ## Notes - Requires `requests` package: `pip install requests`

path: scripts/download.py
content: #!/usr/bin/env python3
"""Download a file from a URL and save it locally.

Dependencies:
    pip install requests
"""

import argparse
import json
import os
import sys
from urllib.parse import unquote, urlparse

import requests


def download_file(url: str, save_path: str) -> str:
    """Download a file from url and save to save_path. Returns the absolute path."""
    os.makedirs(os.path.dirname(save_path) or ".", exist_ok=True)

    resp = requests.get(url, stream=True, timeout=120)
    resp.raise_for_status()

    with open(save_path, "wb") as f:
        for chunk in resp.iter_content(chunk_size=8192):
            f.write(chunk)

    return os.path.abspath(save_path)


def _filename_from_url(url: str) -> str:
    """Extract a filename from the URL path."""
    path = urlparse(url).path
    name = os.path.basename(unquote(path))
    return name if name else "downloaded_file"


def main():
    parser = argparse.ArgumentParser(description="Download a file from a URL and save it locally")
    parser.add_argument("--url", required=True, help="URL of the file to download")
    parser.add_argument("--save_path", default=None, help="Local path to save the file (optional)")
    args = parser.parse_args()

    if args.save_path:
        save_path = args.save_path
    else:
        save_path = os.path.join(".", _filename_from_url(args.url))

    try:
        abs_path = download_file(args.url, save_path)
    except Exception as e:
        print(json.dumps({"code": 1, "message": str(e), "data": ""}))
        sys.exit(1)

    print(json.dumps({"code": 0, "message": "success", "data": abs_path}))


if __name__ == "__main__":
    main()


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)