added bit more verbose output and my build script.
also embedded demo of usage
This commit is contained in:
parent
4d5fc9c2a7
commit
6d2a4aa625
5 changed files with 18 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "pixelfed_batch_uploader"
|
||||
version = "0.1.0"
|
||||
version = "1.0.2"
|
||||
edition = "2021"
|
||||
|
||||
[build]
|
||||
|
|
|
@ -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
|
||||
|
|
4
build.sh
Executable file
4
build.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash -x
|
||||
|
||||
cargo clean
|
||||
cargo build --release --target $(rustc -vV | grep host | cut -d ' ' -f2)
|
|
@ -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 \
|
||||
|
|
|
@ -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,6 +44,7 @@ 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)?;
|
||||
|
||||
|
@ -68,6 +68,7 @@ fn upload_images_batch(client: &Client, config: &Config, images: &[String], batc
|
|||
"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<dyn Error>> {
|
|||
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)?;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue