snapcat 0.2.2 → 0.6

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: 6437760738563d52cd3c43500739d0c604ce4923
4
- data.tar.gz: 07416fe7a096a5d2e601c3f2f5b912251e3281d3
3
+ metadata.gz: b9aa4ef2de497924cd6e94fbd28a223078a99b52
4
+ data.tar.gz: 87c1b26acffec51351cf0e330f74b679ec898a0e
5
5
  SHA512:
6
- metadata.gz: 7a6fb107dce99f3d2d983dff1612d959eed8bbeb47f7159aa509d2fe078ac456ebb2089e92edff1a4ccc9e5ee202c8f71b78b09b5d98fb0d9a5731f6976332b8
7
- data.tar.gz: 079e3dc44abc5a69ffd66ef84192a4ae64d42dd767d4b5ca7053e7dee002012aab6252abf34ef97742dc43954ce0ba65a32fe1e5ed69c90740babb6cb23f493d
6
+ metadata.gz: 84dc62f99d81c15991a4ccd851e5ab1c56f9fb150155ac50a57228227e1bab7abb5ee559e1c35cc46be20176154a9739bde2a373c0e557912161d0d58cc2f478
7
+ data.tar.gz: 3883f1cb5b20e89138c41ded834ecd029e8850ef60a5d570a594f94adbe3b68a3bc651a6c741d94e8b093bc293ffaaa1552d44d83caa703f4955a8e5681f497e
data/README.md CHANGED
@@ -13,7 +13,7 @@ Installation
13
13
 
14
14
  Add this line to your application's `Gemfile`:
15
15
 
16
- gem 'snapcat', '~> 0.2'
16
+ gem 'snapcat', '~> 0.5'
17
17
 
18
18
  And then execute:
19
19
 
@@ -134,6 +134,21 @@ snapcat.send_media(data, 'catsaregreat')
134
134
  snapcat.send_media(data, %w(catsaregreat ronnie99), view_duration: 4)
135
135
  ```
136
136
 
137
+ **Posting a Story**
138
+
139
+ ```ruby
140
+ # Post a Story out to your network
141
+ # `data` is a string which can be read directly from an mp4 or jpg
142
+ snapcat.send_story(data, caption_text: "oh hai haz cheezburger", time: 10)
143
+ ```
144
+
145
+ **Getting Stories**
146
+
147
+ ```ruby
148
+ # Get all stories from your network, including view count, viewers (essentially anything in the friends list)
149
+ snapcat.get_stories
150
+ ```
151
+
137
152
  **Received Snaps**
138
153
 
139
154
  ```ruby
@@ -189,10 +204,10 @@ processes and set it manually.
189
204
 
190
205
  ```ruby
191
206
  # Fetch token
192
- snapcat.client.auth_token
207
+ snapcat.auth_token
193
208
 
194
209
  # Set token
195
- snapcat.client.auth_token = '1c7e8f83-1379-4694-8fa9-4cab6b73f0d4'
210
+ snapcat.auth_token = '1c7e8f83-1379-4694-8fa9-4cab6b73f0d4'
196
211
  ```
197
212
 
198
213
 
@@ -210,10 +225,10 @@ Contributing
210
225
  Credits
211
226
  -------
212
227
 
213
- * [Neal Kemp](http://nealke.mp)
228
+ * [Neal Kemp](http://nealke.mp), [Daniel Archer](http://dja.io)
214
229
  * Based on work by martinp on [pysnap](https://github.com/martinp/pysnap) and by
215
230
  djstelles on [php-snapchat](https://github.com/dstelljes/php-snapchat)
216
231
 
217
- Copyright © 2013 Neal Kemp
232
+ Copyright © 2013 Neal Kemp, Daniel Archer
218
233
 
219
234
  Released under the MIT License, which can be found in the repository in `LICENSE.txt`.
@@ -34,6 +34,10 @@ module Snapcat
34
34
  ))
35
35
  end
36
36
 
37
+ def get_stories
38
+ @requestor.request_with_username('stories')
39
+ end
40
+
37
41
  def media_for(snap_id)
38
42
  @requestor.request_media(snap_id)
39
43
  end
@@ -132,6 +136,10 @@ module Snapcat
132
136
  )
133
137
  end
134
138
 
139
+ def send_story(data, options = {})
140
+ @requestor.request_upload_story(data, options[:time], options[:caption_text], options[:type])
141
+ end
142
+
135
143
  def unblock(username)
136
144
  @requestor.request_with_username(
137
145
  'friend',
@@ -18,7 +18,8 @@ module Snapcat
18
18
  def request(endpoint, data = {})
19
19
  response = self.class.post(
20
20
  "/#{endpoint}",
21
- body: merge_defaults_with(data)
21
+ body: merge_defaults_with(data),
22
+ headers: request_headers
22
23
  )
23
24
 
24
25
  additional_fields = additional_fields_for(data)
@@ -31,7 +32,8 @@ module Snapcat
31
32
  def request_media(snap_id)
32
33
  response = self.class.post(
33
34
  '/blob',
34
- { body: merge_defaults_with({ id: snap_id, username: @username }) }
35
+ body: merge_defaults_with({ id: snap_id, username: @username }),
36
+ headers: request_headers
35
37
  )
36
38
 
37
39
  Response.new(response)
@@ -63,6 +65,31 @@ module Snapcat
63
65
  end
64
66
  end
65
67
 
68
+ def request_upload_story(data, time = nil, caption_text = nil, type = nil)
69
+ encrypted_data = Crypt.encrypt(data)
70
+ media = Media.new(encrypted_data, type)
71
+ file_extension = media.file_extension
72
+
73
+ begin
74
+ file = Tempfile.new(['story', ".#{file_extension}"])
75
+ file.write(encrypted_data.force_encoding('utf-8'))
76
+ file.rewind
77
+
78
+ return request_with_username(
79
+ 'retry_post_story',
80
+ data: file,
81
+ media_id: media.generate_id(@username),
82
+ client_id: media.generate_id(@username),
83
+ time: time || 3,
84
+ caption_text_display: caption_text,
85
+ type: media.type_code
86
+ )
87
+ ensure
88
+ file.close
89
+ file.unlink
90
+ end
91
+ end
92
+
66
93
  private
67
94
 
68
95
  def additional_fields_for(data)
@@ -102,5 +129,11 @@ module Snapcat
102
129
  timestamp: now
103
130
  })
104
131
  end
132
+
133
+ def request_headers
134
+ {'User-Agent' => 'Snapchat/8.1.1 (iPhone; iOS 8.1.1; gzip)',
135
+ 'Accept-Language' => 'en',
136
+ 'Accept-Locale' => 'en'}
137
+ end
105
138
  end
106
139
  end
@@ -4,12 +4,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'snapcat'
7
- spec.version = '0.2.2'
8
- spec.authors = ['Neal Kemp']
7
+ spec.version = '0.6'
8
+ spec.authors = ['Neal Kemp', 'Daniel Archer']
9
9
  spec.email = ['']
10
10
  spec.description = %q{Snapchat API wrapper}
11
11
  spec.summary = %q{Ruby wrapper for Snapchat's private API}
12
- spec.homepage = 'https://github.com/NealKemp/snapcat'
12
+ spec.homepage = 'https://github.com/nneal/snapcat'
13
13
  spec.license = 'MIT'
14
14
  spec.required_ruby_version = '>= 1.9.3'
15
15
 
@@ -29,4 +29,4 @@ describe Snapcat::Timestamp do
29
29
  timestamp.must_equal 1384635477196
30
30
  end
31
31
  end
32
- end
32
+ end
@@ -67,4 +67,4 @@ module Fixture
67
67
  }
68
68
  end
69
69
  end
70
- end
70
+ end
@@ -336,4 +336,4 @@ module RequestStub
336
336
  stub_auth
337
337
  login
338
338
  end
339
- end
339
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: '0.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neal Kemp
8
+ - Daniel Archer
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-04-27 00:00:00.000000000 Z
12
+ date: 2015-01-26 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: httmultiparty
@@ -170,7 +171,7 @@ files:
170
171
  - spec/support/snaps/video_decrypted.mp4
171
172
  - spec/support/snaps/video_encrypted.mp4
172
173
  - spec/support/user_experience.rb
173
- homepage: https://github.com/NealKemp/snapcat
174
+ homepage: https://github.com/nneal/snapcat
174
175
  licenses:
175
176
  - MIT
176
177
  metadata: {}
@@ -190,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
191
  version: '0'
191
192
  requirements: []
192
193
  rubyforge_project:
193
- rubygems_version: 2.2.2
194
+ rubygems_version: 2.4.5
194
195
  signing_key:
195
196
  specification_version: 4
196
197
  summary: Ruby wrapper for Snapchat's private API