diff --git a/Cargo.toml b/Cargo.toml index a54f413..26da7ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pixelfed_batch_uploader" -version = "0.1.0" +version = "1.0.2" edition = "2021" [build] diff --git a/README.md b/README.md index f9e560f..0885890 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,9 @@ The description of the post can be given via the config.json. Two variables in the post description can be give (see the `config.json.example` ). Usage: `./pixelfed_batch_uploader ../../Downloads/Instagram-Backup/media/posts/201406 --title "June 2014"` + + +[![asciicast](https://asciinema.mxhdr.net/a/6.svg)](https://asciinema.mxhdr.net/a/6) + + +Check the package of this repo to get pre-compiled binaries for macOS (Apple Silicon), Linux x86_64, Windows ARM diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..5c5e017 --- /dev/null +++ b/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash -x + +cargo clean +cargo build --release --target $(rustc -vV | grep host | cut -d ' ' -f2) diff --git a/package.sh b/package.sh index 34592b0..62f03b9 100755 --- a/package.sh +++ b/package.sh @@ -1,6 +1,6 @@ #!/bin/bash -x -RELEASE_VERSION="1.0.1" +RELEASE_VERSION="1.0.2" curl --netrc \ --upload-file target/$(rustc -vV | grep host | cut -d ' ' -f2)/release/pixelfed_batch_uploader \ diff --git a/src/main.rs b/src/main.rs index ae1c331..91feb4e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ use std::fs; -use std::path::Path; -use serde::{Deserialize, Serialize}; +use serde::Deserialize; use reqwest::blocking::Client; use std::error::Error; @@ -45,9 +44,10 @@ fn upload_images_batch(client: &Client, config: &Config, images: &[String], batc let mut media_ids = Vec::new(); for image_path in images { + println!("Uploading image {}", image_path.to_string()); let form = reqwest::blocking::multipart::Form::new() .file("file", image_path)?; - + let res = client.post(&url) .bearer_auth(&config.access_token) .multipart(form) @@ -67,7 +67,8 @@ fn upload_images_batch(client: &Client, config: &Config, images: &[String], batc "media_ids": media_ids, "visibility": config.visibility, }); - + + println!("Posting batch {} out of {}", batch_num, total_batches); client.post(&post_url) .bearer_auth(&config.access_token) .json(&body) @@ -95,7 +96,7 @@ fn main() -> Result<(), Box> { let images = get_jpeg_files(&args[1]); let client = Client::new(); let total_batches = (images.len() + config.batch_size - 1) / config.batch_size; - + println!("Found a total of {} images to upload. Will take {} batches", images.len(), total_batches); for (i, chunk) in images.chunks(config.batch_size).enumerate() { upload_images_batch(&client, &config, chunk, i + 1, total_batches, &title)?; }