two_captcha 1.1.0 → 1.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 +4 -4
- data/README.md +10 -2
- data/captchas/3.mp3 +0 -0
- data/lib/two_captcha/client.rb +2 -5
- data/lib/two_captcha/version.rb +1 -1
- data/spec/lib/client_spec.rb +15 -0
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b2779681253ef270666b343ac55f430b790229a1
         | 
| 4 | 
            +
              data.tar.gz: e02d828d5a7af4d3707ff246f8fbadf85ad012c1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7b5c68c961ebd3f92dfd265ec3489ae772430fcf16b51f6486adcd46befc360c0e0ad6adbd034734500afedc24728210cc7a1fe3b6da8b9c02ee503636087e0a
         | 
| 7 | 
            +
              data.tar.gz: 67dc5d2753dc923afc74ef5b30f10b950488d1c76f2440e129c083a3b385afe72b0aed30baa42afb748bb78b1f68ec9729ee6c290a82b80ef5e2b56c7b26cc82
         | 
    
        data/README.md
    CHANGED
    
    | @@ -118,9 +118,17 @@ more information. | |
| 118 118 | 
             
            The response will be an array containing coordinates where the captcha should be
         | 
| 119 119 | 
             
            clicked. For the captcha above it should look something like:
         | 
| 120 120 |  | 
| 121 | 
            +
            ## Audio reCAPTCHA v2
         | 
| 122 | 
            +
             | 
| 123 | 
            +
              ```ruby
         | 
| 124 | 
            +
              client.decode(url: 'http://bit.ly/audiorecaptchav2', recaptchavoice: 1)
         | 
| 125 | 
            +
              ```
         | 
| 126 | 
            +
             | 
| 127 | 
            +
            The response will be a simple text:
         | 
| 128 | 
            +
             | 
| 121 129 | 
             
            ```ruby
         | 
| 122 | 
            -
            # captcha. | 
| 123 | 
            -
             | 
| 130 | 
            +
            # captcha.text
         | 
| 131 | 
            +
            '61267'
         | 
| 124 132 | 
             
            ```
         | 
| 125 133 |  | 
| 126 134 | 
             
            ## Notes
         | 
    
        data/captchas/3.mp3
    ADDED
    
    | Binary file | 
    
        data/lib/two_captcha/client.rb
    CHANGED
    
    | @@ -55,7 +55,7 @@ module TwoCaptcha | |
| 55 55 | 
             
                # @option options [Integer] :language       (0) https://2captcha.com/setting
         | 
| 56 56 | 
             
                # @option options [Integer] :header_acao    (0) https://2captcha.com/setting
         | 
| 57 57 | 
             
                # @option options [Integer] :id_constructor (0) 23 if new reCAPTCHA.
         | 
| 58 | 
            -
                # @option options [Integer] coordinatescaptcha (0) 1 if clickable captcha.
         | 
| 58 | 
            +
                # @option options [Integer] :coordinatescaptcha (0) 1 if clickable captcha.
         | 
| 59 59 | 
             
                #
         | 
| 60 60 | 
             
                # @return [TwoCaptcha::Captcha] The captcha (with solution) if an error is
         | 
| 61 61 | 
             
                #                               not raised.
         | 
| @@ -88,10 +88,7 @@ module TwoCaptcha | |
| 88 88 | 
             
                  args = {}
         | 
| 89 89 | 
             
                  args[:body]   = options[:raw64]
         | 
| 90 90 | 
             
                  args[:method] = 'base64'
         | 
| 91 | 
            -
                   | 
| 92 | 
            -
                   :header_acao, :id_constructor, :coordinatescaptcha].each do |key|
         | 
| 93 | 
            -
                    args[key] = options[key] if options[key]
         | 
| 94 | 
            -
                  end
         | 
| 91 | 
            +
                  args.merge!(options)
         | 
| 95 92 | 
             
                  response = request('in', :multipart, args)
         | 
| 96 93 |  | 
| 97 94 | 
             
                  unless response.match(/\AOK\|/)
         | 
    
        data/lib/two_captcha/version.rb
    CHANGED
    
    
    
        data/spec/lib/client_spec.rb
    CHANGED
    
    | @@ -5,6 +5,7 @@ captcha_id       = CREDENTIALS['captcha_id'] | |
| 5 5 | 
             
            captcha_solution = CREDENTIALS['solution']
         | 
| 6 6 | 
             
            image64          = Base64.encode64(File.open('captchas/1.png', 'rb').read)
         | 
| 7 7 | 
             
            clickable64      = Base64.encode64(File.open('captchas/2.jpg', 'rb').read)
         | 
| 8 | 
            +
            audio64          = Base64.encode64(File.open('captchas/3.mp3', 'rb').read)
         | 
| 8 9 |  | 
| 9 10 | 
             
            describe TwoCaptcha::Client do
         | 
| 10 11 | 
             
              describe 'create' do
         | 
| @@ -77,4 +78,18 @@ describe TwoCaptcha::Client do | |
| 77 78 | 
             
                  it { expect(@xy2[1]).to be_between(276, 366).inclusive }
         | 
| 78 79 | 
             
                end
         | 
| 79 80 | 
             
              end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
              context 'audio reCAPTCHA v2' do
         | 
| 83 | 
            +
                before(:all) { @client = TwoCaptcha.new(key) }
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                describe '#decode!' do
         | 
| 86 | 
            +
                  before(:all) do
         | 
| 87 | 
            +
                    @captcha = @client.decode!(raw64: audio64, recaptchavoice: 1)
         | 
| 88 | 
            +
                  end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                  it { expect(@captcha).to be_a(TwoCaptcha::Captcha) }
         | 
| 91 | 
            +
                  it { expect(@captcha.text.downcase).to eq '61267' }
         | 
| 92 | 
            +
                  it { expect(@captcha.id).to match(/[0-9]{9}/) }
         | 
| 93 | 
            +
                end
         | 
| 94 | 
            +
              end
         | 
| 80 95 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: two_captcha
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Marcelo Mita
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2016-05- | 
| 12 | 
            +
            date: 2016-05-24 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: bundler
         | 
| @@ -74,6 +74,7 @@ files: | |
| 74 74 | 
             
            - bin/setup
         | 
| 75 75 | 
             
            - captchas/1.png
         | 
| 76 76 | 
             
            - captchas/2.jpg
         | 
| 77 | 
            +
            - captchas/3.mp3
         | 
| 77 78 | 
             
            - lib/two_captcha.rb
         | 
| 78 79 | 
             
            - lib/two_captcha/client.rb
         | 
| 79 80 | 
             
            - lib/two_captcha/errors.rb
         |