Skip to content

Commit

Permalink
Merge pull request #95 from hguandl/dev
Browse files Browse the repository at this point in the history
修改日志的日期格式,少量warning修复
  • Loading branch information
haha114514 authored Jul 14, 2023
2 parents 7712346 + f82e63a commit 2787fd3
Show file tree
Hide file tree
Showing 8 changed files with 272 additions and 174 deletions.
423 changes: 256 additions & 167 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion crates/biliup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ reqwest_cookie_store = "0.5.0"
cookie_store = "0.19.0"
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing-subscriber = { version = "0.3", features = ["env-filter", "local-time"] }
rsa = "0.9.2"
base64 = "0.21.0"
md-5 = "0.10.5"
Expand All @@ -35,6 +35,7 @@ typed-builder = "0.11.0"
reqwest-middleware = "0.2.0"
reqwest-retry = "0.2.1"
clap = { version = "4", features = ["derive"] }
time = "0.3"

anyhow = "1.0"
#clap = { version = "3.0.0", features = ["derive"] }
Expand Down
3 changes: 1 addition & 2 deletions crates/biliup/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ pub struct StatefulClient {
}

impl StatefulClient {
pub fn new(mut headers: HeaderMap) -> Self {
headers.insert("Connection", header::HeaderValue::from_static("keep-alive"));
pub fn new(headers: HeaderMap) -> Self {
let cookie_store = cookie_store::CookieStore::default();
let cookie_store = CookieStoreMutex::new(cookie_store);
let cookie_store = Arc::new(cookie_store);
Expand Down
2 changes: 1 addition & 1 deletion crates/biliup/src/uploader/bilibili.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl BiliBili {
.client
.post("https://member.bilibili.com/x/vu/web/cover/up")
.form(&json!({
"cover": format!("data:image/jpeg;base64,{}", base64::encode(input)),
"cover": format!("data:image/jpeg;base64,{}", base64::Engine::encode(&base64::engine::general_purpose::STANDARD, input)),
"csrf": csrf["value"]
}))
.send()
Expand Down
1 change: 0 additions & 1 deletion crates/biliup/src/uploader/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::uploader::bilibili::{BiliBili, ResponseData};
use base64::{engine::general_purpose, Engine as _};
use cookie::Cookie;
use md5::{Digest, Md5};
use rand::rngs::OsRng;
use reqwest::header::{COOKIE, ORIGIN, REFERER, USER_AGENT};

use rsa::{pkcs8::DecodePublicKey, Pkcs1v15Encrypt, RsaPublicKey};
Expand Down
6 changes: 5 additions & 1 deletion crates/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ async fn main() -> Result<()> {
// tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
let cli = Cli::parse();

let timer = tracing_subscriber::fmt::time::LocalTime::new(format_description!(
"[year]-[month]-[day] [hour]:[minute]:[second]"
));

tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::new(&cli.rust_log))
.with(tracing_subscriber::fmt::layer())
.with(tracing_subscriber::fmt::layer().with_timer(timer))
.init();

match cli.command {
Expand Down
1 change: 1 addition & 0 deletions crates/stream-gears/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ tracing-appender = "0.2"
anyhow = "1.0"
futures = "0.3.21"
biliup = { path = "../biliup"}
time = "0.3"

#[target.'cfg(all(target_arch="aarch64", target_os="linux"))'.dependencies]
#downloader = { path = "../downloader", default-features = false , features = ["rustls-tls"] }
Expand Down
7 changes: 6 additions & 1 deletion crates/stream-gears/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod login;
mod uploader;

use pyo3::prelude::*;
use time::macros::format_description;
use uploader::PyCredit;

use std::collections::HashMap;
Expand Down Expand Up @@ -151,9 +152,13 @@ fn upload(
.enable_all()
.build()?;
// 输出到控制台中
let local_time = tracing_subscriber::fmt::time::LocalTime::new(format_description!(
"[year]-[month]-[day] [hour]:[minute]:[second]"
));
let formatting_layer = tracing_subscriber::FmtSubscriber::builder()
// will be written to stdout.
// builds the subscriber.
.with_timer(local_time)
.finish();
let file_appender = tracing_appender::rolling::never("", "upload.log");
let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);
Expand Down Expand Up @@ -210,7 +215,7 @@ fn stream_gears(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(send_sms, m)?)?;
m.add_function(wrap_pyfunction!(login_by_qrcode, m)?)?;
m.add_function(wrap_pyfunction!(get_qrcode, m)?)?;
// m.add_function(wrap_pyfunction(login_by_sms, m)?)?;
m.add_function(wrap_pyfunction!(login_by_sms, m)?)?;
m.add_class::<UploadLine>()?;
Ok(())
}

0 comments on commit 2787fd3

Please sign in to comment.