mirror of
https://github.com/thegeneralist01/archivr
synced 2026-07-22 03:05:32 +02:00
feat(core): add via_freedium to CaptureConfig; route WebPage captures through Freedium mirror
When via_freedium is true and the locator is not already a Freedium URL, perform_capture passes https://freedium-mirror.cfd/<original-url> to singlefile::save() so paywalled articles are fetched via the mirror. The original locator is kept for requested_locator and canonical_locator in the DB entry. An empty cookie map is used for the mirror fetch to prevent original-domain credentials from being sent to freedium-mirror.cfd.
This commit is contained in:
parent
289037235c
commit
a926d7cf2d
1 changed files with 14 additions and 1 deletions
|
|
@ -87,6 +87,9 @@ pub struct CaptureConfig {
|
||||||
pub reader_mode: bool,
|
pub reader_mode: bool,
|
||||||
/// Override for modal-closer browser-script behavior during WebPage captures.
|
/// Override for modal-closer browser-script behavior during WebPage captures.
|
||||||
pub modal_closer_enabled: Option<bool>,
|
pub modal_closer_enabled: Option<bool>,
|
||||||
|
/// Route WebPage captures through the Freedium mirror to bypass paywalls.
|
||||||
|
/// The original locator is still recorded in the DB; only the fetch URL changes.
|
||||||
|
pub via_freedium: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resolves which cookies apply to `url` by evaluating all rules in ordinal order.
|
/// Resolves which cookies apply to `url` by evaluating all rules in ordinal order.
|
||||||
|
|
@ -1038,7 +1041,17 @@ pub fn perform_capture(
|
||||||
|
|
||||||
// Source: web page — archive as a self-contained HTML snapshot via single-file-cli
|
// Source: web page — archive as a self-contained HTML snapshot via single-file-cli
|
||||||
if source == Source::WebPage {
|
if source == Source::WebPage {
|
||||||
match downloader::singlefile::save(locator, store_path, ×tamp, &cookies, config.ublock_enabled, config.cookie_ext_enabled, config.reader_mode, config.modal_closer_enabled) {
|
// When via_freedium is enabled and the URL is not already a freedium mirror,
|
||||||
|
// fetch through the mirror to bypass paywalls. Store the original locator in DB.
|
||||||
|
// Use an empty cookie jar for the mirror URL: cookies resolved for the original
|
||||||
|
// domain (e.g. NYT, Medium) must not be sent to freedium-mirror.cfd.
|
||||||
|
let (fetch_url, fetch_cookies): (String, HashMap<String, String>) =
|
||||||
|
if config.via_freedium && !locator.starts_with("https://freedium-mirror.cfd/") {
|
||||||
|
(format!("https://freedium-mirror.cfd/{}", locator), HashMap::new())
|
||||||
|
} else {
|
||||||
|
(locator.to_string(), cookies.clone())
|
||||||
|
};
|
||||||
|
match downloader::singlefile::save(&fetch_url, store_path, ×tamp, &fetch_cookies, config.ublock_enabled, config.cookie_ext_enabled, config.reader_mode, config.modal_closer_enabled) {
|
||||||
Ok(result) => {
|
Ok(result) => {
|
||||||
let file_extension = ".html".to_string();
|
let file_extension = ".html".to_string();
|
||||||
let temp_html = store_path
|
let temp_html = store_path
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue