grabzit 3.5.2 → 3.5.4

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: 2920fbc96f29ee4d9b7f7a1c83e7fe1d2ead558fc74b4baa5cd335f73cc9efd7
4
- data.tar.gz: 8104b2962af11846171eced2a038a48d1f33f768d6684293f52a73103aaed85c
3
+ metadata.gz: 2a8a19888be59015aa66b1794e2bd0ccf7c395272c98e65b7156b4d921b7f8c6
4
+ data.tar.gz: 57d2ac4496d215398896a0e30162c71885e8b29e955a5fedfa9f279484367b24
5
5
  SHA512:
6
- metadata.gz: 3fd0f39c45172d5f685e1c76b9664d0f4b1e5de08c37a0d3c565a64eaf85712c4a254506b1468fb64cbb45b7135a507f89420f1746f89dcd5914810fb6427744
7
- data.tar.gz: 1afc1b4fcbd2e0008d58ce9b6572a48981ac6febd4c2434b4abca92561c4b4536dbf9c4408a75ec5c10cccecbb48ccb197e9484b9de27ee06ec1a2b172f46488
6
+ metadata.gz: bf4947d9f5b5055806281a167944ab1d83ef3b9d14bb32204393f6d47a9a70cab5e5e88785c871eeaf31657ae59d7c4a50693ac41eef1d78a3d55640cbd31981
7
+ data.tar.gz: 6d735f28a68c328d3187ca76638660380777399e3bc4a4536adc850536e5bcd29e4a9174978bebbb946da5c936fae3d5816e00821eb91530a82ff19e03d1c668
@@ -1,4 +1,4 @@
1
- # The public REST API for http://grabz.it
1
+ # The public REST API for https://grabz.it
2
2
  # @example To include the GrabzIt module do the following
3
3
  # require 'grabzit'
4
4
  module GrabzIt
@@ -32,13 +32,15 @@ module GrabzIt
32
32
  # grabzItClient.save("http://www.mysite.com/grabzit/handler")
33
33
  # @version 3.0
34
34
  # @author GrabzIt
35
- # @see http://grabz.it/api/ruby/ GrabzIt Ruby API
35
+ # @see https://grabz.it/api/ruby/ GrabzIt Ruby API
36
36
  class Client
37
37
 
38
38
  WebServicesBaseURL = "://api.grabz.it/services/"
39
39
  private_constant :WebServicesBaseURL
40
40
  TakePicture = "takepicture"
41
41
  private_constant :TakePicture
42
+ TakeVideo = "takevideo"
43
+ private_constant :TakeVideo
42
44
  TakeTable = "taketable"
43
45
  private_constant :TakeTable
44
46
  TakePDF = "takepdf"
@@ -54,7 +56,7 @@ module GrabzIt
54
56
  #
55
57
  # @param applicationKey [String] your application key
56
58
  # @param applicationSecret [String] your application secret
57
- # @see http://grabz.it/register.aspx You can get an application key and secret by registering for free with GrabzIt
59
+ # @see https://grabz.it/login/create/ You can get an application key and secret by registering for free with GrabzIt
58
60
  def initialize(applicationKey, applicationSecret)
59
61
  @applicationKey = applicationKey
60
62
  @applicationSecret = applicationSecret
@@ -116,6 +118,45 @@ module GrabzIt
116
118
  html_to_image(read_file(path), options)
117
119
  end
118
120
 
121
+ # This method specifies the URL that should be converted into a video
122
+ #
123
+ # @param url [String] the URL to capture as a video
124
+ # @param options [VideoOptions, nil] a instance of the VideoOptions class that defines any special options to use when creating a video
125
+ # @return [void]
126
+ def url_to_video(url, options = nil)
127
+
128
+ if options == nil
129
+ options = VideoOptions.new()
130
+ end
131
+
132
+ @request = Request.new(@protocol + WebServicesBaseURL + TakeVideo, false, options, url)
133
+ return nil
134
+ end
135
+
136
+ # This method specifies the HTML that should be converted into a video
137
+ #
138
+ # @param html [String] the HTML to convert into a video
139
+ # @param options [VideoOptions, nil] a instance of the VideoOptions class that defines any special options to use when creating a video
140
+ # @return [void]
141
+ def html_to_video(html, options = nil)
142
+
143
+ if options == nil
144
+ options = VideoOptions.new()
145
+ end
146
+
147
+ @request = Request.new(@protocol + WebServicesBaseURL + TakeVideo, true, options, html)
148
+ return nil
149
+ end
150
+
151
+ # This method specifies a HTML file that should be converted into a video
152
+ #
153
+ # @param path [String] the file path of a HTML file to convert into a video
154
+ # @param options [VideoOptions, nil] a instance of the VideoOptions class that defines any special options to use when creating a video
155
+ # @return [void]
156
+ def file_to_video(path, options = nil)
157
+ html_to_video(read_file(path), options)
158
+ end
159
+
119
160
  # This method specifies the URL that should be converted into rendered HTML
120
161
  #
121
162
  # @param url [String] the URL to capture as rendered HTML
@@ -627,7 +668,7 @@ module GrabzIt
627
668
 
628
669
  # This method will decrypt a encrypted capture, using the key you passed to the encryption key parameter.
629
670
  #
630
- # @param path [String] the encrypted bytes
671
+ # @param data [Array<Byte>] the encrypted bytes
631
672
  # @param key [String] the encryption key
632
673
  # @return [Array<Byte>] an array of decrypted bytes
633
674
  def decrypt(data, key)
@@ -0,0 +1,272 @@
1
+ module GrabzIt
2
+ require File.join(File.dirname(__FILE__), 'baseoptions')
3
+
4
+ # Represents all of the options available when creating an video
5
+ # @version 3.0
6
+ # @author GrabzIt
7
+ class VideoOptions < BaseOptions
8
+ def initialize()
9
+ super()
10
+ @browserWidth = nil
11
+ @browserHeight = nil
12
+ @width = nil
13
+ @height = nil
14
+ @waitForElement = nil
15
+ @requestAs = 0
16
+ @customWaterMarkId = nil
17
+ @noAds = false
18
+ @noCookieNotifications = false
19
+ @address = nil
20
+ @clickElement = nil
21
+ @start = 0
22
+ @duration = 10
23
+ @framesPerSecond = 0
24
+ end
25
+
26
+ # @return [Integer] the width of the browser in pixels
27
+ def browserWidth
28
+ @browserWidth
29
+ end
30
+
31
+ # Set the width of the browser in pixels
32
+ #
33
+ # @param value [Integer] the browser width
34
+ # @return [void]
35
+ def browserWidth=(value)
36
+ @browserWidth = value
37
+ end
38
+
39
+ # @return [Integer] the height of the browser in pixels
40
+ def browserHeight
41
+ @browserHeight
42
+ end
43
+
44
+ # Set the height of the browser in pixels. Use -1 to screenshot the whole web page
45
+ #
46
+ # @param value [Integer] the browser height
47
+ # @return [void]
48
+ def browserHeight=(value)
49
+ @browserHeight = value
50
+ end
51
+
52
+ # @return [Integer] get the width of the resulting video in pixels
53
+ def width
54
+ @width
55
+ end
56
+
57
+ # Set the width of the resulting video in pixels
58
+ #
59
+ # @param value [Integer] the width
60
+ # @return [void]
61
+ def width=(value)
62
+ @width = value
63
+ end
64
+
65
+ # @return [Integer] get the height of the resulting video in pixels
66
+ def height
67
+ @height
68
+ end
69
+
70
+ # Set the height of the resulting video in pixels
71
+ #
72
+ # @param value [Integer] the height
73
+ # @return [void]
74
+ def height=(value)
75
+ @height = value
76
+ end
77
+
78
+ # @return [String] get the CSS selector of the HTML element in the web page that must be visible before the capture is performed
79
+ def waitForElement
80
+ @waitForElement
81
+ end
82
+
83
+ # Set the CSS selector of the HTML element in the web page that must be visible before the capture is performed
84
+ #
85
+ # @param value [String] the element to wait for
86
+ # @return [void]
87
+ def waitForElement=(value)
88
+ @waitForElement = value
89
+ end
90
+
91
+ # @return [String] get the CSS selector of the HTML element in the web page that must clicked before the capture is performed
92
+ def clickElement
93
+ @clickElement
94
+ end
95
+
96
+ # Set the CSS selector of the HTML element in the web page that must clicked before the capture is performed
97
+ #
98
+ # @param value [String] the element to click
99
+ # @return [void]
100
+ def clickElement=(value)
101
+ @clickElement = value
102
+ end
103
+
104
+ # @return [Integer] get which user agent type should be used
105
+ def requestAs
106
+ @requestAs
107
+ end
108
+
109
+ # Set which user agent type should be used: Standard Browser = 0, Mobile Browser = 1, Search Engine = 2 and Fallback Browser = 3
110
+ #
111
+ # @param value [Integer] the browser type
112
+ # @return [void]
113
+ def requestAs=(value)
114
+ @requestAs = value
115
+ end
116
+
117
+ # @return [String] the custom watermark id.
118
+ def customWaterMarkId
119
+ @customWaterMarkId
120
+ end
121
+
122
+ # Set a custom watermark to add to the screenshot.
123
+ #
124
+ # @param value [String] custom watermark id
125
+ # @return [void]
126
+ def customWaterMarkId=(value)
127
+ @customWaterMarkId = value
128
+ end
129
+
130
+ # @return [Boolean] get if adverts should be automatically hidden
131
+ def noAds
132
+ @noAds
133
+ end
134
+
135
+ # Set to true if adverts should be automatically hidden
136
+ #
137
+ # @param value [Boolean] hide adverts
138
+ # @return [void]
139
+ def noAds=(value)
140
+ @noAds = value
141
+ end
142
+
143
+ # @return [Boolean] get if cookie notifications should be automatically hidden
144
+ def noCookieNotifications
145
+ @noCookieNotifications
146
+ end
147
+
148
+ # Set to true if cookie notifications should be automatically hidden
149
+ #
150
+ # @param value [Boolean] hide cookie notifications
151
+ # @return [void]
152
+ def noCookieNotifications=(value)
153
+ @noCookieNotifications = value
154
+ end
155
+
156
+ # @return [String] get the URL to execute the HTML code in
157
+ def address
158
+ @address
159
+ end
160
+
161
+ # Set the URL to execute the HTML code in
162
+ #
163
+ # @param value [String] the address
164
+ # @return [void]
165
+ def address=(value)
166
+ @address = value
167
+ end
168
+
169
+ # @return [Integer] the starting time of the web page that should be converted into a video
170
+ def start
171
+ @start
172
+ end
173
+
174
+ # Set the starting time of the web page that should be converted into a video
175
+ #
176
+ # @param value [Integer] the second to start at
177
+ # @return [void]
178
+ def start=(value)
179
+ @start = value
180
+ end
181
+
182
+ # @return [Integer] the length in seconds of the web page that should be converted into a video
183
+ def duration
184
+ @duration
185
+ end
186
+
187
+ # Set the length in seconds of the web page that should be converted into a video
188
+ #
189
+ # @param value [Integer] the number of seconds
190
+ # @return [void]
191
+ def duration=(value)
192
+ @duration = value
193
+ end
194
+
195
+ # @return [Float] the number of frames per second that should be used to create the video. From a minimum of 0.2 to a maximum of 10
196
+ def framesPerSecond
197
+ @framesPerSecond
198
+ end
199
+
200
+ # Set the number of frames per second that should be used to create the video. From a minimum of 0.2 to a maximum of 10
201
+ #
202
+ # @param value [Float] the number of frames per second
203
+ # @return [void]
204
+ def framesPerSecond=(value)
205
+ @framesPerSecond = value
206
+ end
207
+
208
+ # Define a HTTP Post parameter and optionally value, this method can be called multiple times to add multiple parameters. Using this method will force
209
+ # GrabzIt to perform a HTTP post.
210
+ #
211
+ # @param name [String] the name of the HTTP Post parameter
212
+ # @param value [String] the value of the HTTP Post parameter
213
+ def add_post_parameter(name, value)
214
+ @post = appendParameter(@post, name, value)
215
+ end
216
+
217
+ # @!visibility private
218
+ def _getSignatureString(applicationSecret, callBackURL, url = nil)
219
+ items = [applicationSecret]
220
+
221
+ if(url != nil)
222
+ items.push(GrabzIt::Utility.nil_check(url))
223
+ end
224
+
225
+ items.push(GrabzIt::Utility.nil_check(callBackURL),
226
+ GrabzIt::Utility.nil_int_check(@browserHeight),
227
+ GrabzIt::Utility.nil_int_check(@browserWidth),
228
+ GrabzIt::Utility.nil_check(@customId),
229
+ GrabzIt::Utility.nil_check(@customWaterMarkId),
230
+ GrabzIt::Utility.nil_int_check(@start),
231
+ GrabzIt::Utility.nil_int_check(@requestAs),
232
+ GrabzIt::Utility.nil_check(@country),
233
+ GrabzIt::Utility.nil_check(@exportURL),
234
+ GrabzIt::Utility.nil_check(@waitForElement),
235
+ GrabzIt::Utility.nil_check(@encryptionKey),
236
+ GrabzIt::Utility.b_to_str(@noAds),
237
+ GrabzIt::Utility.nil_check(@post),
238
+ GrabzIt::Utility.nil_check(@proxy),
239
+ GrabzIt::Utility.nil_check(@address),
240
+ GrabzIt::Utility.b_to_str(@noCookieNotifications),
241
+ GrabzIt::Utility.nil_check(@clickElement),
242
+ GrabzIt::Utility.nil_float_check(@framesPerSecond),
243
+ GrabzIt::Utility.nil_int_check(@duration),
244
+ GrabzIt::Utility.nil_int_check(@width),
245
+ GrabzIt::Utility.nil_int_check(@height))
246
+
247
+ return items.join("|")
248
+ end
249
+
250
+ # @!visibility private
251
+ def _getParameters(applicationKey, sig, callBackURL, dataName, dataValue)
252
+ params = createParameters(applicationKey, sig, callBackURL, dataName, dataValue)
253
+ params['bwidth'] = GrabzIt::Utility.nil_int_check(@browserWidth)
254
+ params['customwatermarkid'] = GrabzIt::Utility.nil_check(@customWaterMarkId)
255
+ params['bheight'] = GrabzIt::Utility.nil_int_check(@browserHeight)
256
+ params['waitfor'] = GrabzIt::Utility.nil_check(@waitForElement)
257
+ params['requestmobileversion'] = GrabzIt::Utility.nil_int_check(@requestAs)
258
+ params['noads'] = GrabzIt::Utility.b_to_str(@noAds)
259
+ params['post'] = GrabzIt::Utility.nil_check(@post)
260
+ params['address'] = GrabzIt::Utility.nil_check(@address)
261
+ params['nonotify'] = GrabzIt::Utility.b_to_str(@noCookieNotifications)
262
+ params['click'] = GrabzIt::Utility.nil_check(@clickElement)
263
+ params['start'] = GrabzIt::Utility.nil_int_check(@start)
264
+ params['fps'] = GrabzIt::Utility.nil_float_check(@framesPerSecond)
265
+ params['duration'] = GrabzIt::Utility.nil_int_check(@duration)
266
+ params['width'] = GrabzIt::Utility.nil_int_check(@width)
267
+ params['height'] = GrabzIt::Utility.nil_int_check(@height)
268
+
269
+ return params
270
+ end
271
+ end
272
+ end
data/test/test_grabzit.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'test/unit'
2
- require 'grabzit'
2
+ require_relative '../lib/grabzit.rb'
3
3
 
4
4
  class GrabzItTest < Test::Unit::TestCase
5
5
  Cookie_Name = "test_cookie"
@@ -31,6 +31,14 @@ class GrabzItTest < Test::Unit::TestCase
31
31
  end
32
32
  end
33
33
 
34
+ def test_html_to_video
35
+ assert_nothing_raised "An error occured when trying to take convert HTML to a video" do
36
+ grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
37
+ grabzItClient.html_to_video("<h1>Hello world</h1>");
38
+ assert_not_equal(false, grabzItClient.save(), "HTML not converted")
39
+ end
40
+ end
41
+
34
42
  def test_html_to_pdf
35
43
  assert_nothing_raised "An error occured when trying to take convert HTML to a pdf" do
36
44
  grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grabzit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.2
4
+ version: 3.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - GrabzIt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-09 00:00:00.000000000 Z
11
+ date: 2024-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,8 +24,8 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: Use GrabzIt to convert HTML or URL's into images, PDF, rendered HTML
28
- or DOCX. These captures have highly customizable options include altering quality,
27
+ description: Use GrabzIt to convert HTML or URL's into images, PDF, videos, rendered
28
+ HTML or DOCX. These captures have highly customizable options include altering quality,
29
29
  delay, size, browser type, geographic location and much more. Additionally GrabzIt
30
30
  can even convert HTML tables on the web into a CSV or Excel spreadsheet. As well
31
31
  as enabling online video's to be converted into animated GIF's.
@@ -50,6 +50,7 @@ files:
50
50
  - lib/grabzit/screenshotstatus.rb
51
51
  - lib/grabzit/tableoptions.rb
52
52
  - lib/grabzit/utility.rb
53
+ - lib/grabzit/videooptions.rb
53
54
  - lib/grabzit/watermark.rb
54
55
  - test/test.png
55
56
  - test/test_grabzit.rb
@@ -72,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
73
  - !ruby/object:Gem::Version
73
74
  version: '0'
74
75
  requirements: []
75
- rubygems_version: 3.1.6
76
+ rubygems_version: 3.4.19
76
77
  signing_key:
77
78
  specification_version: 4
78
79
  summary: GrabzIt Ruby Client