agentleFS
rocosenrocosen/flashdata-mcp/skills/youtube-download/SKILL.md

youtube-download

Skill0 starsChanged 10 days agoMITView on GitHub

Download YouTube video, audio or a clip to your cloud storage with FlashData. Use for YouTube-to-S3 delivery, MP4 or MP3 exports and media ingestion through asynchronous jobs.

  • Reads credentials
  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use Python 3.10+ and a FlashData API key supplied as FLASHDATA_API_KEY through your environment or secret manager.

    line 23
  2. Very specific:

    Use download_type: "audio", output_format: "mp3" and optionally audio_quality: "192".

    line 103

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

YouTube Video and Audio Download

Send a YouTube video, audio track or selected clip directly to your own cloud storage. Choose the media type, format and quality, then use the returned job ID to retrieve the completed file location and size.

Documentation · Get an API key

Example requests

  • “Save the first 30 seconds of this video to my S3 bucket.”
  • “Download this video’s audio as MP3 to my storage.”
  • “Deliver a 720p MP4 and its metadata to my media pipeline.”

Quick start with Python: a clip to your storage

Use Python 3.10+ and a FlashData API key supplied as FLASHDATA_API_KEY through your environment or secret manager. Install the Python dependencies in your virtual environment:

python3 -m pip install 'mcp==1.30.0' 'httpx==0.28.1'

Save the following code as example.py and run python3 example.py. It connects to hosted FlashData MCP and sends one request. Data calls use paid FlashData Credits; installing the dependencies is free. Run only within the user's authorized task and budget.

Set FLASHDATA_STORAGE_FILE to a private JSON file containing your destination configuration; storage setup shows its fields. This example delivers the first 10 seconds as MP4. Replace the video and clip bounds for the user’s request. The file is read locally and its credentials are sent to FlashData for the upload, but are not printed.

import asyncio
import json
import os
from datetime import timedelta
from pathlib import Path

import httpx
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client

arguments = {
    "video_id": "jNQXAC9IVRw",
    "mode": "async",
    "download_type": "audio_video",
    "video_quality": "<=720",
    "output_format": "mp4",
    "start_at": "00:00:00",
    "end_at": "00:00:10",
    "storage": json.loads(Path(os.environ['FLASHDATA_STORAGE_FILE']).read_text(encoding='utf-8')),
}


async def main():
    async with httpx.AsyncClient(
        headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
        timeout=120, follow_redirects=False, trust_env=False,
    ) as http:
        async with streamable_http_client(
            "https://data.flashdata.dev/mcp", http_client=http,
        ) as (read, write, _):
            async with ClientSession(read, write) as session:
                await session.initialize()
                result = await session.call_tool(
                    "youtube_download", arguments=arguments,
                    read_timeout_seconds=timedelta(seconds=120),
                )
                if result.isError:
                    raise RuntimeError("FlashData reported a tool error.")
                data = result.structuredContent
                if data is None:
                    data = json.loads(next(item.text for item in result.content if item.type == "text"))
                if not isinstance(data, dict) or not data.get("id"):
                    raise RuntimeError("Missing job ID; check Jobs before resubmitting.")
                data = {key: data[key] for key in ("id", "status", "source", "created_at") if key in data}
                print(json.dumps(data, ensure_ascii=False, indent=2))


try:
    asyncio.run(main())
except Exception:
    raise SystemExit("Request failed. Check Jobs before retrying a paid submission; no automatic retry was made.") from None

With FlashData MCP, call youtube_download using the same fields and a storage object from the user's protected configuration.

Choose the media

ParameterUse
video_idRequired 11-character YouTube video ID.
download_typeaudio_video (default), video or audio.
video_quality<=720 by default; also best, worst, or <=, ==, >= with 144, 360, 480, 720, 1080, 1440, 2160 or 4320.
output_formatVideo: mp4 (default), webm, mkv. Audio: m4a (default), mp3, opus.
start_at, end_atClip times as HH:MM:SS; end must follow start. Omit for the full video.
storageRequired destination configuration; see storage setup.
modeasync; downloads return a job ID.

Audio as MP3

Use download_type: "audio", output_format: "mp3" and optionally audio_quality: "192". Audio quality accepts best (default), 320, 256, 192 or 128. Omit video_quality and fps for audio-only requests.

Higher resolution or a metadata sidecar

Set video_quality: "<=1080" for a maximum of 1080p. Add upload_metadata: true to upload a metadata JSON sidecar alongside the media. Availability depends on the video's formats.

Advanced selection supports fps constraints such as <=30, audio_language: "default" or "original", and yt_dlp_format. A custom yt_dlp_format overrides video_quality, fps and audio_language. Use audio_quality only with audio downloads and omit audio_language for video-only downloads.

Read the job and get the file

The submission response contains id. Set FLASHDATA_JOB_ID to that returned ID. Save the following as read_job.py and run python3 read_job.py to read the existing job once:

import asyncio
import json
import os
from datetime import timedelta

import httpx
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client

arguments = {
    "job_id": os.environ['FLASHDATA_JOB_ID'],
}


async def main():
    async with httpx.AsyncClient(
        headers={"X-API-Key": os.environ["FLASHDATA_API_KEY"]},
        timeout=120, follow_redirects=False, trust_env=False,
    ) as http:
        async with streamable_http_client(
            "https://data.flashdata.dev/mcp", http_client=http,
        ) as (read, write, _):
            async with ClientSession(read, write) as session:
                await session.initialize()
                result = await session.call_tool(
                    "get_job", arguments=arguments,
                    read_timeout_seconds=timedelta(seconds=120),
                )
                if result.isError:
                    raise RuntimeError("FlashData reported a tool error.")
                data = result.structuredContent
                if data is None:
                    data = json.loads(next(item.text for item in result.content if item.type == "text"))
                print(json.dumps(data, ensure_ascii=False, indent=2))


try:
    asyncio.run(main())
except Exception:
    raise SystemExit("Request failed. Check Jobs before retrying a paid submission; no automatic retry was made.") from None

While job.status is pending or processing, read the same job again as needed. When it is completed, inspect output.results[0] for file_url, file_size, downloaded_bytes, md5 and output_format. A private storage URL requires access through your storage provider.

Downloads reserve Credits before work and settle by actual uploaded bytes. get_pricing with {"source":"youtube_download"} returns the per-TB rate; it cannot give an exact file cost from duration alone. Job reads are free. Use this for media the user is authorized to download.

Connection and errors

For hosted MCP, connect https://data.flashdata.dev/mcp using Streamable HTTP and an X-API-Key header in your client's protected settings. Keep keys out of chat and committed files.

Storage credentials are transmitted to FlashData to perform the upload; MCP clients may retain tool arguments in their history. Use narrowly scoped credentials, and do not print credentials or signed access tokens in the returned file summary.

If a submission times out, do not resubmit automatically; it may already have been charged. Use get_job if an ID was returned. Without an ID, report the outcome as unknown and check Jobs in the FlashData console; get_job cannot look up a job without its ID. A failed or pending job is not a completed upload. For a chunked MCP response, use get_result with the returned result_id and next_offset as offset, then join the text chunks before parsing. The Python example prints the MCP response; if it contains chunks, retrieve them using the same MCP connection before closing it.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.