tumblr_draftking 0.8.2.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f398e7746629d4541b94b0f7d70a1593de4bc27a
4
- data.tar.gz: 1231bddcbb48a7c55a24851920ebe57764cb0f70
3
+ metadata.gz: 3c1b27da4e0f56a4f0ef9b3cd6cd64c27b0e4525
4
+ data.tar.gz: 035d3a92cc389359be66854971196ce2d7d0729a
5
5
  SHA512:
6
- metadata.gz: d1599d652d68bdf51b502621fcded6fa72b3b41592903df6be13b26e2df4d2b684fa3e5e7632176b6d46b4fe46924f271e528ff0bcae4761bebac1015fadfca3
7
- data.tar.gz: 44d60f6f5fc04fbff89d906193cb47b8478bb82f5a310e8db815878d7b1151dbb2b74dde3978066c1acbf6eb73577190f58fa15aada46ccd482e7f42b5e8052f
6
+ metadata.gz: c7e858d13b0fa24686467464678396cbacefcf6a502fa4fad696d2b4af73d52e176ae01bb1614c01db0d240f940efa1c05e5a70437542e59b1dc55c11b8495d5
7
+ data.tar.gz: 2697b4e18bf633f64e706a690c1747e8da52e973046fc208ab1a346b8e8a8ad15b02ad840cbde0d52f11004cdeaf8b73d86558ef0f0b2ab63591d1e9f5499f68
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # Changelog :: tumblr_draftking
2
+ ## Version 0.8.3
3
+ + New! (Auto-Poster) Publish up to 200 posts per 24 hours!
4
+
2
5
  ## Version 0.8.2.2
3
6
  + Added patch for tumblr_client 0.8.5 to enable passing of all accepted parameters to Client#likes, Client#blog_likes
4
7
 
data/README.md CHANGED
@@ -6,14 +6,15 @@ DraftKing is not associated with Tumblr
6
6
 
7
7
  DraftKing for Tumblr takes the hassle out of managing your draft queue!
8
8
  + **(New!) Save and name your own [DK commands](#custom-commands)!**
9
+ + **Save and name your own [DK commands](#custom-commands)!**
9
10
  + **Automate the addition of comments and tags.**
10
11
  + **Strip away old comments.**
11
12
  + **Easily replenish your queue.**
12
13
  + **Randomize post order to add variety.**
13
14
  + **Manage multiple accounts.**
14
15
 
15
- Version 0.8.2.2
16
- + Added patch for tumblr_client 0.8.5 to enable passing of all accepted parameters to Client#likes, Client#blog_likes
16
+ Version 0.8.3
17
+ + New! (Auto-Poster) Publish up to 200 posts per 24 hours!
17
18
 
18
19
  + Please report any [issues] you encounter!
19
20
  + [Change Log](./CHANGELOG.md)
@@ -35,6 +36,7 @@ Version 0.8.2.2
35
36
  + [Drafts or Queue](#drafts-or-queue)
36
37
  + [Stripping Comments](#stripping-comments)
37
38
  + [Comment & Move](#comment-&-move)
39
+ + [Auto-Poster](#auto-poster)
38
40
  + [Testing Console](#testing-console)
39
41
  + [API](#api)
40
42
  + [Built With](#built-with)
@@ -216,8 +218,21 @@ $ dk strip -b second-blog-name -s
216
218
  - Suppress progress message (-m)
217
219
 
218
220
  ```ruby
219
- $ dk md -c "draftking for tumblr" -k -a new,tags,to,add -m
221
+ $ dk md -c "draftking for tumblr" -k -t new,tags,to,add -m
220
222
  ```
223
+
224
+ ##### Auto-Poster
225
+ - Publish from the Drafts (-s)
226
+ - Add the comment "draftking auto poster" (-c)
227
+ - Target blog named 'test-blog' (-b)
228
+ - Keep existing tags (-k)
229
+ - Remove old comments (default behavior)
230
+ - Add tags #new, #tags, #to, #add (-t)
231
+
232
+ ```ruby
233
+ $ dk ap -b 'test-blog' -c 'draftking auto poster' -k -t 'new,tags,to,add' -s :drafts
234
+ ```
235
+
221
236
  #### Testing Console
222
237
  The dk console can act as a sandbox while you explore the api or you can use it to actively manage your account.
223
238
  By default it runs in simulation mode so any changes you make will not affect your account.
data/lib/draftking/cli.rb CHANGED
@@ -4,6 +4,7 @@ require_relative 'cli/cli_options'
4
4
 
5
5
  # More complex CLI Commands
6
6
  require_relative 'cli/commands/accounts'
7
+ require_relative 'cli/commands/autoposter'
7
8
  require_relative 'cli/commands/blogs'
8
9
  require_relative 'cli/commands/comment'
9
10
  require_relative 'cli/commands/console'
@@ -16,9 +16,9 @@ module DK
16
16
  DK::Config.setup unless DK::Config.configured?
17
17
  end
18
18
 
19
- def process_source(source)
20
- source = source.to_s
21
- return :queue if source.include?('q')
19
+ def process_source(src)
20
+ src = src.to_s
21
+ return :queue if src.include?('q')
22
22
  :draft
23
23
  end
24
24
 
@@ -0,0 +1,33 @@
1
+ module DK
2
+ class CLI < Thor
3
+ desc 'autoposter, ap', 'Publish up to 200 posts per 24 hours.'
4
+ long_desc <<-LONGDESC
5
+ `ap` will publish up to 200 posts per 24 hours from your Drafts or Queue.
6
+
7
+ Any posts already containing <COMMENT> will be ignored.
8
+ To clear comments you've added, call `comment ' '`.
9
+
10
+ Note:
11
+ - Old tags are removed by default. Pass -k option to preserve them.
12
+ - Previous comments are be removed by default. Pass -K option to preserve them.
13
+ - New tags will be generated by from the comment contents. Use -t <tags> for additional tagging.
14
+ LONGDESC
15
+ option :comment, type: :string, aliases: :c, desc: Options.op_strings[:comment]
16
+ option :blog, type: :string, aliases: :b, desc: Options.op_strings[:blog]
17
+ option :add_tags, type: :string, aliases: :t, desc: Options.op_strings[:add_tags]
18
+ option :source, type: :string, aliases: :S, desc: Options.op_strings[:source]
19
+ option :simulate, type: :boolean, aliases: :s, desc: Options.op_strings[:simulate]
20
+ option :keep_tags, type: :boolean, aliases: :k, desc: Options.op_strings[:keep_tags]
21
+ option :keep_comments, type: :boolean, aliases: :K, desc: Options.op_strings[:keep_comments]
22
+ option :credit, type: :boolean, desc: Options.op_strings[:credit], default: true
23
+ option :tags, type: :boolean, desc: Options.op_strings[:tags], default: true
24
+ option :config, type: :string, desc: Options.op_strings[:config]
25
+ def autoposter
26
+ configured?
27
+ opts = process_options(options)
28
+ dk = get_dk_instance(opts)
29
+ dk.auto_poster(opts)
30
+ end
31
+ map 'ap' => :autoposter
32
+ end
33
+ end
@@ -1,12 +1,7 @@
1
+ # Patch for bugs in the tumblr_client 0.8.5 gem
1
2
  module Tumblr
2
3
  # Tumblr::Blog patch
3
4
  module Blog
4
- # Patch for a bug in the tumblr_client 0.8.5 gem
5
- def draft(blog_name, options = {})
6
- validate_options([:limit, :before_id], options)
7
- get(blog_path(blog_name, 'posts/draft'), options)
8
- end
9
-
10
5
  def blog_likes(blog_name, options = {})
11
6
  validate_options([:limit, :before, :after, :offset], options)
12
7
  url = blog_path(blog_name, 'likes')
@@ -27,5 +22,15 @@ module Tumblr
27
22
  validate_options([:limit, :offset, :before, :after], options)
28
23
  get('v2/user/likes', options)
29
24
  end
25
+
26
+ def queue(blog_name, options = {})
27
+ validate_options([:limit, :offset], options)
28
+ get(blog_path(blog_name, 'posts/queue'), options)
29
+ end
30
+
31
+ def draft(blog_name, options = {})
32
+ validate_options([:limit, :before_id], options)
33
+ get(blog_path(blog_name, 'posts/draft'), options)
34
+ end
30
35
  end
31
36
  end
@@ -12,7 +12,7 @@ module DK
12
12
  # @param options[:blog_name] [String] Name of blog to target
13
13
  # @param options[:mute] [String] Suppress progress indicator
14
14
  # @param options[:test_data] [[Hash]] Array of post hash data
15
- # @param options[:simulate] [bool] Simulation?
15
+ # @param options[:simulate] [Bool] Simulation?
16
16
  # @return [int] Number of modified posts
17
17
  def post_operation(options, &block)
18
18
  work, total, results, reporter = setup_operation(options)
@@ -73,11 +73,11 @@ module DK
73
73
 
74
74
  # Add a comment to Posts
75
75
  # @param options[:credit] [Bool] Give dk credit?
76
- # @param options[:comment] [string] String to add as comment
76
+ # @param options[:comment] [String] String to add as comment
77
77
  # @param options[:limit] [Int] Max number of modified posts
78
78
  # @param options[:message] [String] Message to display during processing
79
79
  # @param options[:source] [Symbol] Target posts from :draft or :queue
80
- # @param options[:simulate] [bool] Simulation?
80
+ # @param options[:simulate] [Bool] Simulation?
81
81
  # @param options[:mute] [String] Suppress progress indicator
82
82
  # @return [int] Number of modified posts
83
83
  def comment_posts(options = {})
@@ -96,9 +96,9 @@ module DK
96
96
  # @param options[:source] [Symbol] Target posts from :draft or :queue
97
97
  # @param options[:mute] [String] Suppress progress indicator
98
98
  # @param options[:blog_name] [String] Name of blog to target
99
- # @param options[:keep_tags] [bool] Preserve existing post tags
100
- # @param options[:keep_tree] [bool] Preserve existing post comments
101
- # @param options[:simulate] [bool] Simulation?
99
+ # @param options[:keep_tags] [Bool] Preserve existing post tags
100
+ # @param options[:keep_tree] [Bool] Preserve existing post comments
101
+ # @param options[:simulate] [Bool] Simulation?
102
102
  # @param options[:comment] [String] Exclude :comment from tags
103
103
  # @return [int] Number of modified posts
104
104
  def tag_posts(options)
@@ -115,7 +115,7 @@ module DK
115
115
  # Determine draft data to use.
116
116
  # @param options[:test_data] [[Hash]] Array of post hash data
117
117
  # @param options[:limit] [Int] Limit # of posts selected
118
- # @param options[:blog_url] [string] URL of blog to read from
118
+ # @param options[:blog_url] [String] URL of blog to read from
119
119
  # @param options[:source] [Symbol] Get posts from :draft or :queue
120
120
  # @param options[:before_id] [Int] [:draft] ID of post to begin reading from
121
121
  # @param options[:offset] [Int] [:queue] Post index to start reading from
@@ -147,8 +147,7 @@ module DK
147
147
 
148
148
  # Dashboard integration
149
149
  def call_source(options)
150
- return @client.send('dashboard', options).first[1] if dashboard?
151
- return @client.send('likes', options).first[1] if likes?
150
+ return @client.send(@source, options).first[1] if dashboard? || likes?
152
151
  @client.send(@source, @blog_url, options).first[1]
153
152
  end
154
153
 
@@ -168,7 +167,7 @@ module DK
168
167
  # Collect all Posts
169
168
  # @param last_id [Int] ID of post to begin reading from (for reading Drafts)
170
169
  # @param offset [Int] Post index to start reading from (for reading Queue)
171
- # @param blog_url [string] URL of blog to read from
170
+ # @param blog_url [String] URL of blog to read from
172
171
  # @param source [Symbol] Get posts from :draft or :queue
173
172
  # @return [[Post]] Array of Post Hash data
174
173
  def all_posts(last_id: 0, offset: 0)
@@ -189,5 +188,43 @@ module DK
189
188
  def likes?
190
189
  @source == :likes
191
190
  end
191
+
192
+ # Publish posts at an interval, first in first out
193
+ # @param options[:comment] [String] String to add as comment
194
+ # @param options[:source] [Symbol] Target posts from :draft or :queue
195
+ # @param options[:simulate] [Bool] Simulation?
196
+ # @param options[:add_tags] [String] Tags to add
197
+ # @param options[:keep_tags] [Bool] Preserve old tags?
198
+ # @param options[:keep_tree] [Bool] Preserve old comments?
199
+ # @return [nil]
200
+ def auto_poster(options = {})
201
+ process_options(options)
202
+ act_on_blog(name: @blog_name)
203
+ print "Retrieving posts...(can take a while for large queues)\r"
204
+ posts = all_posts.reverse # FIFO
205
+ total = posts.size
206
+ puts "Found #{total} posts in #{@source.capitalize}#{'s' if @source[0] == 'd'}."
207
+ puts 'Press CTRL + C to exit.'
208
+ interval = 432 # 200 posts / 24 hours = 432sec
209
+ posts.each_with_index do |current, idx|
210
+ print "Publishing post #{idx}/#{total}.\r"
211
+ post = Post.new(current, keep_tree: @keep_tags)
212
+ post.change_state(DK::PUBLISH)
213
+ post.replace_comment_with(@comment)
214
+ post.generate_tags(keep_tags: @keep_tags,
215
+ add_tags: @tags,
216
+ exclude: @comment,
217
+ credit: true) if @auto_tag
218
+ unless post.save(client: @client, simulate: @simulate) > 0
219
+ puts "Error at Index: #{idx}. Unable to save post!"
220
+ puts "reblog_key: #{post.reblog_key}, id: #{post.post_id}"
221
+ puts 'Quitting auto-poster.'
222
+ exit 1
223
+ end
224
+ print "Published #{idx}/#{total} posts. Next post at #{Time.now + interval}\r"
225
+ sleep interval unless idx == total
226
+ end # End of auto-posting
227
+ puts 'Auto-Poster has completed!'
228
+ end
192
229
  end
193
230
  end
@@ -1,3 +1,3 @@
1
1
  module DK
2
- VERSION = '0.8.2.2'.freeze
2
+ VERSION = '0.8.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tumblr_draftking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meissa Dia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2017-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tumblr_client
@@ -116,6 +116,7 @@ files:
116
116
  - lib/draftking/cli/cli_options.rb
117
117
  - lib/draftking/cli/commands/_template.rb
118
118
  - lib/draftking/cli/commands/accounts.rb
119
+ - lib/draftking/cli/commands/autoposter.rb
119
120
  - lib/draftking/cli/commands/blogs.rb
120
121
  - lib/draftking/cli/commands/comment.rb
121
122
  - lib/draftking/cli/commands/console.rb