grabzit 2.1.3 → 2.2.0

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: e46954d4956663d54e9e74b16b56779f9a608d05
4
- data.tar.gz: 92f87a1e2f4fd45ba920157ad47035373762450f
3
+ metadata.gz: 17e5e690195e3db9e04ddb68b01c8452d9e78ef9
4
+ data.tar.gz: 62c853dc8b70e06b8037839cad0d49ff0b22b304
5
5
  SHA512:
6
- metadata.gz: f34f12ce5d2c01b566e12e6bff84b1d646815aca85df286ec9d92581c71db624d3a550cee2dc46f37d1d557f3b85ad118d5e113039a19ab17d08af1c2904790f
7
- data.tar.gz: 1e6d7037338e53771e1c885e007efaceaba3d60b55b47d29fc289af76d1a9ffec0a2762f3c7d6fe898e48f5fb48050fec2acb14c65fd33a68c2b3e87981710de
6
+ metadata.gz: f4504960048214f2855de361bf232b0910ec25b728e6d230392444cda73cf035dc38f3ec85293346ed2f6be0f84659ed5bd78744dbdb5247d560463a081e5e6f
7
+ data.tar.gz: 82b9b8811d5606238ffbeb4b5ae128856f6a7c9f7a02c9be3c0925e679dd31f470b41eb556efe7b7d59a9b29cb93e0274b4a7aa3a3ef08e6abdc5e4eb475fc4b
@@ -25,7 +25,7 @@ module GrabzIt
25
25
  # @see http://grabz.it/api/ruby/ GrabzIt Ruby API
26
26
  class Client
27
27
 
28
- WebServicesBaseURL = "http://grabz.it/services/"
28
+ WebServicesBaseURL = "http://api.grabz.it/services/"
29
29
  private_constant :WebServicesBaseURL
30
30
  TrueString = "True"
31
31
  private_constant :TrueString
@@ -45,10 +45,35 @@ module GrabzIt
45
45
  @applicationSecret = applicationSecret
46
46
  end
47
47
 
48
+ # This method sets the parameters required to turn a online video into a animated GIF
49
+ #
50
+ # @param url [String] the URL of the online video
51
+ # @param customId [String, nil] custom identifier that you can pass through to the animated GIF web service. This will be returned with the callback URL you have specified
52
+ # @param width [Integer, 0] the width of the resulting animated GIF in pixels
53
+ # @param height [Integer, 0] the height of the resulting animated GIF in pixels
54
+ # @param start [Integer, 0] the starting position of the video that should be converted into a animated GIF
55
+ # @param duration [Integer, 0] the length in seconds of the video that should be converted into a animated GIF
56
+ # @param speed [Float, 0] the speed of the animated GIF from 0.2 to 10 times the original speed
57
+ # @param framesPerSecond [Float, 0] the number of frames per second that should be captured from the video. From a minimum of 0.2 to a maximum of 60
58
+ # @param repeat [Integer, 0] the number of times to loop the animated GIF. If 0 it will loop forever
59
+ # @param reverse [Boolean, false] if true the frames of the animated GIF are reversed
60
+ # @param customWaterMarkId [String, nil] add a custom watermark to the animated GIF
61
+ # @param quality [Integer, -1] the quality of the image where 0 is poor and 100 excellent. The default is -1 which uses the recommended quality
62
+ # @param country [String, nil] request the screenshot from different countries: Default, UK or US
63
+ # @return [void]
64
+ def set_animation_options(url, customId = nil, width = 0, height = 0, start = 0, duration = 0, speed = 0, framesPerSecond = 0, repeat = 0, reverse = false, customWaterMarkId = nil, quality = -1, country = nil)
65
+ @@startDelay = 0;
66
+ @@request = WebServicesBaseURL + "takeanimation.ashx?key=" + CGI.escape(nil_check(@applicationKey))+"&url="+CGI.escape(nil_check(url))+"&width="+nil_int_check(width)+"&height="+nil_int_check(height)+"&duration="+nil_int_check(duration)+"&speed="+nil_float_check(speed)+"&start="+nil_int_check(start)+"&customid="+CGI.escape(nil_check(customId))+"&fps="+nil_float_check(framesPerSecond)+"&repeat="+nil_int_check(repeat)+"&customwatermarkid="+CGI.escape(nil_check(customWaterMarkId))+"&reverse="+b_to_str(reverse)+"&country="+CGI.escape(nil_check(country))+"&quality="+nil_int_check(quality)+"&callback="
67
+ @@signaturePartOne = @applicationSecret+"|"+nil_check(url)+"|"
68
+ @@signaturePartTwo = "|"+nil_int_check(height)+"|"+nil_int_check(width)+"|"+nil_check(customId)+"|"+nil_float_check(framesPerSecond)+"|"+nil_float_check(speed)+"|"+nil_int_check(duration)+"|"+nil_int_check(repeat)+"|"+b_to_str(reverse)+"|"+nil_int_check(start)+"|"+nil_check(customWaterMarkId)+"|"+nil_check(country)+"|"+nil_int_check(quality)
69
+ return nil
70
+ end
71
+
72
+
48
73
  # Sets the parameters required to take a screenshot of a web page.
49
74
  #
50
75
  # @param url [String] the URL that the screenshot should be made of
51
- # @param customId [String, nil] custom identifier that you can pass through to the screenshot webservice. This will be returned with the callback URL you have specified.
76
+ # @param customId [String, nil] custom identifier that you can pass through to the screenshot web service. This will be returned with the callback URL you have specified.
52
77
  # @param browserWidth [Integer, nil] the width of the browser in pixels
53
78
  # @param browserHeight [Integer, nil] the height of the browser in pixels
54
79
  # @param width [Integer, nil] the width of the resulting thumbnail in pixels
@@ -79,11 +104,11 @@ module GrabzIt
79
104
  # Sets the parameters required to extract one or more tables from a web page.
80
105
  #
81
106
  # @param url [String] the URL that the should be used to extract tables
82
- # @param customId [String, nil] a custom identifier that you can pass through to the webservice. This will be returned with the callback URL you have specified.
107
+ # @param customId [String, nil] a custom identifier that you can pass through to the web service. This will be returned with the callback URL you have specified.
83
108
  # @param tableNumberToInclude [Integer, 1] the index of the table to be converted, were all tables in a web page are ordered from the top of the web page to bottom
84
109
  # @param format [String, 'csv'] the format the table should be in: csv, xlsx
85
110
  # @param includeHeaderNames [Boolean, true] if true header names will be included in the table
86
- # @param includeAllTables [Boolean, true] if true all table on the web page will be extracted with each table appearing in a seperate spreadsheet sheet. Only available with the XLSX format.
111
+ # @param includeAllTables [Boolean, true] if true all table on the web page will be extracted with each table appearing in a separate spreadsheet sheet. Only available with the XLSX format.
87
112
  # @param targetElement [String, nil] the id of the only HTML element in the web page that should be used to extract tables from
88
113
  # @param requestAs [Integer, 0] request the screenshot in different forms: Standard Browser = 0, Mobile Browser = 1, Search Engine = 2 and Fallback Browser = 3
89
114
  # @param country [String, nil] request the screenshot from different countries: Default = "", UK = "UK", US = "US"
@@ -101,7 +126,7 @@ module GrabzIt
101
126
  # Sets the parameters required to convert a web page into a PDF.
102
127
  #
103
128
  # @param url url [String] the URL that the should be converted into a pdf
104
- # @param customId [String, nil] a custom identifier that you can pass through to the webservice. This will be returned with the callback URL you have specified.
129
+ # @param customId [String, nil] a custom identifier that you can pass through to the web service. This will be returned with the callback URL you have specified.
105
130
  # @param includeBackground [Boolean, true] if true the background of the web page should be included in the screenshot
106
131
  # @param pagesize [String, 'A4'] the page size of the PDF to be returned: 'A3', 'A4', 'A5', 'B3', 'B4', 'B5', 'Letter'.
107
132
  # @param orientation [String, 'Portrait'] the orientation of the PDF to be returned: 'Landscape' or 'Portrait'
@@ -240,6 +265,10 @@ module GrabzIt
240
265
  # @return [Object] returns the screenshot
241
266
  # @raise [RuntimeError] if the GrabzIt service reports an error with the request it will be raised as a RuntimeError
242
267
  def get_result(id)
268
+ if id == nil || id == ""
269
+ return nil
270
+ end
271
+
243
272
  return get(WebServicesBaseURL + "getfile.ashx?id=" + nil_check(id))
244
273
  end
245
274
 
@@ -344,7 +373,7 @@ module GrabzIt
344
373
 
345
374
  boundary = '--------------------------'+Time.now.to_f.to_s
346
375
 
347
- url = WebServicesBaseURL + "addwatermark.ashx"
376
+ url = "http://grabz.it/services/addwatermark.ashx"
348
377
  uri = URI.parse(url)
349
378
 
350
379
  file = File.open(path, "rb")
@@ -510,6 +539,16 @@ module GrabzIt
510
539
  def nil_int_check(param)
511
540
  return param.to_i.to_s
512
541
  end
542
+
543
+ private
544
+ def nil_float_check(param)
545
+ val = param.to_f
546
+ if ((val % 1) == 0)
547
+ return val.to_i.to_s
548
+ end
549
+
550
+ return val.to_s
551
+ end
513
552
 
514
553
  private
515
554
  def check_for_exception(doc)
@@ -51,6 +51,15 @@ module GrabzIt
51
51
  PARAMETER_MISSING_PARAMETERS = 143
52
52
  PARAMETER_QUALITY_TOO_LARGE = 144
53
53
  PARAMETER_QUALITY_TOO_SMALL = 145
54
+ PARAMETER_REPEAT_TOO_SMALL = 149
55
+ PARAMETER_INVALID_REVERSE = 150
56
+ PARAMETER_FPS_TOO_LARGE = 151
57
+ PARAMETER_FPS_TOO_SMALL = 152
58
+ PARAMETER_SPEED_TOO_FAST = 153
59
+ PARAMETER_SPEED_TOO_SLOW = 154
60
+ PARAMETER_INVALID_ANIMATION_COMBINATION = 155
61
+ PARAMETER_START_TOO_SMALL = 156
62
+ PARAMETER_DURATION_TOO_LARGE = 157
54
63
  NETWORK_SERVER_OFFLINE = 200
55
64
  NETWORK_GENERAL_ERROR = 201
56
65
  NETWORK_DDOS_ATTACK = 202
@@ -9,10 +9,10 @@ class GrabzItTest < Test::Unit::TestCase
9
9
  Screenshot_Path = "test/tmp.jpg"
10
10
 
11
11
  def setup
12
- @applicationKey = ""
13
- @applicationSecret = ""
12
+ @applicationKey = "c3VwcG9ydEBncmFiei5pdA=="
13
+ @applicationSecret = "AD8/aT8/Pz8/Tz8/PwJ3Pz9sVSs/Pz8/Pz9DOzJodoi="
14
14
  #Set to true if the account is subscribed
15
- @isSubscribedAccount = false
15
+ @isSubscribedAccount = true
16
16
  end
17
17
 
18
18
  def test_application_key
@@ -58,6 +58,14 @@ class GrabzItTest < Test::Unit::TestCase
58
58
  File.delete(Screenshot_Path)
59
59
  end
60
60
 
61
+ def test_save_animation
62
+ assert_nothing_raised "An error occured when trying to take a animation" do
63
+ grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
64
+ grabzItClient.set_animation_options("http://www.youtube.com");
65
+ assert_not_equal(false, grabzItClient.save(), "Animation not taken")
66
+ end
67
+ end
68
+
61
69
  def test_save_to_bytes
62
70
  assert_nothing_raised "An error occured when trying to take a image screenshot" do
63
71
  grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
@@ -90,7 +98,9 @@ class GrabzItTest < Test::Unit::TestCase
90
98
  grabzItClient.set_cookie(Cookie_Name, Cookie_Domain)
91
99
  end
92
100
  return
93
- end
101
+ end
102
+
103
+ sleep(4)
94
104
 
95
105
  assert(find_cookie(grabzItClient), "Set cookie has not been found!")
96
106
  end
@@ -108,10 +118,14 @@ class GrabzItTest < Test::Unit::TestCase
108
118
  return
109
119
  end
110
120
 
121
+ sleep(4)
122
+
111
123
  assert_equal(true, find_cookie(grabzItClient), "Test cookie not found!")
112
124
 
113
125
  grabzItClient.delete_cookie(Cookie_Name, Cookie_Domain)
114
126
 
127
+ sleep(4)
128
+
115
129
  assert_equal(false, find_cookie(grabzItClient), "Failed to delete cookie!")
116
130
  end
117
131
  end
@@ -133,10 +147,14 @@ class GrabzItTest < Test::Unit::TestCase
133
147
  return
134
148
  end
135
149
 
150
+ sleep(5)
151
+
136
152
  assert_equal(true, find_watermark(grabzItClient), "Test watermark not found!")
137
153
 
138
154
  grabzItClient.delete_watermark(WaterMark_Identifier)
139
155
 
156
+ sleep(5)
157
+
140
158
  assert_equal(false, find_watermark(grabzItClient), "Failed to delete watermark!")
141
159
  end
142
160
  end
@@ -155,7 +173,9 @@ class GrabzItTest < Test::Unit::TestCase
155
173
  grabzItClient.add_watermark(WaterMark_Identifier, WaterMark_Path, 2, 2)
156
174
  end
157
175
  return
158
- end
176
+ end
177
+
178
+ sleep(4)
159
179
 
160
180
  assert(find_watermark(grabzItClient), "Set watermark has not been found!")
161
181
  end
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: 2.1.3
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GrabzIt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2014-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -26,7 +26,8 @@ dependencies:
26
26
  version: '0'
27
27
  description: 'Automatically create screenshots of website for free, with GrabzIt.
28
28
  Screenshots can be output in a variety of formats including: JPEG, PNG, TIFF, BMP,
29
- PDF, CSV and XLSX.'
29
+ PDF, CSV and XLSX. Additionally GrabzIt allows you to convert online videos into
30
+ animated GIF''s.'
30
31
  email: support@grabz.it
31
32
  executables: []
32
33
  extensions: []