alluc 0.1.0 → 0.2.0

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: 98cbf2d75a4614f39de1ce895d015b191383a29e
4
- data.tar.gz: c3e0b17415f73022f405772ad9a084bfc1ac63ff
3
+ metadata.gz: 13e51dcd43e1278c5307cba11719f7af4a84a029
4
+ data.tar.gz: ec85e3c5f08d6e24390e33202c6782dd313e95e5
5
5
  SHA512:
6
- metadata.gz: eb6f9b7976225a386256613899211be1f5ac4ad4f0c0d1d10b5a5559141f2080faad968b89ad81dc14e292a33fc1303a0c109efd5473079722fc563c05a42fb4
7
- data.tar.gz: 082b299102a49db1b11ad3fc83111a34b022ffcd22583f153b1fc21c0598ee6c2aca1ba76505c29acf7dfa49bf1778f90cf8c090a78d530940293c98592acb97
6
+ metadata.gz: 3cce7d26f02ecabb6ade847a3a3b4b7553533da7100e9c97a685b354f4f015ac0946b7cf469ed47f1a343faf03f65ec67adf33191ae9559c7866f393ea253182
7
+ data.tar.gz: b54c7c5527ae955e5e313762d64612e1530198b386b59ca654b00df0b8f8dac4e95ad421dfd0ed14e666621326d39012f1e947c0582886f71407c3698d4a62fe
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in alluc.gemspec
4
+ gemspec
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ alluc (0.2.0)
5
+ excon (~> 0.44.4)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ excon (0.44.4)
11
+ rake (10.4.2)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ alluc!
18
+ bundler (~> 1.8)
19
+ rake (~> 10.0)
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ahmet Abdi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # Alluc
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.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'alluc'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install alluc
22
+
23
+ ## Usage
24
+
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.
30
+
31
+ 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
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/alluc/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ desc "Open an irb session preloaded with this library"
4
+ task :console do
5
+ sh "irb -rubygems -I lib -r alluc.rb"
6
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'alluc/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "alluc"
8
+ spec.version = Alluc::VERSION
9
+ spec.authors = ["Ahmet Abdi"]
10
+ spec.email = ["ahmetabdi@gmail.com"]
11
+
12
+ spec.summary = %q{'Alluc API'}
13
+ spec.description = %q{'ALluc API'}
14
+ spec.homepage = "https://github.com/ahmetabdi/alluc"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.8"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_dependency 'excon', '~> 0.44.4'
25
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "alluc"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,38 @@
1
+ require 'alluc/version'
2
+ require 'excon'
3
+ require 'pry'
4
+ require 'ostruct'
5
+ require 'json'
6
+ require 'cgi'
7
+ require 'alluc/api'
8
+ require 'alluc/requester'
9
+
10
+ module Alluc
11
+
12
+ def self.connect(api_key)
13
+ Alluc::Api.instance.tap do |api|
14
+ api.connect(api_key)
15
+ end
16
+ end
17
+
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.
24
+ 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
+ end
37
+
38
+ end
@@ -0,0 +1,29 @@
1
+ require 'singleton'
2
+
3
+ module Alluc
4
+ class Api
5
+ include Singleton
6
+
7
+ attr_reader :base_url, :mashape_url, :version, :api_key
8
+
9
+ def initialize
10
+ self.base_url = 'https://www.alluc.com/api/'.freeze
11
+ self.mashape_url = 'https://alluc-alluc-video-and-download-search-v1.p.mashape.com/api/'.freeze
12
+ self.version = '0.1'.freeze
13
+ end
14
+
15
+ def connect(api_key)
16
+ self.api_key = api_key
17
+ end
18
+
19
+ def url_for(action, params={})
20
+ url = URI.join(mashape_url, action) # Need some base_url / mashape_url logic here
21
+ url.query = URI.encode_www_form(params) unless params.empty?
22
+ url.to_s
23
+ end
24
+
25
+ private
26
+ attr_writer :base_url, :mashape_url, :version, :api_key
27
+
28
+ end
29
+ end
@@ -0,0 +1,38 @@
1
+ class Alluc::Requester
2
+ class << self
3
+ def get(action, params={})
4
+ url = api.url_for(action, params)
5
+ perform_request do
6
+ parse_response(Excon.get(url, :headers => headers))
7
+ end
8
+ end
9
+
10
+ private
11
+ def api
12
+ Alluc::Api.instance
13
+ end
14
+
15
+ def headers
16
+ Hash.new.tap do |headers|
17
+ headers['Accept'] = 'application/json'
18
+ headers['Content-Type'] = 'application/json'
19
+ headers['X-Mashape-Key'] = api.api_key
20
+ end
21
+ end
22
+
23
+ def perform_request(&block)
24
+ begin
25
+ block.call
26
+ rescue
27
+ end
28
+ end
29
+
30
+ def parse_response(response)
31
+ begin
32
+ JSON.parse(response.body, object_class: OpenStruct)
33
+ rescue JSON::ParserError => e
34
+ end
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,32 @@
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
@@ -0,0 +1,3 @@
1
+ module Alluc
2
+ VERSION = "0.2.0"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alluc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
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-03-19 00:00:00.000000000 Z
11
+ date: 2015-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,13 +38,41 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
- description: ''
41
+ - !ruby/object:Gem::Dependency
42
+ name: excon
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.44.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.44.4
55
+ description: "'ALluc API'"
42
56
  email:
43
57
  - ahmetabdi@gmail.com
44
58
  executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
- files: []
61
+ files:
62
+ - CODE_OF_CONDUCT.md
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - alluc.gemspec
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/alluc.rb
72
+ - lib/alluc/api.rb
73
+ - lib/alluc/requester.rb
74
+ - lib/alluc/search.rb
75
+ - lib/alluc/version.rb
48
76
  homepage: https://github.com/ahmetabdi/alluc
49
77
  licenses:
50
78
  - MIT
@@ -68,5 +96,5 @@ rubyforge_project:
68
96
  rubygems_version: 2.4.6
69
97
  signing_key:
70
98
  specification_version: 4
71
- summary: ''
99
+ summary: "'Alluc API'"
72
100
  test_files: []