alluc 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 13e51dcd43e1278c5307cba11719f7af4a84a029
4
- data.tar.gz: ec85e3c5f08d6e24390e33202c6782dd313e95e5
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YmI5ZDVjNDJjMzY0N2ViZTZmZTlmZGNiZDk3NDM0MzM5Y2YwNjk4YQ==
5
+ data.tar.gz: !binary |-
6
+ ODUyNjRjMzk1OWMyYWYyMDAwYjA0NzEyODcwOGQyYjM4YzdkMGU2Mg==
5
7
  SHA512:
6
- metadata.gz: 3cce7d26f02ecabb6ade847a3a3b4b7553533da7100e9c97a685b354f4f015ac0946b7cf469ed47f1a343faf03f65ec67adf33191ae9559c7866f393ea253182
7
- data.tar.gz: b54c7c5527ae955e5e313762d64612e1530198b386b59ca654b00df0b8f8dac4e95ad421dfd0ed14e666621326d39012f1e947c0582886f71407c3698d4a62fe
8
+ metadata.gz: !binary |-
9
+ OGRmNzdiYjgyYzE4YzAyM2NjZTczMjgxMDQzMmJhMzlkYmRlYjgxMzY0MjY4
10
+ MDVjZDJmY2E5NjBhMDdkN2I4ODVhYWQ3ZTRiYjQ5ZjM5ZWE2OWFjNmI2OTk3
11
+ NTM3ZjhhYzBlNjUzNDkxYjZlNGNhZDQwZmIzYzhiMzRjZGFmNTM=
12
+ data.tar.gz: !binary |-
13
+ ODEyZTE1ZGJmZmE5MzM1MzUwYjBmNDM1M2QyYTFhMDM0NTMzZThiZDdhZWYx
14
+ NDg0YThjYzljMzllMDNjNDk1ZGVjMzJmMjMwZWUwYzk1Y2Q4NTU2OWQ2NGM1
15
+ ZTI0MTJiOWU0YWE4NWEwYzkxYWJhMmE3NWI3ZWFiMTVkN2NjMTk=
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Alluc
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/alluc`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ alluc.com API
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ With this early version, beta-testers can access allucs database of 21 million streaming and 24m download links and execute full text search queries to find video-hoster or cyberlocker links related to any topic. Beta access is free and allows queries retrieving up to 10,000 links per day.
6
+
7
+ To [sign up](http://api.alluc.com/products/api-10000-calls-month), choose the beta plan and complete checkout (no payment required) and you will receive your API key within the next 24 hours.
8
+
9
+ The API is also available on [Mashape](https://www.mashape.com/alluc/video-and-download-link-search/) (with slightly higher latencies).
6
10
 
7
11
  ## Installation
8
12
 
@@ -22,11 +26,19 @@ Or install it yourself as:
22
26
 
23
27
  ## Usage
24
28
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
29
+ Connect to normal alluc api
30
+ ```ruby
31
+ Alluc.connect('api_key')
32
+ ```
33
+ Connect to mashape api
34
+ ```ruby
35
+ Alluc.connect('api_key', :mashape)
36
+ ```
37
+ Methods
38
+ ```ruby
39
+ Alluc.download_links('batman')
40
+ Alluc.streaming_links('batman')
41
+ ```
30
42
 
31
43
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
44
 
@@ -9,30 +9,23 @@ require 'alluc/requester'
9
9
 
10
10
  module Alluc
11
11
 
12
- def self.connect(api_key)
12
+ def self.connect(api_key, type = :alluc)
13
+ Excon.defaults[:ssl_verify_peer] = false
13
14
  Alluc::Api.instance.tap do |api|
14
- api.connect(api_key)
15
+ api.connect(api_key, type)
15
16
  end
16
17
  end
17
18
 
18
- def self.streaming_links(query, opts={})
19
- params = Hash.new.tap do |hash|
20
- hash['query'] = CGI.escape(query)
21
- hash['count'] = opts[:count] if opts[:count] # count - max-amount of returned results. Can be between 1 - 100
22
- hash['from'] = opts[:from] if opts[:from] # from - where to start. For example if you want result 20-30, you will set count=10 and from=20
23
- hash['getmeta'] = opts[:getmeta] if opts[:getmeta] # getmeta - If you want additional info on hosterlinks and source, set this to 1. Only use if you really need it as it might make for slower queries.
19
+ ['stream', 'download'].each do |action|
20
+ define_singleton_method("#{action}_links") do |query, opts = {}|
21
+ params = Hash.new.tap do |hash|
22
+ hash['query'] = CGI.escape(query)
23
+ hash['count'] = opts[:count] if opts[:count] # count - max-amount of returned results. Can be between 1 - 100
24
+ hash['from'] = opts[:from] if opts[:from] # from - where to start. For example if you want result 20-30, you will set count=10 and from=20
25
+ hash['getmeta'] = opts[:getmeta] if opts[:getmeta] # getmeta - If you want additional info on hosterlinks and source, set this to 1. Only use if you really need it as it might make for slower queries.
26
+ end
27
+ Alluc::Requester.get("search/#{action}", params)
24
28
  end
25
- Alluc::Requester.get('search/stream', params)
26
- end
27
-
28
- def self.download_links(query, opts={})
29
- params = Hash.new.tap do |hash|
30
- hash['query'] = CGI.escape(query)
31
- hash['count'] = opts[:count] if opts[:count] # count - max-amount of returned results. Can be between 1 - 100
32
- hash['from'] = opts[:from] if opts[:from] # from - where to start. For example if you want result 20-30, you will set count=10 and from=20
33
- hash['getmeta'] = opts[:getmeta] if opts[:getmeta] # getmeta - If you want additional info on hosterlinks and source, set this to 1. Only use if you really need it as it might make for slower queries.
34
- end
35
- Alluc::Requester.get('search/download', params)
36
29
  end
37
30
 
38
31
  end
@@ -4,7 +4,7 @@ module Alluc
4
4
  class Api
5
5
  include Singleton
6
6
 
7
- attr_reader :base_url, :mashape_url, :version, :api_key
7
+ attr_reader :base_url, :mashape_url, :version, :api_key, :api_type
8
8
 
9
9
  def initialize
10
10
  self.base_url = 'https://www.alluc.com/api/'.freeze
@@ -12,18 +12,28 @@ module Alluc
12
12
  self.version = '0.1'.freeze
13
13
  end
14
14
 
15
- def connect(api_key)
15
+ def connect(api_key, api_type)
16
16
  self.api_key = api_key
17
+ self.api_type = api_type
18
+ end
19
+
20
+ def actual_url
21
+ if api_type == :mashape
22
+ mashape_url
23
+ else
24
+ base_url
25
+ end
17
26
  end
18
27
 
19
28
  def url_for(action, params={})
20
- url = URI.join(mashape_url, action) # Need some base_url / mashape_url logic here
29
+ params[:apikey] = api_key if api_type == :alluc
30
+ url = URI.join(actual_url, action) # Need some base_url / mashape_url logic here
21
31
  url.query = URI.encode_www_form(params) unless params.empty?
22
32
  url.to_s
23
33
  end
24
34
 
25
35
  private
26
- attr_writer :base_url, :mashape_url, :version, :api_key
36
+ attr_writer :base_url, :mashape_url, :version, :api_key, :api_type
27
37
 
28
38
  end
29
39
  end
@@ -16,21 +16,23 @@ class Alluc::Requester
16
16
  Hash.new.tap do |headers|
17
17
  headers['Accept'] = 'application/json'
18
18
  headers['Content-Type'] = 'application/json'
19
- headers['X-Mashape-Key'] = api.api_key
19
+ headers['X-Mashape-Key'] = api.api_key if api.api_type == :mashape
20
20
  end
21
21
  end
22
22
 
23
23
  def perform_request(&block)
24
24
  begin
25
25
  block.call
26
- rescue
26
+ rescue Exception => e
27
+ puts e.message
27
28
  end
28
29
  end
29
30
 
30
31
  def parse_response(response)
31
32
  begin
32
- JSON.parse(response.body, object_class: OpenStruct)
33
+ JSON.parse(response.body)
33
34
  rescue JSON::ParserError => e
35
+ puts e.message
34
36
  end
35
37
  end
36
38
 
@@ -1,3 +1,3 @@
1
1
  module Alluc
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,58 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alluc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmet Abdi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.8'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: excon
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.44.4
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.44.4
55
- description: "'ALluc API'"
55
+ description: ! '''ALluc API'''
56
56
  email:
57
57
  - ahmetabdi@gmail.com
58
58
  executables: []
@@ -71,7 +71,6 @@ files:
71
71
  - lib/alluc.rb
72
72
  - lib/alluc/api.rb
73
73
  - lib/alluc/requester.rb
74
- - lib/alluc/search.rb
75
74
  - lib/alluc/version.rb
76
75
  homepage: https://github.com/ahmetabdi/alluc
77
76
  licenses:
@@ -83,12 +82,12 @@ require_paths:
83
82
  - lib
84
83
  required_ruby_version: !ruby/object:Gem::Requirement
85
84
  requirements:
86
- - - ">="
85
+ - - ! '>='
87
86
  - !ruby/object:Gem::Version
88
87
  version: '0'
89
88
  required_rubygems_version: !ruby/object:Gem::Requirement
90
89
  requirements:
91
- - - ">="
90
+ - - ! '>='
92
91
  - !ruby/object:Gem::Version
93
92
  version: '0'
94
93
  requirements: []
@@ -96,5 +95,5 @@ rubyforge_project:
96
95
  rubygems_version: 2.4.6
97
96
  signing_key:
98
97
  specification_version: 4
99
- summary: "'Alluc API'"
98
+ summary: ! '''Alluc API'''
100
99
  test_files: []
@@ -1,32 +0,0 @@
1
- module Alluc
2
- class Search
3
- # PARAMS: searchtype:string count:number from:number getmeta:number queryL:string (url encoded)
4
- # query - the search string. All alluc search operators can be used (https://www.alluc.com/about/). Make sure to urlencode this.
5
- # count - max-amount of returned results. Can be between 1 - 100.
6
- # from - where to start. For example if you want result 20-30, you will set count=10 and from=20
7
- # apikey - your apikey
8
- # getmeta - If you want additional info on hosterlinks and source, set this to 1. Only use if you really need it as it might make for slower queries.
9
-
10
- # "status": "success", // Status, success or error
11
- # "message": "", // What went wrong? empty if success
12
- # "result":[ ] // result of your query. Array when using /api/search/ and object in all other cases.
13
- # "fetchedtoday": 174 // Amount of links retrieved with your apikey so far today
14
- # "resultcount": 1 // Amount of results for the current query
15
-
16
- def file_data
17
- # https://www.alluc.com/api/filedata/{filedataid}
18
- # Request more information about a hoster-link. {filedataid} is returned in /api/search/.
19
- end
20
-
21
- def source_data
22
- # https://www.alluc.com/api/sourcedata/{md5-of-source-URL}
23
- # Request more information about a source-url (URL where a hoster link was found)
24
- end
25
-
26
- def thumbnail
27
- # https://www.alluc.com/api/thumbnail/{imageid}
28
- # Fetch a thumbnail. {imageid} is returned in /api/search/.
29
- end
30
-
31
- end
32
- end