mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
add support to download image
This commit is contained in:
@@ -2,14 +2,19 @@ use crate::gettext;
|
||||
use html_parser::Dom;
|
||||
use html_parser::Node;
|
||||
use json::JsonValue;
|
||||
use std::default::Default;
|
||||
|
||||
pub struct MainPageParser {
|
||||
pub struct MetaDataParser {
|
||||
pub key: String,
|
||||
pub value: Option<JsonValue>,
|
||||
}
|
||||
|
||||
impl MainPageParser {
|
||||
pub fn new() -> Self {
|
||||
impl MetaDataParser {
|
||||
/// Create an new instance
|
||||
/// * `key` - meta's name
|
||||
pub fn new(key: &str) -> Self {
|
||||
Self {
|
||||
key: key.to_string(),
|
||||
value: None,
|
||||
}
|
||||
}
|
||||
@@ -26,13 +31,14 @@ impl MainPageParser {
|
||||
if name.is_none() {
|
||||
return false;
|
||||
}
|
||||
if name.as_ref().unwrap() != "global-data" {
|
||||
if name.as_ref().unwrap() != self.key.as_str() {
|
||||
return false;
|
||||
}
|
||||
if e.id.is_none() {
|
||||
return false;
|
||||
}
|
||||
if e.id.as_ref().unwrap() != "meta-global-data" {
|
||||
let mkey = format!("meta-{}", self.key.as_str());
|
||||
if e.id.as_ref().unwrap() != mkey.as_str() {
|
||||
return false;
|
||||
}
|
||||
let c = e.attributes.get("content");
|
||||
@@ -85,3 +91,9 @@ impl MainPageParser {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MetaDataParser {
|
||||
fn default() -> Self {
|
||||
Self::new("global-data")
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
extern crate html_parser;
|
||||
|
||||
pub mod mainpage;
|
||||
pub mod metadata;
|
||||
|
||||
Reference in New Issue
Block a user