Files
gallery-dl/.planning/phases/06-auth-cli/06-03-PLAN.md

4.8 KiB

phase, plan, type, wave, depends_on, files_modified, autonomous, user_setup, must_haves
phase plan type wave depends_on files_modified autonomous user_setup must_haves
06-auth-cli 03 execute 2
01
02
src/main.rs
src/lib.rs
true
truths artifacts
Cookies from --cookies and --cookies-from-browser are passed to extractors (already exists)
Extractors with cookie support (Twitter) use the provided cookies
--input-file reads URLs from file and processes them
-v verbose flag already implemented in CLI (see cli.rs)
path provides min_lines
src/main.rs Wired CLI args to extractor initialization 30
path provides contains
src/lib.rs Auth module re-exported pub mod auth
Wire CLI args and cookie support in main.rs.

Purpose: Connect the CLI arguments (--cookies, --cookies-from-browser, --input-file) to the extraction pipeline. Ensure extractors receive cookies properly.

Output: CLI with cookie support and input-file wired

<execution_context> @/home/eliott/.config/opencode/get-shit-done/workflows/execute-plan.md @/home/eliott/.config/opencode/get-shit-done/templates/summary.md </execution_context>

@src/main.rs @src/cli.rs @src/auth/mod.rs @src/config.rs @src/extractor/extractors/twitter.rs @src/extractor/extractors/pixiv.rs Task 1: Export auth module in lib.rs src/lib.rs Update src/lib.rs to include the auth module:
pub mod auth;
pub mod cli;
// ... other modules

Add re-export:

pub use auth::{load_cookies_from_file, extract_browser_cookies};
cargo check passes Auth module is accessible from the library Task 2: Add input-file URL reading to main.rs src/main.rs Update main.rs to handle --input-file:
  1. Add a function to load URLs from input file:
fn load_urls_from_file(path: &PathBuf) -> Result<Vec<String>, std::io::Error> {
    let content = std::fs::read_to_string(path)?;
    let urls: Vec<String> = content
        .lines()
        .map(|s| s.trim().to_string())
        .filter(|s| !s.is_empty() && !s.starts_with('#'))
        .collect();
    Ok(urls)
}
  1. After parsing args, load URLs from input_file:
// Combine CLI URLs with input file URLs
let mut all_urls = args.urls.clone();
for input_path in &args.input_file {
    match load_urls_from_file(input_path) {
        Ok(urls) => all_urls.extend(urls),
        Err(e) => {
            eprintln!("Error reading input file {:?}: {}", input_path, e);
        }
    }
}
cargo check passes, test with sample file --input-file loads URLs from file and combines with CLI arguments Task 3: Wire cookies to extractors in main.rs src/main.rs Update main.rs to load and pass cookies to extractors:
  1. Add cookie loading logic after config loading:
// Load cookies from CLI arguments
let cookies = if let Some(cookies_file) = &args.cookies {
    match gallery_dl::load_cookies_from_file(cookies_file) {
        Ok(c) => {
            log::info!("Loaded {} cookies from {:?}", c.len(), cookies_file);
            Some(c)
        }
        Err(e) => {
            eprintln!("Error loading cookies: {}", e);
            None
        }
    }
} else if let Some(ref browser) = args.cookies_from_browser {
    match gallery_dl::extract_browser_cookies(browser, None) {
        Ok(c) => {
            log::info!("Extracted {} cookies from browser '{}'", c.len(), browser);
            Some(c)
        }
        Err(e) => {
            eprintln!("Error extracting browser cookies: {}", e);
            None
        }
    }
} else {
    None
};
  1. When creating extractor, pass cookies if the extractor supports them:
    • For Twitter extractor: Use TwitterExtractor::new().with_cookies(cookies.clone())
    • For other extractors: Check if they have cookie support method cargo check passes Cookies from --cookies are passed to extractors during initialization
- cargo check passes - --help shows all new options - Test: --cookies works with cookie file - Test: --input-file reads URLs - Test: --simulate doesn't download - Test: --destination specifies output dir

<success_criteria> Complete end-to-end functionality:

  1. --cookies FILE loads cookies → extractor uses them
  2. --cookies-from-browser extracts cookies → extractor uses them
  3. --simulate prints URLs without downloading
  4. --input-file reads URLs from file
  5. --destination saves to specified directory
  6. OAuth tokens from config → Pixiv extractor </success_criteria>
After completion, create `.planning/phases/06-auth-cli/06-03-SUMMARY.md`