fix
This commit is contained in:
parent
c44b881e69
commit
61ae905521
8 changed files with 28 additions and 12 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1539,7 +1539,7 @@ checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7"
|
|||
|
||||
[[package]]
|
||||
name = "site_icons"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"clap",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "site_icons"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
authors = ["Sam Denty <sam@samdenty.com>"]
|
||||
edition = "2018"
|
||||
license = "GPL-3.0"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[tasks.run]
|
||||
env = { "RUST_LOG" = "site_icons" }
|
||||
env = { "RUST_LOG" = "info" }
|
||||
command = "cargo"
|
||||
args = ["run", "--", "${@}"]
|
||||
|
|
|
@ -21,7 +21,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
|
||||
if opts.debug {
|
||||
let mut builder = Builder::new();
|
||||
builder.filter_module("site_icons", LevelFilter::Info);
|
||||
builder.filter_module("info", LevelFilter::Info);
|
||||
builder.init();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{selector, utils::encode_svg, warn_err, Icon, IconInfo, IconKind, CLIENT};
|
||||
use crate::{utils::encode_svg, Icon, IconInfo, IconKind, CLIENT};
|
||||
use future::join_all;
|
||||
use futures::StreamExt;
|
||||
use futures::{prelude::*, task::noop_waker};
|
||||
|
|
23
src/lib.rs
23
src/lib.rs
|
@ -1,14 +1,35 @@
|
|||
#![feature(async_closure, map_into_keys_values, bool_to_option)]
|
||||
//! # site_icons
|
||||
//! An efficient website icon scraper.
|
||||
//!
|
||||
//! ## Usage
|
||||
//! ```rust
|
||||
//! use site_icons::Icons;
|
||||
//!
|
||||
//! let icons = Icons::new();
|
||||
//! // scrape the icons from a url
|
||||
//! icons.load_website("https://github.com").await?;
|
||||
//!
|
||||
//! // fetch all icons, ensuring they exist & determining size
|
||||
//! let entries = icons.entries().await;
|
||||
//!
|
||||
//! // entries are sorted from highest to lowest resolution
|
||||
//! for icon in entries {
|
||||
//! println("{:?}", icon)
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_with;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
mod icon;
|
||||
mod icon_info;
|
||||
mod icon_size;
|
||||
mod icons;
|
||||
mod macros;
|
||||
mod utils;
|
||||
|
||||
pub use icon::*;
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
#[macro_export]
|
||||
macro_rules! selector {
|
||||
($($selector:expr),+ $(,)?) => {{
|
||||
static RE: once_cell::sync::OnceCell<scraper::Selector> = once_cell::sync::OnceCell::new();
|
||||
RE.get_or_init(|| scraper::Selector::parse(crate::join!(",", $($selector),+)).unwrap())
|
||||
RE.get_or_init(|| scraper::Selector::parse(join!(",", $($selector),+)).unwrap())
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! join {
|
||||
($pattern:literal,$first:expr$(, $($rest:expr),*)? $(,)?) => {
|
||||
concat!($first$(, $($pattern, $rest),*)?)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! regex {
|
||||
($re:literal $(,)?) => {{
|
||||
static RE: once_cell::sync::OnceCell<regex::Regex> = once_cell::sync::OnceCell::new();
|
||||
|
@ -21,7 +18,6 @@ macro_rules! regex {
|
|||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! warn_err {
|
||||
($result:expr, $($arg:tt)*) => {{
|
||||
if let Err(err) = $result {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use crate::regex;
|
||||
use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS};
|
||||
|
||||
const DATA_URI: &AsciiSet = &CONTROLS
|
||||
|
|
Reference in a new issue