4.8 KiB
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 |
|
|
true |
|
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};
- 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)
}
- 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);
}
}
}
- 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
};
- 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
- For Twitter extractor: Use
<success_criteria> Complete end-to-end functionality:
- --cookies FILE loads cookies → extractor uses them
- --cookies-from-browser extracts cookies → extractor uses them
- --simulate prints URLs without downloading
- --input-file reads URLs from file
- --destination saves to specified directory
- OAuth tokens from config → Pixiv extractor </success_criteria>