Compare commits

...

28 Commits

Author SHA1 Message Date
M3DZIK b6ef4241ca
Release v0.11.3 2024-04-11 22:43:15 +02:00
M3DZIK 6d6cbbd4b0
Update docs in imgurs lib 2024-04-11 22:40:46 +02:00
M3DZIK 723bf26dbd
Delete total lines, code size and build status badges from readme 2024-04-11 22:39:39 +02:00
M3DZIK 56cbd96053
Fix clippy error 2024-04-11 22:37:59 +02:00
Andre Julius af0864d272 Update dependencies and replace validator crate with url crate 2024-04-11 22:32:30 +02:00
M3DZIK e782617f08
chore(release): v0.11.2 2023-06-22 13:50:08 +02:00
dependabot[bot] 7062046679 chore(deps): bump enumflags2 from 0.7.5 to 0.7.7
Bumps [enumflags2](https://github.com/meithecatte/enumflags2) from 0.7.5 to 0.7.7.
- [Release notes](https://github.com/meithecatte/enumflags2/releases)
- [Commits](https://github.com/meithecatte/enumflags2/compare/v0.7.5...v0.7.7)

---
updated-dependencies:
- dependency-name: enumflags2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-22 13:36:39 +02:00
dependabot[bot] 9ba2233734 chore(deps): bump openssl from 0.10.48 to 0.10.55
Bumps [openssl](https://github.com/sfackler/rust-openssl) from 0.10.48 to 0.10.55.
- [Release notes](https://github.com/sfackler/rust-openssl/releases)
- [Commits](https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.48...openssl-v0.10.55)

---
updated-dependencies:
- dependency-name: openssl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-22 13:36:30 +02:00
dependabot[bot] 044fa6525d chore(deps): bump h2 from 0.3.14 to 0.3.17
Bumps [h2](https://github.com/hyperium/h2) from 0.3.14 to 0.3.17.
- [Release notes](https://github.com/hyperium/h2/releases)
- [Changelog](https://github.com/hyperium/h2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/hyperium/h2/compare/v0.3.14...v0.3.17)

---
updated-dependencies:
- dependency-name: h2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-15 13:26:15 +02:00
dependabot[bot] f6d8e906fb chore(deps): bump bumpalo from 3.11.0 to 3.12.0
Bumps [bumpalo](https://github.com/fitzgen/bumpalo) from 3.11.0 to 3.12.0.
- [Release notes](https://github.com/fitzgen/bumpalo/releases)
- [Changelog](https://github.com/fitzgen/bumpalo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fitzgen/bumpalo/compare/3.11.0...3.12.0)

---
updated-dependencies:
- dependency-name: bumpalo
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 20:31:43 +02:00
dependabot[bot] 47b6225280 chore(deps): bump openssl from 0.10.42 to 0.10.48
Bumps [openssl](https://github.com/sfackler/rust-openssl) from 0.10.42 to 0.10.48.
- [Release notes](https://github.com/sfackler/rust-openssl/releases)
- [Commits](https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.42...openssl-v0.10.48)

---
updated-dependencies:
- dependency-name: openssl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 20:31:05 +02:00
Andre Julius e9a7108f90 Fix deprecation warning of base64 crate.
See: https://github.com/M3DZIK/imgurs/actions/runs/3871046426/jobs/6598478600
2023-04-03 20:29:17 +02:00
renovate[bot] 0398f7f675 fix(deps): update all non-major dependencies 2023-01-30 04:52:40 +00:00
renovate[bot] 300fa61a65 fix(deps): update all non-major dependencies to 4.1 2023-01-16 04:10:52 +00:00
renovate[bot] 0ad55015ac fix(deps): update rust crate tokio to 1.24 [security] 2023-01-09 12:54:49 +00:00
renovate[bot] 965c4407f1 fix(deps): update all non-major dependencies 2023-01-09 05:30:05 +00:00
renovate[bot] 80292730f3 fix(deps): update all non-major dependencies 2022-12-12 04:55:31 +00:00
MedzikUser 304034f037
chore(release): v0.11.1 2022-12-11 11:05:51 +01:00
Andre Julius b6e715accf album_title can be null. account_id can be a string or a number 2022-12-11 09:40:18 +01:00
renovate[bot] d29b299a4b fix(deps): update rust crate notify-rust to 4.6 2022-12-05 04:22:49 +00:00
renovate[bot] c08e640421 fix(deps): update rust crate tokio to 1.22 2022-11-21 04:10:16 +00:00
MedzikUser 60119be30b
chore: update 2022-11-07 17:17:09 +01:00
MedzikUser 986a3b365c
chore(release): v0.11.0 2022-11-07 17:13:50 +01:00
MedzikUser 25cc96774c
fix: rename function to `with_http_client` 2022-11-07 17:05:01 +01:00
renovate[bot] 111fef82d1 fix(deps): update rust crate arboard to v3 2022-11-07 08:33:47 +01:00
renovate[bot] 5d5beaecd8 fix(deps): update rust crate simple_logger to v4 2022-11-07 08:33:32 +01:00
Andre Julius 89a7969353 Add `with_http_client` method to ImgurClient
This will allow customization of the http client or just providing an already existing http client.
In my use case I already have a client I'd like to reuse.
2022-11-07 08:30:13 +01:00
MedzikUser 25190ba5c1
chore(deps): update cargo lock 2022-10-01 18:47:02 +02:00
8 changed files with 1345 additions and 843 deletions

View File

@ -9,6 +9,29 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
## [0.11.3] - 2024-04-11
- Updated dependencies
- Replaced url validation with url crate in imgurs-cli
## [0.11.2] - 2023-06-22
- Updated dependencies
- Fix deprecation warning of base64 crate.
## [0.11.1] - 2022-12-11
### Fixed
- `album_title` can be null, `account_id` can be null, string or number #92, thanks to @NotNorom
### Changed
- Updated dependencies
## [0.11.0] - 2022-11-07
### Added
- Added `with_http_client` method to ImgurClient #87, thanks to @NotNorom
### Changed
- Updated crate arboard to v3
- Updated crate simple_logger to v4
## [0.10.0] - 2022-10-01
- add configuration for tls (rustls-tls or native-tls)
@ -139,8 +162,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- upload image
<!-- next-url -->
[Unreleased]: https://github.com/MedzikUser/imgurs/compare/v0.8.0...HEAD
[0.7.4]: https://github.com/MedzikUser/imgurs/commits/v0.8.0
[Unreleased]: https://github.com/MedzikUser/imgurs/compare/v0.11.3...HEAD
[0.11.3]: https://github.com/MedzikUser/imgurs/commits/v0.11.3
[0.11.2]: https://github.com/MedzikUser/imgurs/commits/v0.11.2
[0.11.1]: https://github.com/MedzikUser/imgurs/commits/v0.11.1
[0.11.0]: https://github.com/MedzikUser/imgurs/commits/v0.11.0
[0.10.0]: https://github.com/MedzikUser/imgurs/commits/v0.10.0
[0.9.1]: https://github.com/MedzikUser/imgurs/commits/v0.9.1
[0.9.0]: https://github.com/MedzikUser/imgurs/commits/v0.9.0
[0.8.1]: https://github.com/MedzikUser/imgurs/commits/v0.8.1
[0.8.0]: https://github.com/MedzikUser/imgurs/commits/v0.8.0
[0.7.4]: https://github.com/MedzikUser/imgurs/commits/v0.7.4
[0.7.3]: https://github.com/MedzikUser/imgurs/commits/v0.7.3
[0.7.2]: https://github.com/MedzikUser/imgurs/commits/v0.7.2

2060
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -4,12 +4,12 @@ resolver = "2"
[package]
name = "imgurs"
version = "0.10.0"
version = "0.11.3"
description = "API for Imgur"
license = "BSD-3-Clause"
authors = ["MedzikUser <medzik@duck.com>"]
homepage = "https://github.com/MedzikUser/imgurs"
repository = "https://github.com/MedzikUser/imgurs.git"
authors = ["M3DZIK <me@medzik.dev>"]
homepage = "https://github.com/M3DZIK/imgurs"
repository = "https://github.com/M3DZIK/imgurs.git"
keywords = ["imgur", "imgur-api", "image", "image-upload"]
edition = "2021"
@ -27,10 +27,10 @@ codegen-units = 1
[dependencies]
# HTTP
reqwest = { version = "0.11", default-features = false, features = ["json", "multipart"] }
reqwest = { version = "0.12", default-features = false, features = ["json", "multipart"] }
# Request
base64 = "0.13"
validator = "0.16" # validate url address
base64 = "0.22"
url = "2.5.0" # validate url address
# Response
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
@ -40,4 +40,4 @@ thiserror = "1.0"
[dev-dependencies]
# Async tests
tokio = { version = "1.21", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1.37", features = ["macros", "rt-multi-thread"] }

View File

@ -1,16 +1,10 @@
[total-lines]: https://img.shields.io/tokei/lines/github/MedzikUser/HomeDisk?style=for-the-badge&logo=github&color=fede00
[code-size]: https://img.shields.io/github/languages/code-size/MedzikUser/HomeDisk?style=for-the-badge&color=c8df52&logo=github
[crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
[docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs
[ci]: https://img.shields.io/github/workflow/status/MedzikUser/rust-crypto-utils/Rust/main?style=for-the-badge&logo=github
# Imgurs - CLI and Library for Imgur API
[![total-lines]](https://github.com/MedzikUser/HomeDisk)
[![code-size]](https://github.com/MedzikUser/HomeDisk)
[![crates-io]](https://crates.io/crates/imgurs)
[![docs-rs]](https://docs.rs/imgurs)
[![ci]](https://github.com/MedzikUser/imgurs/actions/workflows/rust.yml)
## Screenshots
@ -74,4 +68,4 @@ Download imgurs-windows.exe from [the releases page](https://github.com/MedzikUs
### **Compile with Cargo**
Make sure you have a recent version of Rust. Then you can run
cargo install imgurs
cargo install imgurs-cli

View File

@ -1,11 +1,11 @@
[package]
name = "imgurs-cli"
version = "0.10.0"
version = "0.11.3"
description = "CLI for Imgur"
license = "BSD-3-Clause"
authors = ["MedzikUser <medzik@duck.com>"]
homepage = "https://github.com/MedzikUser/imgurs"
repository = "https://github.com/MedzikUser/imgurs.git"
authors = ["M3DZIK <me@medzik.dev>"]
homepage = "https://github.com/M3DZIK/imgurs"
repository = "https://github.com/M3DZIK/imgurs.git"
keywords = ["imgur", "imgur-api", "image", "image-upload"]
categories = ["command-line-utilities"]
edition = "2021"
@ -16,11 +16,11 @@ path = "src/main.rs"
[dependencies]
# Async runtime
tokio = { version = "1.21", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1.37", features = ["macros", "rt-multi-thread"] }
# CLI
clap = { version = "4.0", features = ["derive"] }
clap_complete = "4.0"
clap = { version = "4.5", features = ["derive"] }
clap_complete = "4.5"
clap_mangen = "0.2"
# Errors
@ -28,19 +28,19 @@ anyhow = "1.0"
# Logger
log = { version = "0.4", features = ["release_max_level_info"] }
simple_logger = "2.3"
colored = "2.0"
simple_logger = "4.3"
colored = "2.1"
# Config
toml = "0.5"
toml = "0.8"
serde = { version = "1.0", features = ["derive"] }
# Other
chrono = "0.4" # parse upload date
notify-rust = "4.5" # send notification after upload
dirs = "4.0" # get system configuration directory
notify-rust = "4.11" # send notification after upload
dirs = "5.0" # get system configuration directory
imgurs = { path = "..", version = "0.10.0", features = ["full"] }
imgurs = { path = "..", version = "0.11.0", features = ["full"] }
[target.'cfg(not(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten")))))'.dependencies]
arboard = "2.1" # copy url to clipboard
arboard = "3.3" # copy url to clipboard

View File

@ -18,7 +18,7 @@ pub struct AlbumInfoData {
/// Album ID
pub id: String,
/// Title of the album
pub title: String,
pub title: Option<String>,
/// Description of the album
pub description: Option<String>,
pub datetime: i64,
@ -27,7 +27,7 @@ pub struct AlbumInfoData {
pub cover_width: i64,
pub cover_height: i64,
pub account_url: Option<String>,
pub account_id: Option<String>,
pub account_id: Option<AccountId>,
pub privacy: String,
pub layout: String,
pub views: i64,
@ -45,6 +45,13 @@ pub struct AlbumInfoData {
pub ad_config: AdConfig,
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
#[serde(untagged)]
pub enum AccountId {
String(String),
Int(i64),
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
pub struct AdConfig {
#[serde(rename = "safeFlags")]

View File

@ -9,6 +9,7 @@ pub(crate) use client::api_url;
pub use client::ImgurClient;
pub use image_type::*;
pub use send_api_request::*;
use url::Url;
use crate::{Error, Result};
@ -25,6 +26,25 @@ impl ImgurClient {
ImgurClient { client_id, client }
}
/// Create a new Imgur Client with the provided `reqwest::Client`
///
/// This allows for customization of the http client settings like timeout or the user agent.
/// ```
/// use imgurs::ImgurClient;
/// use reqwest::Client;
///
/// let http_client = Client::builder().build().unwrap();
///
/// let client = ImgurClient::with_http_client("3e3ce0d7ac14d56", http_client);
/// ```
pub fn with_http_client(client_id: &str, http_client: reqwest::Client) -> Self {
let client_id = client_id.to_string();
ImgurClient {
client_id,
client: http_client,
}
}
/// Upload image to Imgur
/// ```
/// use imgurs::ImgurClient;
@ -40,15 +60,17 @@ impl ImgurClient {
/// }
/// ```
pub async fn upload_image(&self, path: &str) -> Result<ImageInfo> {
use base64::prelude::{Engine, BASE64_STANDARD};
let mut image = path.to_string();
// check if the specified file exists if not then check if it is a url
if std::path::Path::new(path).exists() {
let bytes = std::fs::read(path)?;
image = base64::encode(bytes)
image = BASE64_STANDARD.encode(bytes)
}
// validate url adress
else if !validator::validate_url(path) {
else if Url::parse(path).is_err() {
Err(Error::InvalidUrlOrFile(path.to_string()))?;
}

View File

@ -1,4 +1,4 @@
//! [![github]](https://github.com/MedzikUser/imgurs)
//! [![github]](https://github.com/M3DZIK/imgurs)
//! [![crates-io]](https://crates.io/crates/imgurs)
//! [![docs-rs]](https://docs.rs/imgurs)
//!
@ -19,7 +19,7 @@
//! your application, simply add it to your project's `Cargo.toml`.
//! ```toml
//! [dependencies]
//! imgurs = "0.8.0"
//! imgurs = "0.11.3"
//! ```
//!
//! # Example Usage