[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6C1SNKPAN3VDGKTF8FJBBW0":3,"skill-same:01M6C1SNKPAN3VDGKTF8FJBBW0":99},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":51,"linkOnly":52,"markdownContent":53,"markdownBody":54,"frontMatter":55,"refName":63,"commitSha":64,"skillDirectory":65,"forksCount":66,"repositoryHtmlUrl":67,"repositoryHomepageUrl":68,"ownerHtmlUrl":69,"ownerBlogUrl":70,"ownerDescription":71,"updatedAt":72,"install":73,"resources":86},"01M6C1SNKPAN3VDGKTF8FJBBW0","acquire","媒体资源下载","Download media from discovered sources with format selection and progress tracking","从已发现的来源下载媒体，支持格式选择和进度跟踪。","jmagly\u002Faiwg","jmagly","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1159087?v=4","01M6C10AK8N2WCSQN11FYGTJWN","Joseph Magly","01M6C10AQ8A2RMED1Y1BSVY7NF",229,"MIT",null,"https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Facquire\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BR5V816HPKFXP1YV56C07K","多媒体工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BRP9HTCQJVTBV9WC1A6N5B","多媒体素材检索与处理","SCENARIO","使用场景",[5,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50],"grep","standard","sonnet","URL","sources","progress","selection","tracking","write","read","yaml","parallel","coding","download","format","plan","Bash","Audio","Media","Video","2026-11-10 10:12:30",false,"---\nnamespace: aiwg\nname: acquire\nplatforms: [all]\ndescription: Download media from discovered sources with format selection and progress tracking\ncommandHint:\n  argumentHint: --plan \u003Csources.yaml> | --url \u003CURL> [--format audio|video|best] [--output \u003Cdir>] [--parallel N]\n  allowedTools: Bash, Read, Write, Glob, Grep\n  model: sonnet\n  category: media-curator\n  modelRole: coding\n  modelTier: standard\n---\n\n# \u002Facquire\n\nDownload media from discovered sources with intelligent format selection, parallel execution, and comprehensive progress tracking.\n\n## Purpose\n\nThe `\u002Facquire` command orchestrates media downloads from various sources (YouTube, Internet Archive, Bandcamp, direct links) using the Acquisition Manager agent. It handles:\n\n- Single URL or batch downloads from source plans\n- Automatic format selection based on content type\n- Parallel download execution with resource limits\n- Real-time progress tracking and status reporting\n- Error recovery with retry strategies\n- Quality verification and metadata recording\n- Network mount awareness for optimal performance\n\n## Parameters\n\n### Required (one of)\n\n**`--plan \u003Csources.yaml>`**\n- Source plan file generated by `\u002Ffind-sources` command\n- YAML format containing URLs, metadata, and acquisition strategy\n- Example: `.curator\u002Fsources\u002Fplan-001.yaml`\n\n**`--url \u003CURL>`**\n- Single URL for one-off downloads\n- Supports: YouTube, Internet Archive, Bandcamp, SoundCloud, Vimeo, direct links\n- Example: `https:\u002F\u002Fyoutube.com\u002Fwatch?v=abc123`\n\n### Optional\n\n**`--format \u003Caudio|video|best>`**\n- Format preference for downloads\n- `audio`: Extract audio only (Opus 128K default)\n- `video`: Best video up to 1080p with audio\n- `best`: Let agent decide based on content type (default)\n- Example: `--format audio`\n\n**`--output \u003Cdirectory>`**\n- Base output directory for downloads\n- Default: `.\u002Fdownloads\u002F\u003Ctimestamp>`\n- Structure: `\u003Coutput>\u002F\u003Cartist>\u002F\u003Cera>\u002Faudio\u002F` and `\u002Fvideo\u002F`\n- Example: `--output \u002Fmnt\u002Farchive\u002Fmusic`\n\n**`--parallel \u003CN>`**\n- Maximum concurrent downloads\n- Range: 1-5 (default: 3)\n- Lower for slow networks, higher for fast connections\n- Example: `--parallel 5`\n\n**`--local-work \u003Cdirectory>`**\n- Local working directory (required for network mount outputs)\n- Downloads happen here first, then copied to output\n- Default: `\u002Ftmp\u002Fcurator-work-$$`\n- Example: `--local-work \u002Ffast-local-disk\u002Ftmp`\n\n**`--verify-after`**\n- Enable post-download verification\n- Checks file integrity, size, media validity\n- Adds ~5% overhead but prevents corruption\n- Example: `--verify-after`\n\n**`--extract-audio`**\n- Automatically extract audio from downloaded videos\n- Creates parallel audio files in audio\u002F directory\n- Uses Opus 128K by default\n- Example: `--extract-audio`\n\n**`--resume \u003Csession-id>`**\n- Resume interrupted download session\n- Loads state from `.curator\u002Fsessions\u002F\u003Csession-id>\u002Fstate.json`\n- Skips completed downloads, retries failed\n- Example: `--resume 20260214-143022`\n\n## Usage Examples\n\n### Single URL Download\n\n```bash\n# Download single YouTube video (audio only)\n\u002Facquire --url \"https:\u002F\u002Fyoutube.com\u002Fwatch?v=abc123\" --format audio\n\n# Download single video with metadata\n\u002Facquire --url \"https:\u002F\u002Fyoutube.com\u002Fwatch?v=abc123\" \\\n  --format video \\\n  --output \u002Fmnt\u002Farchive\u002Fconcerts \\\n  --verify-after\n```\n\n### Batch Download from Plan\n\n```bash\n# Download entire source plan (generated by \u002Ffind-sources)\n\u002Facquire --plan .curator\u002Fsources\u002Fplan-001.yaml\n\n# Download to network mount (uses local working dir)\n\u002Facquire --plan .curator\u002Fsources\u002Fplan-001.yaml \\\n  --output \u002Fmnt\u002Fnetwork-storage\u002Farchive \\\n  --local-work \u002Ffast-ssd\u002Fcurator-work \\\n  --parallel 3\n```\n\n### Audio Extraction Workflow\n\n```bash\n# Download videos and auto-extract audio\n\u002Facquire --plan .curator\u002Fsources\u002Fplan-001.yaml \\\n  --format video \\\n  --extract-audio \\\n  --verify-after\n\n# Result structure:\n# downloads\u002Fartist\u002Fera\u002Fvideo\u002Fconcert.mkv\n# downloads\u002Fartist\u002Fera\u002Faudio\u002Fconcert.opus\n```\n\n### Resume Interrupted Session\n\n```bash\n# Resume after network failure\n\u002Facquire --resume 20260214-143022\n\n# Resume with different output (move completed files)\n\u002Facquire --resume 20260214-143022 \\\n  --output \u002Fnew\u002Flocation\n```\n\n## Workflow\n\n### 1. Initialization\n\n```bash\n# Validate parameters\n- Check --plan exists OR --url provided\n- Verify output directory is writable\n- Check required tools (yt-dlp, wget, curl, ffmpeg)\n- Test network mount performance if applicable\n- Create session directory structure\n\n# Session setup\nSESSION_ID=$(date +%Y%m%d-%H%M%S)\nSESSION_DIR=\".curator\u002Fsessions\u002F$SESSION_ID\"\nmkdir -p \"$SESSION_DIR\"\u002F{logs,metadata}\n\n# Initialize state file\ncat > \"$SESSION_DIR\u002Fstate.json\" \u003C\u003CEOF\n{\n  \"session_id\": \"$SESSION_ID\",\n  \"started_at\": \"$(date -Iseconds)\",\n  \"status\": \"initializing\",\n  \"parameters\": {\n    \"plan\": \"$PLAN_FILE\",\n    \"format\": \"$FORMAT\",\n    \"output\": \"$OUTPUT_DIR\",\n    \"parallel\": $PARALLEL\n  },\n  \"downloads\": []\n}\nEOF\n```\n\n### 2. Source Validation\n\n```bash\n# If --plan provided, parse YAML\nif [[ -n \"$PLAN_FILE\" ]]; then\n  # Extract URLs and metadata\n  SOURCES=$(yq eval '.sources[] | .url' \"$PLAN_FILE\")\n  TOTAL_SOURCES=$(echo \"$SOURCES\" | wc -l)\n\n  # Validate each URL is accessible\n  while IFS= read -r url; do\n    if yt-dlp --dump-json \"$url\" >\u002Fdev\u002Fnull 2>&1; then\n      echo \"VALID: $url\"\n    else\n      echo \"WARNING: Cannot access $url\"\n    fi\n  done \u003C\u003C\u003C \"$SOURCES\"\nfi\n\n# If --url provided, validate single URL\nif [[ -n \"$SINGLE_URL\" ]]; then\n  if ! yt-dlp --dump-json \"$SINGLE_URL\" >\u002Fdev\u002Fnull 2>&1; then\n    echo \"ERROR: Cannot access URL: $SINGLE_URL\"\n    exit 1\n  fi\nfi\n```\n\n### 3. Directory Structure Creation\n\n```bash\ncreate_acquisition_structure() {\n  local output_base=\"$1\"\n  local artist=\"$2\"\n  local era=\"$3\"\n\n  # Sanitize directory names\n  local safe_artist=$(echo \"$artist\" | sed 's\u002F[^a-zA-Z0-9_-]\u002F_\u002Fg')\n  local safe_era=$(echo \"$era\" | sed 's\u002F[^a-zA-Z0-9_-]\u002F_\u002Fg')\n\n  # Create directory tree\n  local audio_dir=\"$output_base\u002F$safe_artist\u002F$safe_era\u002Faudio\"\n  local video_dir=\"$output_base\u002F$safe_artist\u002F$safe_era\u002Fvideo\"\n\n  mkdir -p \"$audio_dir\u002F.curator\"\n  mkdir -p \"$video_dir\u002F.curator\"\n  mkdir -p \"$output_base\u002F$safe_artist\u002F.curator\"\n\n  # Write artist metadata\n  cat > \"$output_base\u002F$safe_artist\u002F.curator\u002Fartist-info.json\" \u003C\u003CEOF\n{\n  \"name\": \"$artist\",\n  \"era\": \"$era\",\n  \"created_at\": \"$(date -Iseconds)\",\n  \"session_id\": \"$SESSION_ID\"\n}\nEOF\n\n  echo \"$audio_dir:$video_dir\"\n}\n```\n\n### 4. Launch Downloads\n\n```bash\n# Download orchestration with concurrency control\nACTIVE_DOWNLOADS=()\nMAX_CONCURRENT=${PARALLEL:-3}\n\nlaunch_download() {\n  local url=\"$1\"\n  local output_dir=\"$2\"\n  local format=\"$3\"\n  local download_id=\"dl-$SESSION_ID-$(date +%s)\"\n\n  # Wait for slot availability\n  while [[ ${#ACTIVE_DOWNLOADS[@]} -ge $MAX_CONCURRENT ]]; do\n    check_completed_downloads\n    sleep 2\n  done\n\n  # Determine target directory (audio vs video)\n  local target_dir\n  if [[ \"$format\" == \"audio\" || \"$format\" == \"bestaudio\" ]]; then\n    target_dir=\"$output_dir\u002Faudio\"\n  else\n    target_dir=\"$output_dir\u002Fvideo\"\n  fi\n\n  # Launch download in background\n  (\n    download_with_retry \"$url\" \"$target_dir\" \"$format\" \"$download_id\"\n    echo \"COMPLETED:$download_id:$?\" >> \"$SESSION_DIR\u002Fcompletion.log\"\n  ) &\n\n  local pid=$!\n  ACTIVE_DOWNLOADS+=(\"$download_id:$pid\")\n\n  # Update state file\n  update_state_file \"add\" \"$download_id\" \"$url\" \"in_progress\"\n}\n\ndownload_with_retry() {\n  local url=\"$1\"\n  local target_dir=\"$2\"\n  local format=\"$3\"\n  local download_id=\"$4\"\n\n  local attempt=0\n  local max_attempts=3\n\n  while [[ $attempt -lt $max_attempts ]]; do\n    attempt=$((attempt + 1))\n\n    echo \"[$download_id] Attempt $attempt\u002F$max_attempts\"\n\n    if yt-dlp -f \"$format\" \\\n        --output \"$target_dir\u002F%(title)s.%(ext)s\" \\\n        --write-info-json \\\n        --write-thumbnail \\\n        --no-playlist \\\n        \"$url\" \\\n        2>&1 | tee \"$SESSION_DIR\u002Flogs\u002F$download_id.log\"; then\n\n      update_state_file \"complete\" \"$download_id\" \"\" \"completed\"\n      return 0\n    fi\n\n    # Check error type\n    local error_type=$(classify_error \"$SESSION_DIR\u002Flogs\u002F$download_id.log\")\n\n    if [[ \"$error_type\" == \"disk_full\" || \"$error_type\" == \"permission_denied\" ]]; then\n      echo \"FATAL: $error_type - aborting all downloads\"\n      pkill -P $$  # Kill all child processes\n      exit 2\n    fi\n\n    if [[ $attempt -lt $max_attempts ]]; then\n      local wait_time=$((5 * attempt))\n      echo \"Waiting ${wait_time}s before retry...\"\n      sleep \"$wait_time\"\n    fi\n  done\n\n  update_state_file \"fail\" \"$download_id\" \"\" \"failed\"\n  return 1\n}\n\ncheck_completed_downloads() {\n  local new_active=()\n\n  for entry in \"${ACTIVE_DOWNLOADS[@]}\"; do\n    local pid=\"${entry#*:}\"\n    if kill -0 \"$pid\" 2>\u002Fdev\u002Fnull; then\n      new_active+=(\"$entry\")\n    fi\n  done\n\n  ACTIVE_DOWNLOADS=(\"${new_active[@]}\")\n}\n```\n\n### 5. Track Progress\n\n```bash\n# Real-time progress monitoring\nmonitor_progress() {\n  local session_dir=\"$1\"\n\n  while true; do\n    # Load current state\n    local state_file=\"$session_dir\u002Fstate.json\"\n\n    local total=$(jq '.downloads | length' \"$state_file\")\n    local completed=$(jq '[.downloads[] | select(.status == \"completed\")] | length' \"$state_file\")\n    local in_progress=$(jq '[.downloads[] | select(.status == \"in_progress\")] | length' \"$state_file\")\n    local failed=$(jq '[.downloads[] | select(.status == \"failed\")] | length' \"$state_file\")\n\n    # Clear screen and display status\n    clear\n    cat \u003C\u003CEOF\nACQUISITION PROGRESS\n====================\nSession: $SESSION_ID\nStarted: $(jq -r '.started_at' \"$state_file\")\n\nStatus: $completed\u002F$total completed ($failed failed, $in_progress in progress)\n\nActive Downloads:\nEOF\n\n    # Show active download details\n    jq -r '.downloads[] | select(.status == \"in_progress\") | \"  [\\(.progress_percent)%] \\(.filename) @ \\(.speed_mbps)MB\u002Fs (ETA: \\(.eta_seconds)s)\"' \"$state_file\"\n\n    # Exit if all done\n    if [[ $((completed + failed)) -eq $total ]]; then\n      echo \"\"\n      echo \"All downloads completed.\"\n      break\n    fi\n\n    sleep 5\n  done\n}\n\n# Run in background\nmonitor_progress \"$SESSION_DIR\" &\nMONITOR_PID=$!\n```\n\n### 6. Extract Audio (if requested)\n\n```bash\nif [[ \"$EXTRACT_AUDIO\" == \"true\" ]]; then\n  echo \"Extracting audio from video files...\"\n\n  find \"$OUTPUT_DIR\" -type d -name \"video\" | while read -r video_dir; do\n    local audio_dir=\"${video_dir%\u002Fvideo}\u002Faudio\"\n\n    find \"$video_dir\" -type f \\( -name \"*.mkv\" -o -name \"*.mp4\" -o -name \"*.webm\" \\) | while read -r video_file; do\n      local basename=$(basename \"$video_file\" | sed 's\u002F\\.[^.]*$\u002F\u002F')\n      local audio_file=\"$audio_dir\u002F${basename}.opus\"\n\n      echo \"  $video_file -> $audio_file\"\n\n      ffmpeg -i \"$video_file\" \\\n        -vn \\\n        -acodec libopus \\\n        -b:a 128K \\\n        \"$audio_file\" \\\n        2>&1 | tee -a \"$SESSION_DIR\u002Flogs\u002Faudio-extraction.log\"\n\n      if [[ ${PIPESTATUS[0]} -eq 0 ]]; then\n        echo \"SUCCESS: $audio_file\"\n      else\n        echo \"FAILED: $video_file\"\n      fi\n    done\n  done\nfi\n```\n\n### 7. Verify Downloads (if requested)\n\n```bash\nif [[ \"$VERIFY_AFTER\" == \"true\" ]]; then\n  echo \"Verifying downloaded files...\"\n\n  local verification_results=\"$SESSION_DIR\u002Fverification.json\"\n  echo '{\"verified\": [], \"failed\": []}' > \"$verification_results\"\n\n  find \"$OUTPUT_DIR\" -type f \\( -name \"*.opus\" -o -name \"*.mkv\" -o -name \"*.mp4\" -o -name \"*.flac\" \\) | while read -r file; do\n    echo \"Verifying: $file\"\n\n    # Check file size\n    local size=$(stat -c%s \"$file\" 2>\u002Fdev\u002Fnull || stat -f%z \"$file\")\n    if [[ $size -eq 0 ]]; then\n      echo \"FAILED: Zero-byte file\"\n      jq \".failed += [\\\"$file\\\"]\" \"$verification_results\" > \"$verification_results.tmp\"\n      mv \"$verification_results.tmp\" \"$verification_results\"\n      continue\n    fi\n\n    # Check media integrity with ffmpeg\n    if ffmpeg -v error -i \"$file\" -f null - 2>&1 | grep -q \"error\"; then\n      echo \"FAILED: Corrupted media file\"\n      jq \".failed += [\\\"$file\\\"]\" \"$verification_results\" > \"$verification_results.tmp\"\n      mv \"$verification_results.tmp\" \"$verification_results\"\n      continue\n    fi\n\n    echo \"VERIFIED: $file ($size bytes)\"\n    jq \".verified += [\\\"$file\\\"]\" \"$verification_results\" > \"$verification_results.tmp\"\n    mv \"$verification_results.tmp\" \"$verification_results\"\n  done\n\n  local verified_count=$(jq '.verified | length' \"$verification_results\")\n  local failed_count=$(jq '.failed | length' \"$verification_results\")\n\n  echo \"\"\n  echo \"Verification complete: $verified_count verified, $failed_count failed\"\nfi\n```\n\n### 8. Copy to Network Mount (if applicable)\n\n```bash\nif [[ -n \"$LOCAL_WORK\" && \"$OUTPUT_DIR\" != \"$LOCAL_WORK\"* ]]; then\n  echo \"Copying from local work directory to network mount...\"\n\n  # Batch copy with progress\n  rsync -av --progress \\\n    --exclude='.DS_Store' \\\n    --exclude='Thumbs.db' \\\n    \"$LOCAL_WORK\u002F\" \"$OUTPUT_DIR\u002F\"\n\n  # Verify checksums\n  echo \"Verifying network copy...\"\n  (cd \"$LOCAL_WORK\" && find . -type f -exec sha256sum {} \\; | sort) > \u002Ftmp\u002Flocal-checksums\n  (cd \"$OUTPUT_DIR\" && find . -type f -exec sha256sum {} \\; | sort) > \u002Ftmp\u002Fremote-checksums\n\n  if diff \u002Ftmp\u002Flocal-checksums \u002Ftmp\u002Fremote-checksums; then\n    echo \"Verification SUCCESS - removing local working copy\"\n    rm -rf \"$LOCAL_WORK\"\n  else\n    echo \"WARNING: Checksum mismatch - keeping local copy at $LOCAL_WORK\"\n  fi\nfi\n```\n\n## Progress Display Format\n\nReal-time console output during acquisition:\n\n```\nACQUISITION PROGRESS\n====================\nSession: 20260214-143022\nStarted: 2026-02-14T14:30:22Z\n\nStatus: 5\u002F12 completed (1 failed, 3 in progress)\n\nActive Downloads:\n  [67%] concert-1.mkv @ 12.5MB\u002Fs (ETA: 245s)\n  [23%] album.flac @ 8.2MB\u002Fs (ETA: 680s)\n  [91%] podcast-ep5.opus @ 2.1MB\u002Fs (ETA: 45s)\n\nRecent Completions:\n  [✓] documentary.mp4 (1.2GB, 8m 34s)\n  [✓] live-set.opus (85MB, 1m 12s)\n\nRecent Failures:\n  [✗] unavailable-video.mkv (Video unavailable - marked for alternate source)\n\nTotal Downloaded: 4.8GB \u002F ~12.5GB estimated\nAverage Speed: 8.9MB\u002Fs\nEstimated Completion: 14:58 (28 minutes remaining)\n```\n\n## Error Handling\n\n### Common Errors and Responses\n\n| Error | Detection | Response | User Action Required |\n|-------|-----------|----------|---------------------|\n| **URL inaccessible** | Pre-download validation fails | Skip URL, mark for manual review | Check URL, update source plan |\n| **Network timeout** | Download stalls for 60s | Retry with exponential backoff (3x) | Check network connection |\n| **Rate limited** | HTTP 429 response | Wait 60s, retry (2x) | Reduce parallel count |\n| **Disk full** | Write fails with ENOSPC | STOP all downloads, escalate | Free disk space |\n| **Format unavailable** | yt-dlp format error | Try fallback formats | Accept lower quality or skip |\n| **Corrupted download** | ffmpeg verification fails | Delete and retry (2x) | Report to source |\n| **Permission denied** | Write fails with EACCES | STOP, escalate | Fix permissions |\n| **Mount failure** | Network mount timeout | Fall back to local-only mode | Check mount health |\n\n### Error Log Structure\n\n```bash\n# Per-download error log: .curator\u002Fsessions\u002F\u003Csession-id>\u002Flogs\u002F\u003Cdownload-id>.log\n[2026-02-14 14:35:22] Starting download: https:\u002F\u002Fyoutube.com\u002Fwatch?v=abc123\n[2026-02-14 14:35:23] Format selected: bestvideo[height\u003C=1080]+bestaudio\n[2026-02-14 14:37:45] ERROR: HTTP Error 429: Too Many Requests\n[2026-02-14 14:37:45] Classified as: rate_limited\n[2026-02-14 14:37:45] Applying retry strategy: wait 60s (attempt 1\u002F2)\n[2026-02-14 14:38:45] Retrying download...\n[2026-02-14 14:42:10] Download completed: concert-1.mkv (1.2GB)\n```\n\n### Session Failure Recovery\n\n```bash\n# Detect stale sessions and offer recovery\ndetect_incomplete_sessions() {\n  find .curator\u002Fsessions -name \"state.json\" -mtime -7 | while read -r state_file; do\n    local status=$(jq -r '.status' \"$state_file\")\n    local session_id=$(jq -r '.session_id' \"$state_file\")\n\n    if [[ \"$status\" == \"in_progress\" ]]; then\n      local completed=$(jq '[.downloads[] | select(.status == \"completed\")] | length' \"$state_file\")\n      local total=$(jq '.downloads | length' \"$state_file\")\n\n      echo \"Incomplete session detected: $session_id ($completed\u002F$total completed)\"\n      echo \"Resume with: \u002Facquire --resume $session_id\"\n    fi\n  done\n}\n```\n\n## Report Generation\n\n### Final Session Report\n\n```bash\ngenerate_acquisition_report() {\n  local session_dir=\"$1\"\n  local state_file=\"$session_dir\u002Fstate.json\"\n  local report_file=\"$session_dir\u002Freport.md\"\n\n  cat > \"$report_file\" \u003C\u003CEOF\n# Acquisition Session Report\n\n**Session ID**: $(jq -r '.session_id' \"$state_file\")\n**Started**: $(jq -r '.started_at' \"$state_file\")\n**Completed**: $(date -Iseconds)\n**Duration**: $(calculate_duration \"$(jq -r '.started_at' \"$state_file\")\" \"$(date -Iseconds)\")\n\n## Summary\n\n- **Total Downloads**: $(jq '.downloads | length' \"$state_file\")\n- **Completed**: $(jq '[.downloads[] | select(.status == \"completed\")] | length' \"$state_file\")\n- **Failed**: $(jq '[.downloads[] | select(.status == \"failed\")] | length' \"$state_file\")\n- **Total Size**: $(jq '[.downloads[] | select(.status == \"completed\") | .filesize_bytes] | add | . \u002F 1073741824' \"$state_file\") GB\n\n## Successful Downloads\n\n$(jq -r '.downloads[] | select(.status == \"completed\") | \"- \\(.filename) (\\(.filesize_bytes | tonumber \u002F 1048576 | floor)MB)\"' \"$state_file\")\n\n## Failed Downloads\n\n$(jq -r '.downloads[] | select(.status == \"failed\") | \"- \\(.url)\\n  Error: \\(.error)\"' \"$state_file\")\n\n## Parameters\n\n- **Source Plan**: $(jq -r '.parameters.plan \u002F\u002F \"N\u002FA\"' \"$state_file\")\n- **Format Preference**: $(jq -r '.parameters.format' \"$state_file\")\n- **Output Directory**: $(jq -r '.parameters.output' \"$state_file\")\n- **Parallel Downloads**: $(jq -r '.parameters.parallel' \"$state_file\")\n\n## File Locations\n\n- **Session Directory**: $session_dir\n- **Download Logs**: $session_dir\u002Flogs\u002F\n- **Metadata**: $session_dir\u002Fmetadata\u002F\n- **Verification Results**: $session_dir\u002Fverification.json\n\nEOF\n\n  echo \"Report generated: $report_file\"\n  cat \"$report_file\"\n}\n```\n\n### Metadata Export\n\n```bash\n# Export metadata for external tools\nexport_metadata() {\n  local session_dir=\"$1\"\n  local export_file=\"$session_dir\u002Fmetadata-export.json\"\n\n  jq '{\n    session_id: .session_id,\n    started_at: .started_at,\n    downloads: [\n      .downloads[] | select(.status == \"completed\") | {\n        url: .url,\n        filename: .filename,\n        format: .format,\n        filesize_bytes: .filesize_bytes,\n        duration_seconds: .duration_seconds,\n        checksum_sha256: .checksum_sha256\n      }\n    ]\n  }' \"$session_dir\u002Fstate.json\" > \"$export_file\"\n\n  echo \"Metadata exported: $export_file\"\n}\n```\n\n### Acquisition Manifest (research handoff)\n\nFor the media-curator to research-complete handoff, `\u002Facquire` writes a\nper-media **acquisition manifest** beside each downloaded file (in addition to\nthe session-level `state.json` and `metadata-export.json`). This manifest is the\nproducer side of the contract that `induct-media` consumes — it is the file you\npass as the first positional argument to `\u002Finduct-media`.\n\nRecommended filename: `\u003Cmedia-basename>.acquisition.json`\n\nSchema and required fields:\n\n- `schema`: `aiwg.media.acquisition.v1`\n- `title` — human-readable title of the acquired media\n- `source_url` — canonical source URL (strip trackers; normalize `watch?v=` form)\n- `platform` — `YouTube`, `Internet Archive`, `Bandcamp`, `direct`, etc.\n- `format` — `audio` or `video`\n- `media_path` — local path to the acquired file\n- `sha256` — SHA-256 of the exact local media bytes (`sha256:\u003Chex>` convention,\n  matching the integrity-verification skill)\n- `duration` — `HH:MM:SS`\n- `license` — explicit posture: `platform ToS only`, `CC-BY-4.0`,\n  `public domain`, etc. Never assert a redistributable license you cannot verify.\n\nOptional fields (recorded when known — they let `induct-media` backlink\nprofiles and skip re-derivation):\n\n- `speakers` — array of `{ \"name\": \"Family, Given\" }`\n- `channel_or_venue` — `{ \"name\": \"...\" }` (e.g. a YouTube channel, podcast\n  feed, or conference such as NeurIPS)\n- `acquisition_id`, `acquired_at`, `session_id` — provenance back to this run\n\nEmit one manifest per completed download:\n\n```bash\nwrite_acquisition_manifest() {\n  local media_path=\"$1\" source_url=\"$2\" platform=\"$3\" format=\"$4\"\n  local title=\"$5\" duration=\"$6\" license=\"$7\"\n  local sha\n  sha=\"sha256:$(sha256sum \"$media_path\" | awk '{print $1}')\"\n  local manifest=\"${media_path%.*}.acquisition.json\"\n\n  jq -n \\\n    --arg title \"$title\" --arg url \"$source_url\" --arg platform \"$platform\" \\\n    --arg format \"$format\" --arg path \"$media_path\" --arg sha \"$sha\" \\\n    --arg duration \"$duration\" --arg license \"$license\" \\\n    --arg sid \"$SESSION_ID\" --arg at \"$(date -Iseconds)\" \\\n    '{\n      schema: \"aiwg.media.acquisition.v1\",\n      acquisition_id: $sid, acquired_at: $at, session_id: $sid,\n      title: $title, source_url: $url, platform: $platform, format: $format,\n      media_path: $path, sha256: $sha, duration: $duration, license: $license\n    }' > \"$manifest\"\n\n  echo \"Acquisition manifest: $manifest\"\n}\n```\n\nSee `examples\u002Fsample.acquisition.json` for a minimal manifest, and\n@$AIWG_ROOT\u002Fdocs\u002Fintegrations\u002Fmedia-curator-to-research-handoff.md for the full\nacquire → transcribe-media → induct-media flow.\n\n## Integration with Other Commands\n\n### Typical Workflow\n\n```bash\n# 1. Discover sources\n\u002Ffind-sources --artist \"Pink Floyd\" --era \"1970s\" --sources youtube,archive\n\n# 2. Acquire media from discovered sources\n\u002Facquire --plan .curator\u002Fsources\u002Fplan-001.yaml \\\n  --format video \\\n  --extract-audio \\\n  --verify-after \\\n  --output \u002Fmnt\u002Farchive\u002Fpink-floyd\n\n# 3. Extract metadata (runs automatically or manually)\n\u002Fextract-metadata --source \u002Fmnt\u002Farchive\u002Fpink-floyd\u002FThe_Wall\u002Faudio\n\n# 4. Organize final collection\n\u002Forganize --source \u002Fmnt\u002Farchive\u002Fpink-floyd\n```\n\n## Performance Considerations\n\n### Network Mount Optimization\n\n- **Download to local first**: Always use `--local-work` when output is network mount\n- **Batch copy**: Single rsync after all downloads complete\n- **Verify checksums**: Before deleting local copy\n- **Concurrent limit**: Reduce `--parallel` for network mounts (recommend 2)\n\n### Disk Space Management\n\n- **Pre-flight check**: Estimate total size from source plan\n- **Monitor during**: Watch for disk space warnings\n- **Cleanup strategy**: Remove verified local copies after network copy\n\n### Network Bandwidth\n\n- **Parallel tuning**: More concurrent downloads for high bandwidth\n- **Rate limiting**: Add `--limit-rate` to yt-dlp for shared networks\n- **Peak hours**: Schedule large downloads for off-peak times\n\n## Security Considerations\n\n- **URL validation**: Never execute arbitrary commands from URLs\n- **Directory traversal**: Sanitize all path components\n- **Disk quota**: Respect user\u002Fsystem quotas\n- **Network access**: Only connect to explicitly allowed domains\n- **Credential handling**: Never log or expose API keys\u002Ftokens\n\n## References\n\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fhuman-authorization.md — Seek explicit authorization before irreversible actions (overwrites, deletions)\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fresearch-before-decision.md — Research sources before deciding on acquisition strategy\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Ffind-sources\u002FSKILL.md — Source discovery skill used before acquisition\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fyoutube-acquisition\u002FSKILL.md — yt-dlp patterns; **read the Prerequisites section before any YouTube acquisition** (EJS \u002F PO-token \u002F pip-vs-zipapp gotchas)\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fintegrity-verification\u002FSKILL.md — Verify downloaded files after acquisition\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fprovenance-tracking\u002FSKILL.md — Track origin and derivation of acquired media\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Ftranscribe-media\u002FSKILL.md — Transcribe acquired media before research induction\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fresearch-complete\u002Fskills\u002Finduct-media\u002FSKILL.md — Consumes the acquisition manifest (`aiwg.media.acquisition.v1`) for the research handoff\n","# \u002Facquire\n\nDownload media from discovered sources with intelligent format selection, parallel execution, and comprehensive progress tracking.\n\n## Purpose\n\nThe `\u002Facquire` command orchestrates media downloads from various sources (YouTube, Internet Archive, Bandcamp, direct links) using the Acquisition Manager agent. It handles:\n\n- Single URL or batch downloads from source plans\n- Automatic format selection based on content type\n- Parallel download execution with resource limits\n- Real-time progress tracking and status reporting\n- Error recovery with retry strategies\n- Quality verification and metadata recording\n- Network mount awareness for optimal performance\n\n## Parameters\n\n### Required (one of)\n\n**`--plan \u003Csources.yaml>`**\n- Source plan file generated by `\u002Ffind-sources` command\n- YAML format containing URLs, metadata, and acquisition strategy\n- Example: `.curator\u002Fsources\u002Fplan-001.yaml`\n\n**`--url \u003CURL>`**\n- Single URL for one-off downloads\n- Supports: YouTube, Internet Archive, Bandcamp, SoundCloud, Vimeo, direct links\n- Example: `https:\u002F\u002Fyoutube.com\u002Fwatch?v=abc123`\n\n### Optional\n\n**`--format \u003Caudio|video|best>`**\n- Format preference for downloads\n- `audio`: Extract audio only (Opus 128K default)\n- `video`: Best video up to 1080p with audio\n- `best`: Let agent decide based on content type (default)\n- Example: `--format audio`\n\n**`--output \u003Cdirectory>`**\n- Base output directory for downloads\n- Default: `.\u002Fdownloads\u002F\u003Ctimestamp>`\n- Structure: `\u003Coutput>\u002F\u003Cartist>\u002F\u003Cera>\u002Faudio\u002F` and `\u002Fvideo\u002F`\n- Example: `--output \u002Fmnt\u002Farchive\u002Fmusic`\n\n**`--parallel \u003CN>`**\n- Maximum concurrent downloads\n- Range: 1-5 (default: 3)\n- Lower for slow networks, higher for fast connections\n- Example: `--parallel 5`\n\n**`--local-work \u003Cdirectory>`**\n- Local working directory (required for network mount outputs)\n- Downloads happen here first, then copied to output\n- Default: `\u002Ftmp\u002Fcurator-work-$$`\n- Example: `--local-work \u002Ffast-local-disk\u002Ftmp`\n\n**`--verify-after`**\n- Enable post-download verification\n- Checks file integrity, size, media validity\n- Adds ~5% overhead but prevents corruption\n- Example: `--verify-after`\n\n**`--extract-audio`**\n- Automatically extract audio from downloaded videos\n- Creates parallel audio files in audio\u002F directory\n- Uses Opus 128K by default\n- Example: `--extract-audio`\n\n**`--resume \u003Csession-id>`**\n- Resume interrupted download session\n- Loads state from `.curator\u002Fsessions\u002F\u003Csession-id>\u002Fstate.json`\n- Skips completed downloads, retries failed\n- Example: `--resume 20260214-143022`\n\n## Usage Examples\n\n### Single URL Download\n\n```bash\n# Download single YouTube video (audio only)\n\u002Facquire --url \"https:\u002F\u002Fyoutube.com\u002Fwatch?v=abc123\" --format audio\n\n# Download single video with metadata\n\u002Facquire --url \"https:\u002F\u002Fyoutube.com\u002Fwatch?v=abc123\" \\\n  --format video \\\n  --output \u002Fmnt\u002Farchive\u002Fconcerts \\\n  --verify-after\n```\n\n### Batch Download from Plan\n\n```bash\n# Download entire source plan (generated by \u002Ffind-sources)\n\u002Facquire --plan .curator\u002Fsources\u002Fplan-001.yaml\n\n# Download to network mount (uses local working dir)\n\u002Facquire --plan .curator\u002Fsources\u002Fplan-001.yaml \\\n  --output \u002Fmnt\u002Fnetwork-storage\u002Farchive \\\n  --local-work \u002Ffast-ssd\u002Fcurator-work \\\n  --parallel 3\n```\n\n### Audio Extraction Workflow\n\n```bash\n# Download videos and auto-extract audio\n\u002Facquire --plan .curator\u002Fsources\u002Fplan-001.yaml \\\n  --format video \\\n  --extract-audio \\\n  --verify-after\n\n# Result structure:\n# downloads\u002Fartist\u002Fera\u002Fvideo\u002Fconcert.mkv\n# downloads\u002Fartist\u002Fera\u002Faudio\u002Fconcert.opus\n```\n\n### Resume Interrupted Session\n\n```bash\n# Resume after network failure\n\u002Facquire --resume 20260214-143022\n\n# Resume with different output (move completed files)\n\u002Facquire --resume 20260214-143022 \\\n  --output \u002Fnew\u002Flocation\n```\n\n## Workflow\n\n### 1. Initialization\n\n```bash\n# Validate parameters\n- Check --plan exists OR --url provided\n- Verify output directory is writable\n- Check required tools (yt-dlp, wget, curl, ffmpeg)\n- Test network mount performance if applicable\n- Create session directory structure\n\n# Session setup\nSESSION_ID=$(date +%Y%m%d-%H%M%S)\nSESSION_DIR=\".curator\u002Fsessions\u002F$SESSION_ID\"\nmkdir -p \"$SESSION_DIR\"\u002F{logs,metadata}\n\n# Initialize state file\ncat > \"$SESSION_DIR\u002Fstate.json\" \u003C\u003CEOF\n{\n  \"session_id\": \"$SESSION_ID\",\n  \"started_at\": \"$(date -Iseconds)\",\n  \"status\": \"initializing\",\n  \"parameters\": {\n    \"plan\": \"$PLAN_FILE\",\n    \"format\": \"$FORMAT\",\n    \"output\": \"$OUTPUT_DIR\",\n    \"parallel\": $PARALLEL\n  },\n  \"downloads\": []\n}\nEOF\n```\n\n### 2. Source Validation\n\n```bash\n# If --plan provided, parse YAML\nif [[ -n \"$PLAN_FILE\" ]]; then\n  # Extract URLs and metadata\n  SOURCES=$(yq eval '.sources[] | .url' \"$PLAN_FILE\")\n  TOTAL_SOURCES=$(echo \"$SOURCES\" | wc -l)\n\n  # Validate each URL is accessible\n  while IFS= read -r url; do\n    if yt-dlp --dump-json \"$url\" >\u002Fdev\u002Fnull 2>&1; then\n      echo \"VALID: $url\"\n    else\n      echo \"WARNING: Cannot access $url\"\n    fi\n  done \u003C\u003C\u003C \"$SOURCES\"\nfi\n\n# If --url provided, validate single URL\nif [[ -n \"$SINGLE_URL\" ]]; then\n  if ! yt-dlp --dump-json \"$SINGLE_URL\" >\u002Fdev\u002Fnull 2>&1; then\n    echo \"ERROR: Cannot access URL: $SINGLE_URL\"\n    exit 1\n  fi\nfi\n```\n\n### 3. Directory Structure Creation\n\n```bash\ncreate_acquisition_structure() {\n  local output_base=\"$1\"\n  local artist=\"$2\"\n  local era=\"$3\"\n\n  # Sanitize directory names\n  local safe_artist=$(echo \"$artist\" | sed 's\u002F[^a-zA-Z0-9_-]\u002F_\u002Fg')\n  local safe_era=$(echo \"$era\" | sed 's\u002F[^a-zA-Z0-9_-]\u002F_\u002Fg')\n\n  # Create directory tree\n  local audio_dir=\"$output_base\u002F$safe_artist\u002F$safe_era\u002Faudio\"\n  local video_dir=\"$output_base\u002F$safe_artist\u002F$safe_era\u002Fvideo\"\n\n  mkdir -p \"$audio_dir\u002F.curator\"\n  mkdir -p \"$video_dir\u002F.curator\"\n  mkdir -p \"$output_base\u002F$safe_artist\u002F.curator\"\n\n  # Write artist metadata\n  cat > \"$output_base\u002F$safe_artist\u002F.curator\u002Fartist-info.json\" \u003C\u003CEOF\n{\n  \"name\": \"$artist\",\n  \"era\": \"$era\",\n  \"created_at\": \"$(date -Iseconds)\",\n  \"session_id\": \"$SESSION_ID\"\n}\nEOF\n\n  echo \"$audio_dir:$video_dir\"\n}\n```\n\n### 4. Launch Downloads\n\n```bash\n# Download orchestration with concurrency control\nACTIVE_DOWNLOADS=()\nMAX_CONCURRENT=${PARALLEL:-3}\n\nlaunch_download() {\n  local url=\"$1\"\n  local output_dir=\"$2\"\n  local format=\"$3\"\n  local download_id=\"dl-$SESSION_ID-$(date +%s)\"\n\n  # Wait for slot availability\n  while [[ ${#ACTIVE_DOWNLOADS[@]} -ge $MAX_CONCURRENT ]]; do\n    check_completed_downloads\n    sleep 2\n  done\n\n  # Determine target directory (audio vs video)\n  local target_dir\n  if [[ \"$format\" == \"audio\" || \"$format\" == \"bestaudio\" ]]; then\n    target_dir=\"$output_dir\u002Faudio\"\n  else\n    target_dir=\"$output_dir\u002Fvideo\"\n  fi\n\n  # Launch download in background\n  (\n    download_with_retry \"$url\" \"$target_dir\" \"$format\" \"$download_id\"\n    echo \"COMPLETED:$download_id:$?\" >> \"$SESSION_DIR\u002Fcompletion.log\"\n  ) &\n\n  local pid=$!\n  ACTIVE_DOWNLOADS+=(\"$download_id:$pid\")\n\n  # Update state file\n  update_state_file \"add\" \"$download_id\" \"$url\" \"in_progress\"\n}\n\ndownload_with_retry() {\n  local url=\"$1\"\n  local target_dir=\"$2\"\n  local format=\"$3\"\n  local download_id=\"$4\"\n\n  local attempt=0\n  local max_attempts=3\n\n  while [[ $attempt -lt $max_attempts ]]; do\n    attempt=$((attempt + 1))\n\n    echo \"[$download_id] Attempt $attempt\u002F$max_attempts\"\n\n    if yt-dlp -f \"$format\" \\\n        --output \"$target_dir\u002F%(title)s.%(ext)s\" \\\n        --write-info-json \\\n        --write-thumbnail \\\n        --no-playlist \\\n        \"$url\" \\\n        2>&1 | tee \"$SESSION_DIR\u002Flogs\u002F$download_id.log\"; then\n\n      update_state_file \"complete\" \"$download_id\" \"\" \"completed\"\n      return 0\n    fi\n\n    # Check error type\n    local error_type=$(classify_error \"$SESSION_DIR\u002Flogs\u002F$download_id.log\")\n\n    if [[ \"$error_type\" == \"disk_full\" || \"$error_type\" == \"permission_denied\" ]]; then\n      echo \"FATAL: $error_type - aborting all downloads\"\n      pkill -P $$  # Kill all child processes\n      exit 2\n    fi\n\n    if [[ $attempt -lt $max_attempts ]]; then\n      local wait_time=$((5 * attempt))\n      echo \"Waiting ${wait_time}s before retry...\"\n      sleep \"$wait_time\"\n    fi\n  done\n\n  update_state_file \"fail\" \"$download_id\" \"\" \"failed\"\n  return 1\n}\n\ncheck_completed_downloads() {\n  local new_active=()\n\n  for entry in \"${ACTIVE_DOWNLOADS[@]}\"; do\n    local pid=\"${entry#*:}\"\n    if kill -0 \"$pid\" 2>\u002Fdev\u002Fnull; then\n      new_active+=(\"$entry\")\n    fi\n  done\n\n  ACTIVE_DOWNLOADS=(\"${new_active[@]}\")\n}\n```\n\n### 5. Track Progress\n\n```bash\n# Real-time progress monitoring\nmonitor_progress() {\n  local session_dir=\"$1\"\n\n  while true; do\n    # Load current state\n    local state_file=\"$session_dir\u002Fstate.json\"\n\n    local total=$(jq '.downloads | length' \"$state_file\")\n    local completed=$(jq '[.downloads[] | select(.status == \"completed\")] | length' \"$state_file\")\n    local in_progress=$(jq '[.downloads[] | select(.status == \"in_progress\")] | length' \"$state_file\")\n    local failed=$(jq '[.downloads[] | select(.status == \"failed\")] | length' \"$state_file\")\n\n    # Clear screen and display status\n    clear\n    cat \u003C\u003CEOF\nACQUISITION PROGRESS\n====================\nSession: $SESSION_ID\nStarted: $(jq -r '.started_at' \"$state_file\")\n\nStatus: $completed\u002F$total completed ($failed failed, $in_progress in progress)\n\nActive Downloads:\nEOF\n\n    # Show active download details\n    jq -r '.downloads[] | select(.status == \"in_progress\") | \"  [\\(.progress_percent)%] \\(.filename) @ \\(.speed_mbps)MB\u002Fs (ETA: \\(.eta_seconds)s)\"' \"$state_file\"\n\n    # Exit if all done\n    if [[ $((completed + failed)) -eq $total ]]; then\n      echo \"\"\n      echo \"All downloads completed.\"\n      break\n    fi\n\n    sleep 5\n  done\n}\n\n# Run in background\nmonitor_progress \"$SESSION_DIR\" &\nMONITOR_PID=$!\n```\n\n### 6. Extract Audio (if requested)\n\n```bash\nif [[ \"$EXTRACT_AUDIO\" == \"true\" ]]; then\n  echo \"Extracting audio from video files...\"\n\n  find \"$OUTPUT_DIR\" -type d -name \"video\" | while read -r video_dir; do\n    local audio_dir=\"${video_dir%\u002Fvideo}\u002Faudio\"\n\n    find \"$video_dir\" -type f \\( -name \"*.mkv\" -o -name \"*.mp4\" -o -name \"*.webm\" \\) | while read -r video_file; do\n      local basename=$(basename \"$video_file\" | sed 's\u002F\\.[^.]*$\u002F\u002F')\n      local audio_file=\"$audio_dir\u002F${basename}.opus\"\n\n      echo \"  $video_file -> $audio_file\"\n\n      ffmpeg -i \"$video_file\" \\\n        -vn \\\n        -acodec libopus \\\n        -b:a 128K \\\n        \"$audio_file\" \\\n        2>&1 | tee -a \"$SESSION_DIR\u002Flogs\u002Faudio-extraction.log\"\n\n      if [[ ${PIPESTATUS[0]} -eq 0 ]]; then\n        echo \"SUCCESS: $audio_file\"\n      else\n        echo \"FAILED: $video_file\"\n      fi\n    done\n  done\nfi\n```\n\n### 7. Verify Downloads (if requested)\n\n```bash\nif [[ \"$VERIFY_AFTER\" == \"true\" ]]; then\n  echo \"Verifying downloaded files...\"\n\n  local verification_results=\"$SESSION_DIR\u002Fverification.json\"\n  echo '{\"verified\": [], \"failed\": []}' > \"$verification_results\"\n\n  find \"$OUTPUT_DIR\" -type f \\( -name \"*.opus\" -o -name \"*.mkv\" -o -name \"*.mp4\" -o -name \"*.flac\" \\) | while read -r file; do\n    echo \"Verifying: $file\"\n\n    # Check file size\n    local size=$(stat -c%s \"$file\" 2>\u002Fdev\u002Fnull || stat -f%z \"$file\")\n    if [[ $size -eq 0 ]]; then\n      echo \"FAILED: Zero-byte file\"\n      jq \".failed += [\\\"$file\\\"]\" \"$verification_results\" > \"$verification_results.tmp\"\n      mv \"$verification_results.tmp\" \"$verification_results\"\n      continue\n    fi\n\n    # Check media integrity with ffmpeg\n    if ffmpeg -v error -i \"$file\" -f null - 2>&1 | grep -q \"error\"; then\n      echo \"FAILED: Corrupted media file\"\n      jq \".failed += [\\\"$file\\\"]\" \"$verification_results\" > \"$verification_results.tmp\"\n      mv \"$verification_results.tmp\" \"$verification_results\"\n      continue\n    fi\n\n    echo \"VERIFIED: $file ($size bytes)\"\n    jq \".verified += [\\\"$file\\\"]\" \"$verification_results\" > \"$verification_results.tmp\"\n    mv \"$verification_results.tmp\" \"$verification_results\"\n  done\n\n  local verified_count=$(jq '.verified | length' \"$verification_results\")\n  local failed_count=$(jq '.failed | length' \"$verification_results\")\n\n  echo \"\"\n  echo \"Verification complete: $verified_count verified, $failed_count failed\"\nfi\n```\n\n### 8. Copy to Network Mount (if applicable)\n\n```bash\nif [[ -n \"$LOCAL_WORK\" && \"$OUTPUT_DIR\" != \"$LOCAL_WORK\"* ]]; then\n  echo \"Copying from local work directory to network mount...\"\n\n  # Batch copy with progress\n  rsync -av --progress \\\n    --exclude='.DS_Store' \\\n    --exclude='Thumbs.db' \\\n    \"$LOCAL_WORK\u002F\" \"$OUTPUT_DIR\u002F\"\n\n  # Verify checksums\n  echo \"Verifying network copy...\"\n  (cd \"$LOCAL_WORK\" && find . -type f -exec sha256sum {} \\; | sort) > \u002Ftmp\u002Flocal-checksums\n  (cd \"$OUTPUT_DIR\" && find . -type f -exec sha256sum {} \\; | sort) > \u002Ftmp\u002Fremote-checksums\n\n  if diff \u002Ftmp\u002Flocal-checksums \u002Ftmp\u002Fremote-checksums; then\n    echo \"Verification SUCCESS - removing local working copy\"\n    rm -rf \"$LOCAL_WORK\"\n  else\n    echo \"WARNING: Checksum mismatch - keeping local copy at $LOCAL_WORK\"\n  fi\nfi\n```\n\n## Progress Display Format\n\nReal-time console output during acquisition:\n\n```\nACQUISITION PROGRESS\n====================\nSession: 20260214-143022\nStarted: 2026-02-14T14:30:22Z\n\nStatus: 5\u002F12 completed (1 failed, 3 in progress)\n\nActive Downloads:\n  [67%] concert-1.mkv @ 12.5MB\u002Fs (ETA: 245s)\n  [23%] album.flac @ 8.2MB\u002Fs (ETA: 680s)\n  [91%] podcast-ep5.opus @ 2.1MB\u002Fs (ETA: 45s)\n\nRecent Completions:\n  [✓] documentary.mp4 (1.2GB, 8m 34s)\n  [✓] live-set.opus (85MB, 1m 12s)\n\nRecent Failures:\n  [✗] unavailable-video.mkv (Video unavailable - marked for alternate source)\n\nTotal Downloaded: 4.8GB \u002F ~12.5GB estimated\nAverage Speed: 8.9MB\u002Fs\nEstimated Completion: 14:58 (28 minutes remaining)\n```\n\n## Error Handling\n\n### Common Errors and Responses\n\n| Error | Detection | Response | User Action Required |\n|-------|-----------|----------|---------------------|\n| **URL inaccessible** | Pre-download validation fails | Skip URL, mark for manual review | Check URL, update source plan |\n| **Network timeout** | Download stalls for 60s | Retry with exponential backoff (3x) | Check network connection |\n| **Rate limited** | HTTP 429 response | Wait 60s, retry (2x) | Reduce parallel count |\n| **Disk full** | Write fails with ENOSPC | STOP all downloads, escalate | Free disk space |\n| **Format unavailable** | yt-dlp format error | Try fallback formats | Accept lower quality or skip |\n| **Corrupted download** | ffmpeg verification fails | Delete and retry (2x) | Report to source |\n| **Permission denied** | Write fails with EACCES | STOP, escalate | Fix permissions |\n| **Mount failure** | Network mount timeout | Fall back to local-only mode | Check mount health |\n\n### Error Log Structure\n\n```bash\n# Per-download error log: .curator\u002Fsessions\u002F\u003Csession-id>\u002Flogs\u002F\u003Cdownload-id>.log\n[2026-02-14 14:35:22] Starting download: https:\u002F\u002Fyoutube.com\u002Fwatch?v=abc123\n[2026-02-14 14:35:23] Format selected: bestvideo[height\u003C=1080]+bestaudio\n[2026-02-14 14:37:45] ERROR: HTTP Error 429: Too Many Requests\n[2026-02-14 14:37:45] Classified as: rate_limited\n[2026-02-14 14:37:45] Applying retry strategy: wait 60s (attempt 1\u002F2)\n[2026-02-14 14:38:45] Retrying download...\n[2026-02-14 14:42:10] Download completed: concert-1.mkv (1.2GB)\n```\n\n### Session Failure Recovery\n\n```bash\n# Detect stale sessions and offer recovery\ndetect_incomplete_sessions() {\n  find .curator\u002Fsessions -name \"state.json\" -mtime -7 | while read -r state_file; do\n    local status=$(jq -r '.status' \"$state_file\")\n    local session_id=$(jq -r '.session_id' \"$state_file\")\n\n    if [[ \"$status\" == \"in_progress\" ]]; then\n      local completed=$(jq '[.downloads[] | select(.status == \"completed\")] | length' \"$state_file\")\n      local total=$(jq '.downloads | length' \"$state_file\")\n\n      echo \"Incomplete session detected: $session_id ($completed\u002F$total completed)\"\n      echo \"Resume with: \u002Facquire --resume $session_id\"\n    fi\n  done\n}\n```\n\n## Report Generation\n\n### Final Session Report\n\n```bash\ngenerate_acquisition_report() {\n  local session_dir=\"$1\"\n  local state_file=\"$session_dir\u002Fstate.json\"\n  local report_file=\"$session_dir\u002Freport.md\"\n\n  cat > \"$report_file\" \u003C\u003CEOF\n# Acquisition Session Report\n\n**Session ID**: $(jq -r '.session_id' \"$state_file\")\n**Started**: $(jq -r '.started_at' \"$state_file\")\n**Completed**: $(date -Iseconds)\n**Duration**: $(calculate_duration \"$(jq -r '.started_at' \"$state_file\")\" \"$(date -Iseconds)\")\n\n## Summary\n\n- **Total Downloads**: $(jq '.downloads | length' \"$state_file\")\n- **Completed**: $(jq '[.downloads[] | select(.status == \"completed\")] | length' \"$state_file\")\n- **Failed**: $(jq '[.downloads[] | select(.status == \"failed\")] | length' \"$state_file\")\n- **Total Size**: $(jq '[.downloads[] | select(.status == \"completed\") | .filesize_bytes] | add | . \u002F 1073741824' \"$state_file\") GB\n\n## Successful Downloads\n\n$(jq -r '.downloads[] | select(.status == \"completed\") | \"- \\(.filename) (\\(.filesize_bytes | tonumber \u002F 1048576 | floor)MB)\"' \"$state_file\")\n\n## Failed Downloads\n\n$(jq -r '.downloads[] | select(.status == \"failed\") | \"- \\(.url)\\n  Error: \\(.error)\"' \"$state_file\")\n\n## Parameters\n\n- **Source Plan**: $(jq -r '.parameters.plan \u002F\u002F \"N\u002FA\"' \"$state_file\")\n- **Format Preference**: $(jq -r '.parameters.format' \"$state_file\")\n- **Output Directory**: $(jq -r '.parameters.output' \"$state_file\")\n- **Parallel Downloads**: $(jq -r '.parameters.parallel' \"$state_file\")\n\n## File Locations\n\n- **Session Directory**: $session_dir\n- **Download Logs**: $session_dir\u002Flogs\u002F\n- **Metadata**: $session_dir\u002Fmetadata\u002F\n- **Verification Results**: $session_dir\u002Fverification.json\n\nEOF\n\n  echo \"Report generated: $report_file\"\n  cat \"$report_file\"\n}\n```\n\n### Metadata Export\n\n```bash\n# Export metadata for external tools\nexport_metadata() {\n  local session_dir=\"$1\"\n  local export_file=\"$session_dir\u002Fmetadata-export.json\"\n\n  jq '{\n    session_id: .session_id,\n    started_at: .started_at,\n    downloads: [\n      .downloads[] | select(.status == \"completed\") | {\n        url: .url,\n        filename: .filename,\n        format: .format,\n        filesize_bytes: .filesize_bytes,\n        duration_seconds: .duration_seconds,\n        checksum_sha256: .checksum_sha256\n      }\n    ]\n  }' \"$session_dir\u002Fstate.json\" > \"$export_file\"\n\n  echo \"Metadata exported: $export_file\"\n}\n```\n\n### Acquisition Manifest (research handoff)\n\nFor the media-curator to research-complete handoff, `\u002Facquire` writes a\nper-media **acquisition manifest** beside each downloaded file (in addition to\nthe session-level `state.json` and `metadata-export.json`). This manifest is the\nproducer side of the contract that `induct-media` consumes — it is the file you\npass as the first positional argument to `\u002Finduct-media`.\n\nRecommended filename: `\u003Cmedia-basename>.acquisition.json`\n\nSchema and required fields:\n\n- `schema`: `aiwg.media.acquisition.v1`\n- `title` — human-readable title of the acquired media\n- `source_url` — canonical source URL (strip trackers; normalize `watch?v=` form)\n- `platform` — `YouTube`, `Internet Archive`, `Bandcamp`, `direct`, etc.\n- `format` — `audio` or `video`\n- `media_path` — local path to the acquired file\n- `sha256` — SHA-256 of the exact local media bytes (`sha256:\u003Chex>` convention,\n  matching the integrity-verification skill)\n- `duration` — `HH:MM:SS`\n- `license` — explicit posture: `platform ToS only`, `CC-BY-4.0`,\n  `public domain`, etc. Never assert a redistributable license you cannot verify.\n\nOptional fields (recorded when known — they let `induct-media` backlink\nprofiles and skip re-derivation):\n\n- `speakers` — array of `{ \"name\": \"Family, Given\" }`\n- `channel_or_venue` — `{ \"name\": \"...\" }` (e.g. a YouTube channel, podcast\n  feed, or conference such as NeurIPS)\n- `acquisition_id`, `acquired_at`, `session_id` — provenance back to this run\n\nEmit one manifest per completed download:\n\n```bash\nwrite_acquisition_manifest() {\n  local media_path=\"$1\" source_url=\"$2\" platform=\"$3\" format=\"$4\"\n  local title=\"$5\" duration=\"$6\" license=\"$7\"\n  local sha\n  sha=\"sha256:$(sha256sum \"$media_path\" | awk '{print $1}')\"\n  local manifest=\"${media_path%.*}.acquisition.json\"\n\n  jq -n \\\n    --arg title \"$title\" --arg url \"$source_url\" --arg platform \"$platform\" \\\n    --arg format \"$format\" --arg path \"$media_path\" --arg sha \"$sha\" \\\n    --arg duration \"$duration\" --arg license \"$license\" \\\n    --arg sid \"$SESSION_ID\" --arg at \"$(date -Iseconds)\" \\\n    '{\n      schema: \"aiwg.media.acquisition.v1\",\n      acquisition_id: $sid, acquired_at: $at, session_id: $sid,\n      title: $title, source_url: $url, platform: $platform, format: $format,\n      media_path: $path, sha256: $sha, duration: $duration, license: $license\n    }' > \"$manifest\"\n\n  echo \"Acquisition manifest: $manifest\"\n}\n```\n\nSee `examples\u002Fsample.acquisition.json` for a minimal manifest, and\n@$AIWG_ROOT\u002Fdocs\u002Fintegrations\u002Fmedia-curator-to-research-handoff.md for the full\nacquire → transcribe-media → induct-media flow.\n\n## Integration with Other Commands\n\n### Typical Workflow\n\n```bash\n# 1. Discover sources\n\u002Ffind-sources --artist \"Pink Floyd\" --era \"1970s\" --sources youtube,archive\n\n# 2. Acquire media from discovered sources\n\u002Facquire --plan .curator\u002Fsources\u002Fplan-001.yaml \\\n  --format video \\\n  --extract-audio \\\n  --verify-after \\\n  --output \u002Fmnt\u002Farchive\u002Fpink-floyd\n\n# 3. Extract metadata (runs automatically or manually)\n\u002Fextract-metadata --source \u002Fmnt\u002Farchive\u002Fpink-floyd\u002FThe_Wall\u002Faudio\n\n# 4. Organize final collection\n\u002Forganize --source \u002Fmnt\u002Farchive\u002Fpink-floyd\n```\n\n## Performance Considerations\n\n### Network Mount Optimization\n\n- **Download to local first**: Always use `--local-work` when output is network mount\n- **Batch copy**: Single rsync after all downloads complete\n- **Verify checksums**: Before deleting local copy\n- **Concurrent limit**: Reduce `--parallel` for network mounts (recommend 2)\n\n### Disk Space Management\n\n- **Pre-flight check**: Estimate total size from source plan\n- **Monitor during**: Watch for disk space warnings\n- **Cleanup strategy**: Remove verified local copies after network copy\n\n### Network Bandwidth\n\n- **Parallel tuning**: More concurrent downloads for high bandwidth\n- **Rate limiting**: Add `--limit-rate` to yt-dlp for shared networks\n- **Peak hours**: Schedule large downloads for off-peak times\n\n## Security Considerations\n\n- **URL validation**: Never execute arbitrary commands from URLs\n- **Directory traversal**: Sanitize all path components\n- **Disk quota**: Respect user\u002Fsystem quotas\n- **Network access**: Only connect to explicitly allowed domains\n- **Credential handling**: Never log or expose API keys\u002Ftokens\n\n## References\n\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fhuman-authorization.md — Seek explicit authorization before irreversible actions (overwrites, deletions)\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fresearch-before-decision.md — Research sources before deciding on acquisition strategy\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Ffind-sources\u002FSKILL.md — Source discovery skill used before acquisition\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fyoutube-acquisition\u002FSKILL.md — yt-dlp patterns; **read the Prerequisites section before any YouTube acquisition** (EJS \u002F PO-token \u002F pip-vs-zipapp gotchas)\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fintegrity-verification\u002FSKILL.md — Verify downloaded files after acquisition\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Fprovenance-tracking\u002FSKILL.md — Track origin and derivation of acquired media\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Ftranscribe-media\u002FSKILL.md — Transcribe acquired media before research induction\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fresearch-complete\u002Fskills\u002Finduct-media\u002FSKILL.md — Consumes the acquisition manifest (`aiwg.media.acquisition.v1`) for the research handoff\n",{"name":5,"namespace":56,"platforms":57,"commandHint":59,"description":7},"aiwg",[58],"all",{"model":33,"category":60,"modelRole":43,"modelTier":32,"allowedTools":61,"argumentHint":62},"media-curator","Bash, Read, Write, Glob, Grep","--plan \u003Csources.yaml> | --url \u003CURL> [--format audio|video|best] [--output \u003Cdir>] [--parallel N]","main","6754967c344ccb087a8de06972f55a41067b291b","agentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Facquire",36,"https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg","https:\u002F\u002Faiwg.io","https:\u002F\u002Fgithub.com\u002Fjmagly","https:\u002F\u002Fintegrolabs.io","ml\u002Fai, industrial automation, safety\u002Fsecurity, ssi\r\n\r\nmagly.net\r\nintegrolabs.io\r\naiwg.io\r\nfortemi.com\r\npagenary.com\r\nbytecask.com","2026-11-14 10:46:34",{"source":9,"skillName":5,"commands":74,"prompt":84,"zipAvailable":85},[75,78,81],{"tool":76,"command":77},"npx","npx skills add jmagly\u002Faiwg --skill acquire",{"tool":79,"command":80},"bunx","bunx skills add jmagly\u002Faiwg --skill acquire",{"tool":82,"command":83},"pnpm","pnpm dlx skills add jmagly\u002Faiwg --skill acquire","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Facquire\u002FSKILL.md",true,[87,93],{"path":88,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":91,"sourceHtmlUrl":92},"examples\u002Fsample.acquisition.json","REFERENCE","参考文档",661,"https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fmedia-curator\u002Fskills\u002Facquire\u002Fexamples\u002Fsample.acquisition.json",{"path":94,"resourceType":95,"resourceTypeDesc":96,"sizeBytes":97,"sourceHtmlUrl":98},"tools.sdn","OTHER","其他",877,"https:\u002F\u002Fgithub.com\u002Formastes\u002Fsimple\u002Fblob\u002Fmain\u002Fexamples\u002F05_stdlib\u002Fspipe\u002Fdoc\u002F00_llm_process\u002Fskill_command\u002Fskills\u002Fpipe\u002Fimpl\u002Ftools.sdn",[100,108,113,137,156,161],{"skillNo":101,"name":102,"nameZh":17,"description":103,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":107},"01M78KW7PZJ9YQZQMW84SN2YD4","plugin-search","Search marketplaces for plugins using configured local manifests and directory caches; rank matching plugins by observed installs, review tier and cache dates without installing or fetching anything","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Futils\u002Fskills\u002Fplugin-search\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":109,"name":102,"nameZh":17,"description":103,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":107},"01M78KSEZS9ZNNFESY9ANW22S0","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Fskills\u002Fplugin-search\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":17,"description":116,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":51},"01M70QA0BSYJ49EES9V4RE8QH1","host-hardening","Read-only system hardening baseline and plan-first host hardening recommendations for SSH, Docker bind addresses, firewall persistence, datastores, exporters and audit retention.","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fsecurity-engineering\u002Fskills\u002Fhost-hardening\u002FSKILL.md",[],[120,121,122,123,124,40,125,126,127,128,46,129,130,47,131,132,133,134,135,136],"hardening","host","host hardening","verification","secrets","request","remediation","recommendations","audit","port","bind","access","only","retention","re","never","firewall",{"skillNo":138,"name":139,"nameZh":17,"description":140,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":51},"01M70PNT2Z4HMZPRBTAF6073NN","exposure-analysis","Read-only firewall analysis and effective host exposure reconstruction for Docker published ports, UFW bypass, stale rules, CDN scope, IPv6 asymmetry and external probe allowlists.","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fforensics\u002Fskills\u002Fexposure-analysis\u002FSKILL.md",[],[144,145,146,147,148,39,40,149,129,135,47,150,121,151,132,152,153,136,154,155],"analysis","exposure analysis","collection","reconstruction","operator","credentials","unknown","internet","local","scope","ports","ufw",{"skillNo":157,"name":115,"nameZh":17,"description":116,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":158,"categories":159,"keywords":160,"publishedAt":51},"01M70P8QATMPKA78E4FT5D2TNA","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsecurity-engineering\u002Fskills\u002Fhost-hardening\u002FSKILL.md",[],[120,121,122,134,135,136,130,133,127,124,40,125,126,128,46,129,123,47,131,132],{"skillNo":162,"name":139,"nameZh":17,"description":140,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":163,"categories":164,"keywords":165,"publishedAt":51},"01M70NMPVJ5H0JH131P60FW4R8","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fforensics-complete\u002Fskills\u002Fexposure-analysis\u002FSKILL.md",[],[144,145,155,154,148,153,152,132,147,39,40,149,129,146,47,150,121,136,135,151]]