Compare commits
No commits in common. "main" and "direct-url" have entirely different histories.
main
...
direct-url
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,4 +5,3 @@ node_modules
|
|||||||
/target
|
/target
|
||||||
nzz/
|
nzz/
|
||||||
result
|
result
|
||||||
.direnv/
|
|
||||||
|
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -910,7 +910,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nzz-cookie"
|
name = "nzz-cookie"
|
||||||
version = "0.2.1"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@ -921,7 +921,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nzz-download"
|
name = "nzz-download"
|
||||||
version = "0.2.1"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
@ -76,9 +76,9 @@ nzz-cookie -u 'myuser@example.com' <pw | nzz-download -f 2024-06-01 -t 2024-06-0
|
|||||||
|
|
||||||
## Caveats
|
## Caveats
|
||||||
|
|
||||||
There are no retries on a failed downloads so far, it just crashes. Stemming
|
There are no retries on a failed download so far, it just crashes. Stemming from
|
||||||
from that I would advise not to try and download big ranges at once until that
|
that I would advise not to try and download big ranges at once until that is
|
||||||
is fixed.
|
fixed.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nzz-cookie"
|
name = "nzz-cookie"
|
||||||
version = "0.2.1"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = { workspace = true }
|
license = { workspace = true }
|
||||||
authors = { workspace = true }
|
authors = { workspace = true }
|
||||||
|
@ -30,20 +30,6 @@ pub async fn run(args: Config, pw: &str) -> Result<()> {
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
client.goto(LOGIN_URL).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?;
|
let login_button: Element = element_from_css(&client, ".fup-menu-login-container").await?;
|
||||||
sleep(Duration::from_millis(500)).await;
|
sleep(Duration::from_millis(500)).await;
|
||||||
login_button.click().await?;
|
login_button.click().await?;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nzz-download"
|
name = "nzz-download"
|
||||||
version = "0.2.1"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = { workspace = true }
|
license = { workspace = true }
|
||||||
authors = { workspace = true }
|
authors = { workspace = true }
|
||||||
|
@ -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 ISSUE_URL: &str = "https://zeitungsarchiv.nzz.ch/archive/1.0/getPages";
|
||||||
const MAX_DOWNLOADS: usize = 4;
|
const MAX_DOWNLOADS: usize = 4;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
|
||||||
struct SortOption {
|
|
||||||
field: String,
|
|
||||||
order: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
struct SearchData {
|
struct SearchData {
|
||||||
query: String,
|
query: String,
|
||||||
offset: u32,
|
offset: u32,
|
||||||
#[serde(
|
#[serde(rename = "sortField")]
|
||||||
|
sort_field: String,
|
||||||
|
#[serde(rename = "sortOrder")]
|
||||||
|
sort_order: String,
|
||||||
|
#[serde(
|
||||||
rename = "startDate",
|
rename = "startDate",
|
||||||
serialize_with = "crate::date::serialize",
|
serialize_with = "crate::date::serialize",
|
||||||
deserialize_with = "crate::date::deserialize"
|
deserialize_with = "crate::date::deserialize"
|
||||||
@ -34,8 +32,6 @@ struct SearchData {
|
|||||||
deserialize_with = "crate::date::deserialize"
|
deserialize_with = "crate::date::deserialize"
|
||||||
)]
|
)]
|
||||||
end_date: Date,
|
end_date: Date,
|
||||||
#[serde(rename = "sortOptions")]
|
|
||||||
sort_options: Vec<SortOption>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
@ -109,7 +105,8 @@ impl SearchData {
|
|||||||
Self {
|
Self {
|
||||||
query: "".to_string(),
|
query: "".to_string(),
|
||||||
offset,
|
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,
|
start_date,
|
||||||
end_date,
|
end_date,
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
fenixPkgs:
|
fenixPkgs:
|
||||||
fenixPkgs.fromToolchainFile {
|
fenixPkgs.fromToolchainFile {
|
||||||
file = ./rust-toolchain.toml;
|
file = ./rust-toolchain.toml;
|
||||||
sha256 = "sha256-VZZnlyP69+Y3crrLHQyJirqlHrTtGTsyiSnZB8jEvVo=";
|
sha256 = "sha256-Ngiz76YP4HTY75GGdH2P+APE/DEIx2R/Dn+BwwOyzZU=";
|
||||||
};
|
};
|
||||||
|
|
||||||
buildTargets = {
|
buildTargets = {
|
||||||
|
Loading…
Reference in New Issue
Block a user