1 | request = require 'superagent'
|
2 |
|
3 | # Archive
|
4 | class Archive
|
5 | # get
|
6 | #
|
7 | # @param {string} path
|
8 | # @param {object} query
|
9 | # @param {function} callback err, response
|
10 | # @return {Archive} this
|
11 | get: (path, query, cb) ->
|
12 | cb = arguments[arguments.length - 1]
|
13 |
|
14 | request.get("http://archive.org/#{path}")
|
15 | .query(output: 'json')
|
16 | .query(query unless typeof query is 'function')
|
17 | .end (res) ->
|
18 | console.log res.body
|
19 | cb res.body
|
20 | @
|
21 |
|
22 | # http://archive.org/advancedsearch.php?type
|
23 | #
|
24 | # @param {function} callback err, response
|
25 | # @return {Archive} this
|
26 | search: (params, cb) ->
|
27 | @get 'advancedsearch.php', params, (response) ->
|
28 | cb null, response
|
29 |
|
30 | v: -> '0.0.1'
|
31 |
|
32 | module.exports = new Archive()
|