Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI upload supports switching submission interface #157

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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