feed2gram 1.2.0 → 1.2.2

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
  SHA256:
3
- metadata.gz: 7f7ca98db2cd00345d0f9752ee3cbecb4a08802788a12b0c4ff96ea88e7564d6
4
- data.tar.gz: 9431ebbf3b607ed4c2741dd2566ba1769b9decf999cf4797dffbd067afe9ffa0
3
+ metadata.gz: 8f1c5ede06c494a4b45e77b7ba717c408f72ce9c2ae272c97550b6f0e687fae2
4
+ data.tar.gz: df2a2f0ff2ac9ec4663c5fb4c7f48fb2e1cd9aa3f31c4b9ff7cfc0dde5308946
5
5
  SHA512:
6
- metadata.gz: e4d526ea17064ed90989d26df897d9d0f149c53b59afb0fbdc42099a9ffaccc96c9d70a74999c7b973a037dc484e130904f975f8b6ebfe3a8992c64847dc5b64
7
- data.tar.gz: '090b8873287f0c87df039c457b2f1129620908b0ffa71c1098c4259f0856e03399fa9bd2690ffb15885b895a0d2fb1659ac59d9d7643865975b2b836e2a351db'
6
+ metadata.gz: 8c0e76000c8a937c57d082e0a20c2e8d05bdb193476584a873bd034eed858fdca7702dbd37a3889d3338e4e79ad05c605a2f61ee4d80e8245a479fdf1e90d878
7
+ data.tar.gz: e377a974a2aa8c51e8cf8e2eff23feb30b88b5da9c3a63979de1c05ce5a3e7ede6f0e764f65ff7b9f01266c4bb581dfe63a548ad67e4b25c6aac8968a9288a2e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.2.2]
2
+
3
+ * Fix integer/string conversion error when env vars from 1.2.1 are set
4
+
5
+ ## [1.2.1]
6
+
7
+ * Add `SECONDS_PER_UPLOAD_CHECK` and `MAX_UPLOAD_STATUS_CHECKS` env vars
8
+
1
9
  ## [1.2.0]
2
10
 
3
11
  * Add support for the `cover_url` property for reel posts by way of a
data/README.md CHANGED
@@ -96,6 +96,14 @@ Usage: feed2gram [options]
96
96
  --populate-cache Populate the cache file with any posts found in the feed WITHOUT posting them to Instagram
97
97
  ```
98
98
 
99
+ ## Environment variables
100
+
101
+ These environment variables can be set to augment the gem's behavior:
102
+
103
+ * `SECONDS_PER_UPLOAD_CHECK` - when uploading video, feed2gram must wait until
104
+ the [status code](https://tiagogrosso.github.io/instagram-graph-api-lib/enums/CONTAINER_STATUS_CODE.html) on the media indicates it is published. This variable determines how many seconds to wait between each check (defaults to 30 seconds). Shortening this value can lead to hitting one's hourly rate limit
105
+ * `MAX_UPLOAD_STATUS_CHECKS` - how many status checks to perform before giving up on a piece of media and calling the post failed. Unfortunately, Facebook's servers can take anywhere from 15 seconds to 15 hours to download and process even trivially small videos, so GLHF
106
+
99
107
  ## Formatting your Atom feed's HTML
100
108
 
101
109
  feed2gram uses the first `<figure>` element to generate each Instagram post. That `<figure>` can contain one or more `<img>` tags and one `<figcaption>` tag, which will be used as the post's image(s) and caption, respectively.
data/example/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- feed2gram (1.2.0)
4
+ feed2gram (1.2.2)
5
5
  nokogiri (~> 1.15)
6
6
 
7
7
  GEM
@@ -18,6 +18,7 @@ module Feed2Gram
18
18
  end
19
19
  rescue => e
20
20
  warn "Failed to post #{post.url}: #{e.message}"
21
+ e.backtrace.join("\n").each_line { |line| warn line }
21
22
  Result.new(post: post, status: :failed)
22
23
  end
23
24
  }
@@ -81,14 +82,14 @@ module Feed2Gram
81
82
  Result.new(post: post, status: :posted)
82
83
  end
83
84
 
84
- SECONDS_PER_WAIT = 30
85
- MAX_WAIT_ATTEMPTS = 100
85
+ SECONDS_PER_UPLOAD_CHECK = ENV.fetch("SECONDS_PER_UPLOAD_CHECK") { 30 }.to_i
86
+ MAX_UPLOAD_STATUS_CHECKS = ENV.fetch("MAX_UPLOAD_STATUS_CHECKS") { 100 }.to_i
86
87
  # Good ol' loop-and-sleep. Haven't loop do'd in a while
87
88
  def wait_for_media_to_upload!(url, container_id, config, options)
88
89
  wait_attempts = 0
89
90
  loop do
90
- if wait_attempts > MAX_WAIT_ATTEMPTS
91
- warn "Giving up waiting for media to upload after waiting #{SECONDS_PER_WAIT * MAX_WAIT_ATTEMPTS} seconds: #{url}"
91
+ if wait_attempts > MAX_UPLOAD_STATUS_CHECKS
92
+ warn "Giving up waiting for media to upload after waiting #{SECONDS_PER_UPLOAD_CHECK * MAX_UPLOAD_STATUS_CHECKS} seconds: #{url}"
92
93
  break
93
94
  end
94
95
 
@@ -96,12 +97,12 @@ module Feed2Gram
96
97
  fields: "status_code",
97
98
  access_token: config.access_token
98
99
  })
99
- puts "Upload status #{res[:status_code]} after waiting #{wait_attempts * SECONDS_PER_WAIT} seconds for IG to download #{url}" if options.verbose
100
+ puts "Upload status #{res[:status_code]} after waiting #{wait_attempts * SECONDS_PER_UPLOAD_CHECK} seconds for IG to download #{url}" if options.verbose
100
101
  if res[:status_code] == "FINISHED"
101
102
  break
102
103
  elsif res[:status_code] == "IN_PROGRESS"
103
104
  wait_attempts += 1
104
- sleep SECONDS_PER_WAIT
105
+ sleep SECONDS_PER_UPLOAD_CHECK
105
106
  else
106
107
  warn "Unexpected status code (#{res[:status_code]}) uploading: #{url}"
107
108
  break
@@ -1,3 +1,3 @@
1
1
  module Feed2Gram
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feed2gram
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-09 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.5.3
80
+ rubygems_version: 3.5.4
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Reads an Atom feed and posts its entries to Instagram