facebook-cli 1.4.0 → 1.4.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fbcli.rb +35 -6
  3. data/lib/fbcli/facebook.rb +5 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e825bc8b6a218bd1cb559e8e4061b733d0ce3eb
4
- data.tar.gz: 45cc917afd6dc9dcc6ec529a267c665760374bcd
3
+ metadata.gz: cf36ad0d9d51e1b88c67ae240be6a9a17ccdb01b
4
+ data.tar.gz: b40912f10326054e9ae2e9bb60ed960e22ab97ec
5
5
  SHA512:
6
- metadata.gz: 1971e9c34e24970570284fbcb6303388e53699f54ca7f8292fdaf650ae13399138e901db8b0e249524d957faaf41a53b45ab788c14739a4a0fe4bfdad435e204
7
- data.tar.gz: b372d6298015575340ac147c374a02fc912c1383c2be24c220f6a437c488e9b58d100155c57fc69f469089ee268a2680e4f7c86a743c5cf93c1b14ec7048d2d2
6
+ metadata.gz: 1644e40fc0d100d06d4edd4f40524ef5231469c08df1380033d4ba02a78661dde88c82660c99c10a8f1b00519a5633bb96232524c6b1fd8517136413a50e911c
7
+ data.tar.gz: 942e7dc96aa50c2fd0a9a5cb580f0bd6b4ef350a33ba7192a04db033dc407f421ce0c8baca4f23ad94f95f6229116184d704b3fa1910dbdf048564b98eee16df
data/lib/fbcli.rb CHANGED
@@ -10,7 +10,7 @@ include GLI::App
10
10
 
11
11
  program_desc "Facebook command line interface"
12
12
 
13
- version '1.4.0'
13
+ version '1.4.3'
14
14
 
15
15
  flag [:token], :desc => 'Provide Facebook access token', :required => false
16
16
  flag [:pages, :p], :desc => 'Max pages', :required => false, :type => Integer, :default_value => -1
@@ -24,9 +24,10 @@ def link_to_post(full_post_id)
24
24
  link "#{profile_id}/posts/#{post_id}"
25
25
  end
26
26
 
27
- # Facebook returns dates in ISO 8601 format
27
+ # Facebook returns dates in ISO 8601 format, UTC time zone
28
28
  def date_str(fb_date)
29
- Time.parse(fb_date).localtime.rfc2822
29
+ # Convert to human friendly representation in user's time zone (almost RFC 2822)
30
+ Time.parse(fb_date).localtime.strftime('%a, %-d %b %Y %H:%M:%S %Z')
30
31
  end
31
32
 
32
33
  def save_config
@@ -38,6 +39,9 @@ end
38
39
  pre do |global_options, command|
39
40
  $global_options = global_options # They're supposed to be global, right?
40
41
 
42
+ # Do not print stack trace when terminating due to a broken pipe
43
+ Signal.trap "SIGPIPE", "SYSTEM_DEFAULT"
44
+
41
45
  if command.name == :config
42
46
  $config = {}
43
47
  else
@@ -136,19 +140,44 @@ end
136
140
 
137
141
  desc "Post a message or image to your timeline"
138
142
  arg_name "message"
143
+ long_desc %(
144
+ Facebook advises: photos should be less than 4 MB and saved as JPG, PNG, GIF or TIFF files.
145
+ )
139
146
  command :post do |c|
140
147
  c.flag [:i, :image], :desc => 'File or URL of image to post'
141
148
  c.action do |global_options, options, args|
142
- if options['image'].nil?
143
- full_post_id = FBCLI::publish_post args[0]
144
- else
149
+ if not options['image'].nil?
145
150
  full_post_id = FBCLI::publish_image args[0], options['image']
151
+ else
152
+ full_post_id = FBCLI::publish_post args[0]
146
153
  end
147
154
 
148
155
  puts "Your post: #{link_to_post full_post_id}"
149
156
  end
150
157
  end
151
158
 
159
+ desc "Post a video to your timeline"
160
+ arg_name "message"
161
+ long_desc %(
162
+ Facebook advises: aspect ratio must be between 9x16 and 16x9. The following formats are
163
+ supported:
164
+
165
+ 3g2, 3gp, 3gpp, asf, avi, dat, divx, dv, f4v, flv, m2ts, m4v,
166
+ mkv, mod, mov, mp4, mpe, mpeg, mpeg4, mpg, mts, nsv, ogm, ogv, qt, tod,
167
+ ts, vob, and wmv
168
+ )
169
+ command :postvideo do |c|
170
+ c.flag [:v, :video], :desc => 'File or URL of video'
171
+ c.flag [:t, :title], :desc => 'Title'
172
+ c.action do |global_options, options, args|
173
+ video_id = FBCLI::publish_video args[0], options['video'], options['title']
174
+ puts "Your post: #{link video_id}"
175
+ puts "Edit your video: #{link "video/edit/?v=#{video_id}"}"
176
+ puts
177
+ puts "It might take a few minutes for your video to become available."
178
+ end
179
+ end
180
+
152
181
  desc "Post a link to your timeline"
153
182
  arg_name "url"
154
183
  command :postlink do |c|
@@ -83,4 +83,9 @@ module FBCLI
83
83
  result = api_call lambda { |api| api.put_picture(image_file_or_url, {:message => msg}) }
84
84
  result['post_id']
85
85
  end
86
+
87
+ def self.publish_video(msg, video_file_or_url, title = nil)
88
+ result = api_call lambda { |api| api.put_video(video_file_or_url, {:title => title, :description => msg}) }
89
+ result['id']
90
+ end
86
91
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ildar Sagdejev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-01 00:00:00.000000000 Z
11
+ date: 2016-10-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A limited command line interface to Facebook
14
14
  email: specious@gmail.com