reddit_bot 1.6.4 → 1.6.5

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: 05b83643d990066b8e6a3922b71f065aabf02fa3
4
- data.tar.gz: 23f386f95b1d0490e37c316b2823570f18114368
3
+ metadata.gz: afe3593cb266098860316251a4126efdccced3c0
4
+ data.tar.gz: bcf920ee2ccf254f5f84aeef64c5a5471400165d
5
5
  SHA512:
6
- metadata.gz: 3ce7a59815a001eb2808edfbc3ca1672eaf17cd271d15c7621bca3621ca320baa0174567b0ac539f761f5bd9271a18e34f7e10a41598475028aa3bafc1486918
7
- data.tar.gz: f0c4ee4fe8136d20461cb80fcbe95f08098ba72e545a02a430f675e7a17b08d8225a31dcf369ad93d1f9e90e0c179a978bd7f102dff910197c61c7b9fd188be8
6
+ metadata.gz: 00c876b7cde3299b2ec06ac5c8f7a34e2299a651ac91c7815d168e547c220c3c4a6317a4eab544c2e81656263ce9d2cf7687dcec062f90952a20d8092e2a6185
7
+ data.tar.gz: c74d1fac23dafb7ed17165875b164ceec1f2cde7f21f1defc590661f2f6de86c1ec4b446e69320d2dce72491b42a4081cda2b0e5d8d5e979537697de7d8cf6f0
@@ -2,14 +2,11 @@
2
2
 
3
3
  gem "json"
4
4
 
5
- gem "nethttputils", git: "git@github.com:Nakilon/nethttputils.git", tag: "v0.1.2.1"
6
-
7
- gem "reddit_bot", "~>1.6.3"
5
+ gem "reddit_bot", git: "git@github.com:nakilon/reddit_bot.git"
8
6
  gem "nokogiri"
9
7
 
10
- gem "imgur2array", git: "git@github.com:Nakilon/imgur2array.git"
11
- gem "fastimage", git: "git@github.com:Nakilon/fastimage.git"
12
- gem "url2dimensions", git: "git@github.com:Nakilon/url2dimensions.git", tag: "v0.0.0.8"
8
+ gem "fastimage", git: "git@github.com:sdsykes/fastimage.git", ref: "15bc4111c4c4e1af580b63c62e08decf2d5527d5"
9
+ gem "directlink", git: "git@github.com:Nakilon/directlink.git"
13
10
 
14
11
  gem "gcplogger", git: "git@github.com:Nakilon/gcplogger.git", tag: "v0.1.1.0"
15
12
  gem "google-cloud-error_reporting"
@@ -1,8 +1,10 @@
1
1
  GIT
2
- remote: git@github.com:Nakilon/fastimage.git
3
- revision: 1be9e5cd7a4ac9baa3c83efdd0bf111a52e69f48
2
+ remote: git@github.com:Nakilon/directlink.git
3
+ revision: 18b1544dcbdee3d9f5c2ad685e4eaf134773e5a1
4
4
  specs:
5
- fastimage (2.1.1)
5
+ directlink (0.0.2.0)
6
+ fastimage (~> 2.1.3)
7
+ nethttputils (~> 0.2.4.0)
6
8
 
7
9
  GIT
8
10
  remote: git@github.com:Nakilon/gcplogger.git
@@ -14,24 +16,18 @@ GIT
14
16
  public_suffix (~> 2.0)
15
17
 
16
18
  GIT
17
- remote: git@github.com:Nakilon/imgur2array.git
18
- revision: 9d5e5c3d442e85ff13938b0e614e67ba03581c76
19
+ remote: git@github.com:nakilon/reddit_bot.git
20
+ revision: d2ab4765573ea153e34c99b6f6a4f7bca21df6a7
19
21
  specs:
20
- imgur2array (0.0.3.2)
21
-
22
- GIT
23
- remote: git@github.com:Nakilon/nethttputils.git
24
- revision: 27777142af099556394691c772a33cf5f6548c4f
25
- tag: v0.1.2.1
26
- specs:
27
- nethttputils (0.1.2.1)
22
+ reddit_bot (1.6.5)
23
+ json
28
24
 
29
25
  GIT
30
- remote: git@github.com:Nakilon/url2dimensions.git
31
- revision: c738e255ba3bbd38d142aebabbc0ea13abac4750
32
- tag: v0.0.0.8
26
+ remote: git@github.com:sdsykes/fastimage.git
27
+ revision: 15bc4111c4c4e1af580b63c62e08decf2d5527d5
28
+ ref: 15bc4111c4c4e1af580b63c62e08decf2d5527d5
33
29
  specs:
34
- url2dimensions (0.0.0.8)
30
+ fastimage (2.1.3)
35
31
 
36
32
  GEM
37
33
  remote: https://rubygems.org/
@@ -87,12 +83,11 @@ GEM
87
83
  mini_portile2 (2.1.0)
88
84
  multi_json (1.13.1)
89
85
  multipart-post (2.0.0)
86
+ nethttputils (0.2.4.0)
90
87
  nokogiri (1.6.8.1)
91
88
  mini_portile2 (~> 2.1.0)
92
89
  os (0.9.6)
93
90
  public_suffix (2.0.5)
94
- reddit_bot (1.6.3)
95
- json
96
91
  rly (0.2.3)
97
92
  signet (0.8.1)
98
93
  addressable (~> 2.3)
@@ -106,15 +101,13 @@ PLATFORMS
106
101
  ruby
107
102
 
108
103
  DEPENDENCIES
104
+ directlink!
109
105
  fastimage!
110
106
  gcplogger!
111
107
  google-cloud-error_reporting
112
- imgur2array!
113
108
  json
114
- nethttputils!
115
109
  nokogiri
116
- reddit_bot (~> 1.6.3)
117
- url2dimensions!
110
+ reddit_bot!
118
111
 
119
112
  BUNDLED WITH
120
113
  1.16.1
@@ -4,15 +4,14 @@
4
4
  require "gcplogger"
5
5
  logger = GCPLogger.logger "largeimagesbot"
6
6
 
7
- fail("no ENV['ERROR_REPORTING_KEYFILE'] specified") unless ENV["ERROR_REPORTING_KEYFILE"]
7
+ fail "no ENV['ERROR_REPORTING_KEYFILE'] specified" unless ENV["ERROR_REPORTING_KEYFILE"]
8
8
  require "google/cloud/error_reporting"
9
9
  Google::Cloud::ErrorReporting.configure do |config|
10
- config.project_id = (JSON.load File.read ENV["ERROR_REPORTING_KEYFILE"])["project_id"]
10
+ config.project_id = JSON.load(File.read ENV["ERROR_REPORTING_KEYFILE"])["project_id"]
11
11
  end
12
12
 
13
13
 
14
- require "url2dimensions"
15
- Imgur.logger = logger
14
+ require "directlink"
16
15
 
17
16
  require "nokogiri"
18
17
 
@@ -84,34 +83,35 @@ loop do
84
83
  checked << id
85
84
  # next if Gem::Platform.local.os == "darwin" # prevent concurrent posting
86
85
  logger.debug "image url for #{id}: #{url}"
87
- next logger.warn "skipped a post by /u/sjhill" if author == "sjhill" # opt-out
88
- next logger.warn "skipped a post by /u/bekalaki" if author == "bekalaki" # 9 ways to divide karmawhore
89
-
90
- next logger.warn "skipped (URL2Dimensions :skipped) #{url} from http://redd.it/#{id}" if :skipped == _ = begin
91
- URL2Dimensions::get_dimensions CGI.unescape_html url
92
- rescue URL2Dimensions::Error404
93
- next logger.warn "skipped (URL2Dimensions::Error404) #{url} from http://redd.it/#{id}"
94
- rescue URL2Dimensions::ErrorUnknown
95
- next logger.warn "skipped (URL2Dimensions::ErrorUnknown) #{url} from http://redd.it/#{id}"
86
+ next logger.warn "skipped a post by /u/sjhill" if author == "sjhill" # opt-out
87
+ next logger.warn "skipped a post by /u/redisforever" if author == "redisforever" # opt-out
88
+ next logger.warn "skipped a post by /u/bekalaki" if author == "bekalaki" # 9 ways to divide a karmawhore
89
+
90
+ t = begin
91
+ DirectLink url
92
+ rescue NetHTTPUtils::Error,
93
+ SocketError,
94
+ FastImage::UnknownImageType,
95
+ FastImage::ImageFetchFailure,
96
+ # DirectLink::ErrorMissingEnvVar,
97
+ DirectLink::ErrorNotFound,
98
+ DirectLink::ErrorBadLink => e
99
+ next logger.error "skipped (#{e}) #{url} from http://redd.it/#{id}"
96
100
  end
97
- fail "unable #{url} from http://redd.it/#{id}" unless _
98
- width, height, best_direct_url, *all_direct_urls = _
99
- logger.info "URL2Dimensions: %p" % [[width, height, best_direct_url, all_direct_urls.size]]
100
- unless min_resolution <= width * height
101
+ logger.info "DirectLink: %p" % t
102
+ tt = t.is_a?(Array) ? t : [t]
103
+ unless min_resolution <= tt.first.width * tt.first.height
101
104
  next logger.debug "skipped low resolution #{source}"
102
105
  end
103
- # next if Gem::Platform.local.os == "darwin" # prevent concurrent posting
104
106
  # puts "https://www.reddit.com/r/LargeImages/search.json?q=url%3A#{CGI.escape url}&restrict_sr=on"
105
- resolution = "[#{width}x#{height}]"
106
- # require "cgi"
107
+ resolution = "[#{tt.first.width}x#{tt.first.height}]"
107
108
  next logger.warn "already submitted #{resolution} #{id}: '#{url}'" unless
108
109
  Gem::Platform.local.os == "darwin" || search_url[url].empty?
109
110
  logger.warn "resolution #{resolution} got from #{id}: #{url}"
110
- # next if Gem::Platform.local.os == "darwin" # prevent concurrent posting
111
111
  title = "#{resolution}#{
112
- " [#{all_direct_urls.size} images]" if all_direct_urls.size > 1
112
+ " [#{tt.size} images]" if tt.size > 1
113
113
  } #{
114
- title.sub(/\s*\[?#{width}\s*[*x×]\s*#{height}\]?\s*/i, " ").
114
+ title.sub(/\s*\[?#{tt.first.width}\s*[*x×]\s*#{tt.first.height}\]?\s*/i, " ").
115
115
  sub("[OC]", " ").gsub(/\s+/, " ").strip.
116
116
  gsub(/(?<=.{190 - subreddit.size}).+/, "...")
117
117
  } /r/#{subreddit}".
@@ -137,11 +137,11 @@ loop do
137
137
  # "id"=>"3a9rel",
138
138
  # "name"=>"t3_3a9rel"}}}
139
139
  line1 = "[Original thread](#{permalink}) by /u/#{author}"
140
- line2 = "Direct link#{" (the largest image)" if all_direct_urls.size > 1}: #{best_direct_url}"
140
+ line2 = "Direct link#{" (the largest image)" if tt.size > 1}: #{tt.first.url}"
141
141
  line3 = [
142
142
  "Direct links to all other images in album:",
143
- all_direct_urls - [best_direct_url]
144
- ] if all_direct_urls.size > 1
143
+ tt.map(&:url) - [tt.first.url]
144
+ ] if tt.size > 1
145
145
  text = [line1, line2, line3].compact.join(" \n")
146
146
  logger.info "new comment: #{text.inspect}"
147
147
  unless Gem::Platform.local.os == "darwin"
@@ -152,7 +152,7 @@ loop do
152
152
  end
153
153
  end
154
154
 
155
- abort if ENV["TEST"]
155
+ abort if Gem::Platform.local.os == "darwin"
156
156
  end
157
157
  end
158
158
 
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "reddit_bot", "~>1.5.3"
3
+ gem "reddit_bot", "~>1.6.4"
4
4
  gem "nethttputils", git: "git@github.com:Nakilon/nethttputils.git", tag: "v0.1.0.4"
@@ -9,7 +9,7 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  json (2.1.0)
12
- reddit_bot (1.5.3)
12
+ reddit_bot (1.6.4)
13
13
  json
14
14
 
15
15
  PLATFORMS
@@ -17,7 +17,7 @@ PLATFORMS
17
17
 
18
18
  DEPENDENCIES
19
19
  nethttputils!
20
- reddit_bot (~> 1.5.3)
20
+ reddit_bot (~> 1.6.4)
21
21
 
22
22
  BUNDLED WITH
23
23
  1.16.1
data/lib/reddit_bot.rb CHANGED
@@ -225,7 +225,7 @@ module RedditBot
225
225
  end
226
226
  rescue NetHTTPUtils::Error => e
227
227
  sleep 5
228
- raise unless e.code == 503
228
+ raise unless e.code == 503 || e.code == 502
229
229
  puts "API ERROR 503"
230
230
  retry
231
231
  end
@@ -1,3 +1,3 @@
1
1
  module RedditBot
2
- VERSION = "1.6.4" # :nodoc:
2
+ VERSION = "1.6.5" # :nodoc:
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reddit_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.4
4
+ version: 1.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Maslov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-26 00:00:00.000000000 Z
11
+ date: 2018-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json