source: other-projects/mirex/grand-challenge/generate-jamendo-dataset/scripts-2015/jamendo.py@ 30005

Last change on this file since 30005 was 30005, checked in by davidb, 9 years ago

Initial cut at scripts for generating a 'boosted' ggenre set of files

  • Property svn:executable set to *
File size: 977 bytes
RevLine 
[30005]1
2import urllib
3import json
4
5chunk_size=200
6
7base_url = "http://api.jamendo.com/v3.0/tracks/"
8base_url_args = base_url + "?client_id=54cc3f68&format=json&audioformat=mp32&audiodlformat=flac&ccnc=1&ccsa=1"
9
10##base_url_args = base_url_args + "&include=musicinfo+stats"
11
12
13def download_from_jamendo(offset=0,currentChunkSize=chunk_size,extraArgs=''):
14
15 chunk_url = base_url_args + "&limit=" + str(currentChunkSize)
16
17 download_url = chunk_url + "&offset=" + str(offset)
18 download_url = download_url + extraArgs
19
20 print "Downloading: " + download_url
21 download_url_handle = urllib.urlopen(download_url)
22
23 json_data = download_url_handle.read()
24
25 try:
26 data = json.loads(json_data)
27 print " Status: " + data[u"headers"][u"status"]
28
29 except:
30 print "Warning: failed to process Offset = " + str(offset) + " (chunk = " + str(chunk_count) + ")"
31 data = null
32
33 return data
Note: See TracBrowser for help on using the repository browser.