Skip to content

Commit

Permalink
CLI upload supports switching submission interface (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxxuanran authored Jun 6, 2024
1 parent 9288716 commit 36790ce
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions crates/biliup/src/uploader/bilibili.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ pub struct Studio {
#[clap(long)]
#[serde(default)]
pub up_close_danmu: bool,

#[clap(long)]
#[serde(default)]
pub submit_by_app: bool,
}

#[derive(Default, Debug, Serialize, Deserialize)]
Expand Down Expand Up @@ -278,6 +282,7 @@ impl BiliBili {
.await?;
info!("{:?}", ret);
if ret.code == 0 {
info!("APP接口投稿成功");
Ok(ret)
} else {
Err(Kind::Custom(format!("{:?}", ret)))
Expand Down
3 changes: 3 additions & 0 deletions crates/bin/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub enum Commands {

#[command(flatten)]
studio: Studio,

// #[arg(required = false, last = true, default_value = "client")]
// submit: Option<String>,
},
/// 是否要对某稿件追加视频
Append {
Expand Down
1 change: 1 addition & 0 deletions crates/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async fn main() -> Result<()> {
line,
limit,
studio,
// submit,
} => upload_by_command(studio, cli.user_cookie, video_path, line, limit).await?,
Commands::Upload {
video_path: _,
Expand Down
14 changes: 13 additions & 1 deletion crates/bin/uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub async fn upload_by_command(
video_path: Vec<PathBuf>,
line: Option<UploadLine>,
limit: usize,
// submit: Option<String>,
) -> Result<()> {
let bili = login_by_cookies(user_cookie).await?;
if studio.title.is_empty() {
Expand All @@ -81,7 +82,18 @@ pub async fn upload_by_command(
}
cover_up(&mut studio, &bili).await?;
studio.videos = upload(&video_path, &bili, line, limit).await?;
bili.submit(&studio).await?;

if studio.submit_by_app {
bili.submit_by_app(&studio).await?;
}
else {
bili.submit(&studio).await?;
}
// match submit.as_deref() {
// Some("app") => bili.submit_by_app(&studio).await?,
// _ => bili.submit(&studio).await?,
// };

Ok(())
}

Expand Down

0 comments on commit 36790ce

Please sign in to comment.