Compare commits

..

No commits in common. "main" and "direct-url" have entirely different histories.

9 changed files with 15 additions and 34 deletions

1
.envrc
View File

@ -1 +0,0 @@
use flake

1
.gitignore vendored
View File

@ -5,4 +5,3 @@ node_modules
/target
nzz/
result
.direnv/

4
Cargo.lock generated
View File

@ -910,7 +910,7 @@ dependencies = [
[[package]]
name = "nzz-cookie"
version = "0.2.1"
version = "0.1.0"
dependencies = [
"anyhow",
"clap",
@ -921,7 +921,7 @@ dependencies = [
[[package]]
name = "nzz-download"
version = "0.2.1"
version = "0.1.0"
dependencies = [
"anyhow",
"clap",

View File

@ -76,9 +76,9 @@ nzz-cookie -u 'myuser@example.com' <pw | nzz-download -f 2024-06-01 -t 2024-06-0
## Caveats
There are no retries on a failed downloads so far, it just crashes. Stemming
from that I would advise not to try and download big ranges at once until that
is fixed.
There are no retries on a failed download so far, it just crashes. Stemming from
that I would advise not to try and download big ranges at once until that is
fixed.
## License

View File

@ -1,6 +1,6 @@
[package]
name = "nzz-cookie"
version = "0.2.1"
version = "0.1.0"
edition = "2021"
license = { workspace = true }
authors = { workspace = true }

View File

@ -30,20 +30,6 @@ pub async fn run(args: Config, pw: &str) -> Result<()> {
.await?;
client.goto(LOGIN_URL).await?;
sleep(Duration::from_millis(500)).await;
// Sometimes cookie notice has to bee accepted, not sure when though
if client.find(Locator::Css(".cmpboxbtncustom")).await.is_ok() {
let fu_open_button: Element = element_from_css(&client, ".cmpboxbtncustom").await?;
fu_open_button.click().await?;
let fu_button: Element = element_from_css(&client, ".cmpboxbtn.cmpboxbtnyes.cmpboxbtnyescustomchoices.cmptxt_btn_save").await?;
sleep(Duration::from_millis(500)).await;
fu_button.click().await?;
}
let login_button: Element = element_from_css(&client, ".fup-menu-login-container").await?;
sleep(Duration::from_millis(500)).await;
login_button.click().await?;

View File

@ -1,6 +1,6 @@
[package]
name = "nzz-download"
version = "0.2.1"
version = "0.1.0"
edition = "2021"
license = { workspace = true }
authors = { workspace = true }

View File

@ -12,17 +12,15 @@ const SEARCH_URL: &str = "https://zeitungsarchiv.nzz.ch/solr-epaper-search/1.0/s
const ISSUE_URL: &str = "https://zeitungsarchiv.nzz.ch/archive/1.0/getPages";
const MAX_DOWNLOADS: usize = 4;
#[derive(Debug, Serialize, Deserialize)]
struct SortOption {
field: String,
order: String,
}
#[derive(Debug, Serialize, Deserialize)]
struct SearchData {
query: String,
offset: u32,
#[serde(
#[serde(rename = "sortField")]
sort_field: String,
#[serde(rename = "sortOrder")]
sort_order: String,
#[serde(
rename = "startDate",
serialize_with = "crate::date::serialize",
deserialize_with = "crate::date::deserialize"
@ -34,8 +32,6 @@ struct SearchData {
deserialize_with = "crate::date::deserialize"
)]
end_date: Date,
#[serde(rename = "sortOptions")]
sort_options: Vec<SortOption>
}
#[derive(Debug, Serialize, Deserialize)]
@ -109,7 +105,8 @@ impl SearchData {
Self {
query: "".to_string(),
offset,
sort_options: vec![SortOption { field: "media_ts".to_string(), order: "desc".to_string() }],
sort_field: "media_ts".to_string(),
sort_order: "desc".to_string(),
start_date,
end_date,
}

View File

@ -21,7 +21,7 @@
fenixPkgs:
fenixPkgs.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-VZZnlyP69+Y3crrLHQyJirqlHrTtGTsyiSnZB8jEvVo=";
sha256 = "sha256-Ngiz76YP4HTY75GGdH2P+APE/DEIx2R/Dn+BwwOyzZU=";
};
buildTargets = {