mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
add support for ugoira
add progress bar
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use crate::data::data::PixivData;
|
||||
use crate::ext::json::ToJson;
|
||||
use crate::gettext;
|
||||
use crate::parser::description::parse_description;
|
||||
use crate::pixiv_link::PixivID;
|
||||
@@ -12,10 +13,6 @@ use std::fs::remove_file;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
pub trait ToJson {
|
||||
fn to_json(&self) -> Option<JsonValue>;
|
||||
}
|
||||
|
||||
/// Store metadata informations in JSON file
|
||||
pub struct JSONDataFile {
|
||||
id: PixivID,
|
||||
@@ -117,33 +114,3 @@ impl ToJson for JSONDataFile {
|
||||
Some(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToJson for &str {
|
||||
fn to_json(&self) -> Option<JsonValue> {
|
||||
Some(JsonValue::String(String::from(*self)))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToJson for &String {
|
||||
fn to_json(&self) -> Option<JsonValue> {
|
||||
Some(JsonValue::String((*self).to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToJson for String {
|
||||
fn to_json(&self) -> Option<JsonValue> {
|
||||
Some(JsonValue::String(self.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToJson for JsonValue {
|
||||
fn to_json(&self) -> Option<JsonValue> {
|
||||
Some(self.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToJson for &JsonValue {
|
||||
fn to_json(&self) -> Option<JsonValue> {
|
||||
Some((*self).clone())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,3 +2,5 @@ pub mod data;
|
||||
#[cfg(feature = "exif")]
|
||||
pub mod exif;
|
||||
pub mod json;
|
||||
#[cfg(feature = "avdict")]
|
||||
pub mod video;
|
||||
|
||||
26
src/data/video.rs
Normal file
26
src/data/video.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use crate::avdict::AVDict;
|
||||
use crate::avdict::AVDictError;
|
||||
use crate::data::data::PixivData;
|
||||
use crate::parser::description::parse_description;
|
||||
|
||||
pub fn get_video_metadata(data: &PixivData) -> Result<AVDict, AVDictError> {
|
||||
let mut d = AVDict::new();
|
||||
if data.title.is_some() {
|
||||
let t = data.title.as_ref().unwrap();
|
||||
d.set("title", t, None)?;
|
||||
}
|
||||
if data.author.is_some() {
|
||||
let au = data.author.as_ref().unwrap();
|
||||
d.set("artist", au, None)?;
|
||||
}
|
||||
if data.description.is_some() {
|
||||
let odesc = data.description.as_ref().unwrap();
|
||||
let desc = parse_description(odesc);
|
||||
let des = match &desc {
|
||||
Some(d) => { d }
|
||||
None => { odesc }
|
||||
};
|
||||
d.set("comment", des, None)?;
|
||||
}
|
||||
Ok(d)
|
||||
}
|
||||
Reference in New Issue
Block a user