mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-09-05 15:39:07 +08:00
refactor: 优化部分代码,移除一批 unwrap
This commit is contained in:
@@ -133,7 +133,7 @@ impl<'a> Collection<'a> {
|
||||
("pn", page.as_str()),
|
||||
("ps", "30"),
|
||||
],
|
||||
MIXIN_KEY.load().as_deref().map(|x| x.as_str()),
|
||||
MIXIN_KEY.load().as_deref(),
|
||||
),
|
||||
),
|
||||
CollectionType::Season => (
|
||||
@@ -146,7 +146,7 @@ impl<'a> Collection<'a> {
|
||||
("page_num", page.as_str()),
|
||||
("page_size", "30"),
|
||||
],
|
||||
MIXIN_KEY.load().as_deref().map(|x| x.as_str()),
|
||||
MIXIN_KEY.load().as_deref(),
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
@@ -210,10 +210,10 @@ fn get_filename(url: &str) -> Option<&str> {
|
||||
|
||||
pub fn encoded_query<'a>(
|
||||
params: Vec<(&'a str, impl Into<Cow<'a, str>>)>,
|
||||
mixin_key: Option<&str>,
|
||||
mixin_key: Option<impl AsRef<str>>,
|
||||
) -> Vec<(&'a str, Cow<'a, str>)> {
|
||||
match mixin_key {
|
||||
Some(key) => _encoded_query(params, key, chrono::Local::now().timestamp().to_string()),
|
||||
Some(key) => _encoded_query(params, key.as_ref(), chrono::Local::now().timestamp().to_string()),
|
||||
None => params.into_iter().map(|(k, v)| (k, v.into())).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ impl<'a> Submission<'a> {
|
||||
("pn", page.to_string()),
|
||||
("ps", "30".to_string()),
|
||||
],
|
||||
MIXIN_KEY.load().as_deref().map(|x| x.as_str()),
|
||||
MIXIN_KEY.load().as_deref(),
|
||||
))
|
||||
.send()
|
||||
.await?
|
||||
|
||||
@@ -154,7 +154,7 @@ impl<'a> Video<'a> {
|
||||
("fnval", "4048"),
|
||||
("fourk", "1"),
|
||||
],
|
||||
MIXIN_KEY.load().as_deref().map(|x| x.as_str()),
|
||||
MIXIN_KEY.load().as_deref(),
|
||||
))
|
||||
.send()
|
||||
.await?
|
||||
|
||||
Reference in New Issue
Block a user