reddit_bot 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04c5e7eb195ffcfac43153bd50de22411b5c94f0
4
- data.tar.gz: b5f7b13260c496d2e74efcd7b28da0a0a909bc67
3
+ metadata.gz: 488688c825b8ab8f8f3e7ec10f0608dd3a3ee960
4
+ data.tar.gz: b91ae3dc0b8f4663e0b90b610a81f78e81d27a50
5
5
  SHA512:
6
- metadata.gz: 0022f4739296e9d586b60a85b27e4982b35aad053d3e4284763265d689d594e1ca559d937722df46fb1df948827b5ea4bef8b55ba20bc8c20fa585c46311ab36
7
- data.tar.gz: d7e275236c06d33cf12058eea1f000feda184cf06e9d3c3a510ac6e161834ed39de99d5f665b5a2c76c5b0582f9212f122e06017eaf31cf9429d2264f1e342bc
6
+ metadata.gz: afb7b570aeddc5ce5115ea06d7d89c274eccedc3e2d1b0e8391855a6efcb53b5b21801defc133240f99df5ab619670ea3a9cc6bb37a329306ebe52442eda3c85
7
+ data.tar.gz: 9f406e4e8b3546925b164ac94bb1aaba1b0bac074d5243a66429925897901ae34b4181a5aa475f898424c32ed70fcfad3772a0a555b9a6f2b7cbe5f50c72bf98
@@ -2,9 +2,9 @@
2
2
 
3
3
  gem "json"
4
4
 
5
- gem "nethttputils", git: "git@github.com:Nakilon/nethttputils.git", tag: "v0.1.0.0"
5
+ gem "nethttputils", git: "git@github.com:Nakilon/nethttputils.git", tag: "v0.1.0.1"
6
6
 
7
- gem "reddit_bot", "~>1.4.0"
7
+ gem "reddit_bot", "~>1.5.2"
8
8
  gem "nokogiri"
9
9
 
10
10
  gem "imgur2array", git: "git@github.com:Nakilon/imgur2array.git", tag: "v0.0.2.8"
@@ -15,10 +15,10 @@ GIT
15
15
 
16
16
  GIT
17
17
  remote: git@github.com:Nakilon/nethttputils.git
18
- revision: 547dae5f3c6c893424b30498efa442e4d268b1b4
19
- tag: v0.1.0.0
18
+ revision: 9e357649157955d0fc476b88966aa9a4435ff57a
19
+ tag: v0.1.0.1
20
20
  specs:
21
- nethttputils (0.1.0.0)
21
+ nethttputils (0.1.0.1)
22
22
 
23
23
  GIT
24
24
  remote: git@github.com:Nakilon/url2dimensions.git
@@ -87,7 +87,7 @@ GEM
87
87
  mini_portile2 (~> 2.1.0)
88
88
  os (0.9.6)
89
89
  public_suffix (2.0.5)
90
- reddit_bot (1.4.0)
90
+ reddit_bot (1.5.2)
91
91
  json
92
92
  rly (0.2.3)
93
93
  signet (0.8.1)
@@ -108,7 +108,7 @@ DEPENDENCIES
108
108
  json
109
109
  nethttputils!
110
110
  nokogiri
111
- reddit_bot (~> 1.4.0)
111
+ reddit_bot (~> 1.5.2)
112
112
  url2dimensions!
113
113
 
114
114
  BUNDLED WITH
@@ -37,6 +37,11 @@ EXCLUDE = %w{ foodporn powerwashingporn }
37
37
 
38
38
  checked = []
39
39
 
40
+ search_url = lambda do |url|
41
+ JSON.load(NetHTTPUtils.request_data "https://www.reddit.com/r/largeimages/search.json", form: {q: "url:#{url}", restrict_sr: "on"}, header: ["User-Agent", "ajsdjasdasd"])["data"]["children"]
42
+ end
43
+ fail unless 1 == search_url["https://i.imgur.com/9JTxtjW.jpg"].size
44
+
40
45
  loop do
41
46
  begin
42
47
  logger.warn "LOOP #{Time.now}"
@@ -99,8 +104,7 @@ loop do
99
104
  resolution = "[#{width}x#{height}]"
100
105
  # require "cgi"
101
106
  next logger.warn "already submitted #{resolution} #{id}: '#{url}'" unless
102
- Gem::Platform.local.os == "darwin" ||
103
- (JSON.parse NetHTTPUtils.request_data "https://www.reddit.com/r/LargeImages/search.json?q=url%3A#{CGI.escape url}&restrict_sr=on", header: ["User-Agent", "ajsdjasdasd"])["data"]["children"].empty?
107
+ Gem::Platform.local.os == "darwin" || search_url[url].empty?
104
108
  logger.warn "resolution #{resolution} got from #{id}: #{url}"
105
109
  # next if Gem::Platform.local.os == "darwin" # prevent concurrent posting
106
110
  title = "#{resolution}#{
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "reddit_bot"
4
- gem "nethttputils", git: "git@github.com:Nakilon/nethttputils.git", tag: "v0.0.1.4"
3
+ gem "reddit_bot", "~>1.5.2"
4
+ gem "nethttputils", git: "git@github.com:Nakilon/nethttputils.git", tag: "v0.1.0.1"
@@ -1,15 +1,15 @@
1
1
  GIT
2
2
  remote: git@github.com:Nakilon/nethttputils.git
3
- revision: 10ae857b46a5db16e0193ca6e53cebbe2c499811
4
- tag: v0.0.1.4
3
+ revision: 9e357649157955d0fc476b88966aa9a4435ff57a
4
+ tag: v0.1.0.1
5
5
  specs:
6
- nethttputils (0.0.1.4)
6
+ nethttputils (0.1.0.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  json (2.1.0)
12
- reddit_bot (1.3.1)
12
+ reddit_bot (1.5.2)
13
13
  json
14
14
 
15
15
  PLATFORMS
@@ -17,7 +17,7 @@ PLATFORMS
17
17
 
18
18
  DEPENDENCIES
19
19
  nethttputils!
20
- reddit_bot
20
+ reddit_bot (~> 1.5.2)
21
21
 
22
22
  BUNDLED WITH
23
- 1.15.4
23
+ 1.16.0
@@ -37,15 +37,16 @@ tweet2titleNtext = lambda do |tweet|
37
37
  [CGI::unescapeHTML(tweet["full_text"]).sub(/( https:\/\/t\.co\/[0-9a-zA-Z]{10})*\z/, ""), text, contains_media]
38
38
  end
39
39
  [
40
- [905764294687633408, true, "The Polish government & military high command is now evacuating Warsaw for Brest, 120 miles east: German armies are too close to the capital", "* [Image 1](https://pbs.twimg.com/media/DJHq71BXYAA6KJ0.jpg)\n\n" "^- ^WW2 ^Tweets ^from ^1939 [^\\(@#{TWITTER}\\)](https://twitter.com/#{TWITTER}) ^| [^""September ^7, ^2017](https://twitter.com/#{TWITTER}/status/905764294687633408)"],
41
- [915534673471733760, true, "In east Poland (now Soviet Ukraine) industry & farms to be collectivised, political parties banned, aristocrats & capitalists \"re-educated\".", "* [Image 1](https://pbs.twimg.com/media/DLSh2J9W4AACcOG.jpg)\n\n* [Image 2](https://pbs.twimg.com/media/DLSh4sKX0AEBaXq.jpg)\n\n^- ^WW2 ^Tweets ^from ^1939 [^\\(@#{TWITTER}\\)](https://twitter.com/#{TWITTER}) ^| [^" "October ^4, ^2017](https://twitter.com/#{TWITTER}/status/915534673471733760)"],
42
- [915208866408824832, true, "For 1st time, RAF planes dropping propaganda leaflets on Berlin itself, entitled \"Germans: these are your leaders!\"", "* [Image 1](https://pbs.twimg.com/media/DLN5jJ-XkAEUz9M.jpg)\n\n* [Link 1](https://www.psywar.org/product_1939EH158.php)\n\n" "^- ^WW2 ^Tweets ^from ^1939 [^\\(@#{TWITTER}\\)](https://twitter.com/#{TWITTER}) ^| [^" "October ^3, ^2017](https://twitter.com/#{TWITTER}/status/915208866408824832)"],
43
- [914577848891006978, true, "\"In Poland, Russia pursued a cold policy of selfinterest. But clearly necessary for Russia… against Nazi menace.\"", "* [Link 1](https://www.youtube.com/watch?v=ygmP5A3n2JA)\n\n" "^- ^WW2 ^Tweets ^from ^1939 [^\\(@#{TWITTER}\\)](https://twitter.com/#{TWITTER}) ^| [^" "October ^1, ^2017](https://twitter.com/#{TWITTER}/status/914577848891006978)"],
44
- [926581977372942336, false, "Finland rejects Soviet demand to surrender land near Leningrad & give Red Navy base in Hanko; Soviets now claim Finns' manner \"warlike\".", "^- ^WW2 ^Tweets ^from ^1939 [^\\(@#{TWITTER}\\)](https://twitter.com/#{TWITTER}) ^| [^" "November ^3, ^2017](https://twitter.com/#{TWITTER}/status/926581977372942336)"],
40
+ [905764294687633408, true, "The Polish government & military high command is now evacuating Warsaw for Brest, 120 miles east: German armies are too close to the capital", "* [Image 1](https://pbs.twimg.com/media/DJHq71BXYAA6KJ0.jpg)\n\n" "^- ^WW2 ^Tweets ^from ^1940 [^\\(@#{TWITTER}\\)](https://twitter.com/#{TWITTER}) ^| [^""September ^7, ^2017](https://twitter.com/#{TWITTER}/status/905764294687633408)"],
41
+ [915534673471733760, true, "In east Poland (now Soviet Ukraine) industry & farms to be collectivised, political parties banned, aristocrats & capitalists \"re-educated\".", "* [Image 1](https://pbs.twimg.com/media/DLSh2J9W4AACcOG.jpg)\n\n* [Image 2](https://pbs.twimg.com/media/DLSh4sKX0AEBaXq.jpg)\n\n^- ^WW2 ^Tweets ^from ^1940 [^\\(@#{TWITTER}\\)](https://twitter.com/#{TWITTER}) ^| [^" "October ^4, ^2017](https://twitter.com/#{TWITTER}/status/915534673471733760)"],
42
+ [915208866408824832, true, "For 1st time, RAF planes dropping propaganda leaflets on Berlin itself, entitled \"Germans: these are your leaders!\"", "* [Image 1](https://pbs.twimg.com/media/DLN5jJ-XkAEUz9M.jpg)\n\n* [Link 1](https://www.psywar.org/product_1939EH158.php)\n\n" "^- ^WW2 ^Tweets ^from ^1940 [^\\(@#{TWITTER}\\)](https://twitter.com/#{TWITTER}) ^| [^" "October ^3, ^2017](https://twitter.com/#{TWITTER}/status/915208866408824832)"],
43
+ [914577848891006978, true, "\"In Poland, Russia pursued a cold policy of selfinterest. But clearly necessary for Russia… against Nazi menace.\"", "* [Link 1](https://www.youtube.com/watch?v=ygmP5A3n2JA)\n\n" "^- ^WW2 ^Tweets ^from ^1940 [^\\(@#{TWITTER}\\)](https://twitter.com/#{TWITTER}) ^| [^" "October ^1, ^2017](https://twitter.com/#{TWITTER}/status/914577848891006978)"],
44
+ [926581977372942336, false, "Finland rejects Soviet demand to surrender land near Leningrad & give Red Navy base in Hanko; Soviets now claim Finns' manner \"warlike\".", "^- ^WW2 ^Tweets ^from ^1940 [^\\(@#{TWITTER}\\)](https://twitter.com/#{TWITTER}) ^| [^" "November ^3, ^2017](https://twitter.com/#{TWITTER}/status/926581977372942336)"],
45
45
  ].each do |id, contains_media_, title_, text_|
46
46
  title, text, contains_media = tweet2titleNtext[ JSON.load NetHTTPUtils.request_data(
47
- "https://api.twitter.com/1.1/statuses/show.json?id=#{id}&tweet_mode=extended",
48
- header: { Authorization: "Bearer #{TWITTER_ACCESS_TOKEN}" }
47
+ "https://api.twitter.com/1.1/statuses/show.json",
48
+ form: { id: id, tweet_mode: "extended" },
49
+ header: { Authorization: "Bearer #{TWITTER_ACCESS_TOKEN}" },
49
50
  ) ]
50
51
  unless contains_media_ == contains_media
51
52
  puts "expected: #{contains_media_}"
@@ -88,7 +89,8 @@ loop do
88
89
  timeout = 0
89
90
  JSON.load( begin
90
91
  NetHTTPUtils.request_data(
91
- "https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=#{TWITTER}&count=200&tweet_mode=extended",
92
+ "https://api.twitter.com/1.1/statuses/user_timeline.json",
93
+ form: { screen_name: TWITTER, count: 200, tweet_mode: "extended" },
92
94
  header: { Authorization: "Bearer #{TWITTER_ACCESS_TOKEN}" }
93
95
  ) do |res|
94
96
  next unless res.key? "x-rate-limit-remaining"
@@ -112,7 +112,8 @@ module RedditBot
112
112
  Enumerator.new do |e|
113
113
  after = {}
114
114
  loop do
115
- args = [:get, "/#{subreddit || @subreddit || fail}/new", {limit: 100}.merge(after)]
115
+ # TODO maybe force lib user to prepend "r/" to @subreddit constructor?
116
+ args = [:get, "/#{subreddit || (@subreddit ? "r/#{@subreddit}" : fail)}/new", {limit: 100}.merge(after)]
116
117
  result = cache.call(args){ json *args }
117
118
  fail if result.keys != %w{ kind data }
118
119
  fail if result["kind"] != "Listing"
@@ -206,7 +207,7 @@ module RedditBot
206
207
  when "502", "503", "520", "500", "521", "504", "400", "522"
207
208
  puts "LOL #{response.code} at #{Time.now}?"
208
209
  p args
209
- sleep 5
210
+ sleep 60
210
211
  redo
211
212
  when "409"
212
213
  puts "Conflict (409)? at #{Time.now}?"
@@ -1,3 +1,3 @@
1
1
  module RedditBot
2
- VERSION = "1.5.2" # :nodoc:
2
+ VERSION = "1.5.3" # :nodoc:
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reddit_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Maslov