· 9 years ago · Nov 30, 2016, 06:24 AM
1require 'tumblr_client'
2
3# Get dat Tumblr client
4client = Tumblr::Client.new({
5 consumer_key: 'CONSUMER_KEY',
6 consumer_secret: 'CONSUMER_SECRET',
7 oauth_token: 'OAUTH_TOKEN',
8 oauth_token_secret: 'OAUTH_TOKEN_SECRET'
9})
10
11# Config your stuff here
12tag = 'TAG_TO_REBLOG'
13blog_url = 'YOUR_BLOG.tumblr.com' # or whatever CNAME you have set
14tags_to_post = [
15 'TAG_1',
16 'TAG_2',
17 'TAG_3'
18]
19
20# Form the comma separated string required to tag posts via the API
21tags_to_post_str = tags_to_post.join(',')
22
23# Get the initial tagged stuff
24tagged = client.tagged(tag)
25post = tagged.first
26
27# Drafts 100 posts w/ the tag
285.times do
29 tagged.each do |post|
30 id = post['id']
31 reblog_key = post['reblog_key']
32 client.reblog(blog_url,
33 id: id,
34 reblog_key: reblog_key,
35 state: 'draft',
36 tags: tags_to_post_str
37 )
38 end
39 last_timestamp = tagged.last['timestamp']
40 tagged = client.tagged(tag,
41 before: last_timestamp
42 )
43end