Intro

Tumblr APIs for Rust

Usage

Create a new photo post:

```rust extern crate rumblr;

// --- external --- use rumblr::TumblrClient;

fn main() { // OAUTH const CONSUMERKEY: &'static str = "YOUR CONSUMER KEY"; const CONSUMERSECRET: &'static str = "YOUR CONSUMER SECRET";

let client = TumblrClient::new()
    .set_consumer(CONSUMER_KEY, CONSUMER_SECRET)
    .proxy("http://127.0.0.1:1087")
    .unwrap()
    .oauth();

client.save_keys("rumblr.keys").unwrap();

// Already OAUTHed
let client = TumblrClient::new()
    .proxy("http://127.0.0.1:1087")
    .unwrap()
    .load_keys("rumblr.keys")
    .unwrap();

println!(
    "{:?}",
    client.legacy_post(
        "cestxavier.tumblr.com",
        rumblr::PostAction::New,
        rumblr::PostType::Photo {
            caption: None,
            link: None,
            source: Some("https://uvwvu.xyz/favicon.png"),
            data: None,
            data64: None,
        },
        None
    )
);

} ```

Crawl shield photos:

```rust extern crate rumblr; extern crate serde_json;

// --- external --- use rumblr::{TumblrClient, GetBlogPostsOptionalParams}; use serde_json::Value;

fn main() { let client = TumblrClient::new() .proxy("http://127.0.0.1:1087") .unwrap() .load_keys("rumblr.keys") .unwrap();

let limit = 10;
for i in 0u32.. {
    let resp: Value = client.get_blog_posts(
        "h2artbeat.tumblr.com",
        Some(
            GetBlogPostsOptionalParams::new()
                .r#type("photo")
                .limit(&limit.to_string())
                .offset(&(i * limit).to_string())
        )
    );

    let path = "export";
    {
        // --- std ---
        use std::{
            fs::create_dir,
            path::Path,
        };

        let path = Path::new(path);
        if !path.is_dir() { create_dir(path).unwrap(); }
    }

    let posts = resp["response"]["posts"].as_array().unwrap();
    for post in posts {
        let mut infos = String::new();

        {
            let photos = post["photos"].as_array().unwrap();
            for photo in photos {
                infos.push_str(photo["original_size"]["url"].as_str().unwrap());
                infos.push('\n');
            }
        }

        {
            // --- std ---
            use std::{
                fs::File,
                io::Write,
            };

            let mut f = File::create(&format!("{}/{}.txt", path, post["id"].as_u64().unwrap())).unwrap();
            f.write_all(infos.as_bytes()).unwrap();
            f.sync_all().unwrap();
        }
    }

    if posts.len() != limit as usize { break; }
}

} ```

All client methods sync with Tumblr API.

TODO

Support Neue Post Format.