1
2
3
4 """
5 Copyright (c) 2010 The Echo Nest. All rights reserved.
6 Created by Tyler Williams on 2011-10-21.
7
8 The Sandbox module loosely covers http://developer.echonest.com/docs/v4/sandbox.html
9 Refer to the official api documentation if you are unsure about something.
10 """
11 try:
12 import json
13 except ImportError:
14 import simplejson as json
15 import datetime
16
17 import util
18 from proxies import ResultList
19
20 -def list(sandbox_name, results=15, start=0):
21 """
22 Returns a list of all assets available in this sandbox
23
24 Args:
25 sandbox_name (str): A string representing the name of the sandbox
26
27 Kwargs:
28 results (int): An integer number of results to return
29
30 start (int): An integer starting value for the result set
31
32 Returns:
33 A list of asset dictionaries
34
35 Example:
36
37 >>> sandbox.list('bluenote')
38 [{}, {}]
39 >>>
40
41
42 """
43 result = util.callm("%s/%s" % ('sandbox', 'list'), {'sandbox':sandbox_name, 'results': results, 'start': start})
44 assets = result['response']['assets']
45 start = result['response']['start']
46 total = result['response']['total']
47
48 return ResultList(assets, start, total)
49
50
51 -def access(sandbox_name, asset_ids):
52 """
53 Returns a list of assets with expiring access urls that can be used to download them
54 *Requires Oauth*
55
56 Args:
57 sandbox_name (str): A string representing the name of the sandbox
58 asset_ids (list): A list of asset_ids (str) to fetch
59
60 Kwargs:
61
62 Returns:
63 A list of asset dictionaries
64
65 Example:
66
67 >>> sandbox.access('bluenote', ['12345'])
68 [{}, {}]
69 >>>
70
71
72 """
73 result = util.oauthgetm("%s/%s" % ('sandbox', 'access'), {'sandbox':sandbox_name, 'id':asset_ids})
74 return result['response']['assets']
75