-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathget_sounds.py
48 lines (41 loc) · 1.48 KB
/
get_sounds.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
# This file is part of PyBOSSA.
#
# PyBOSSA is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyBOSSA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with PyBOSSA. If not, see <http://www.gnu.org/licenses/>.
import soundcloud
import config
import json
def get_soundcloud_clips():
"""
Gets public soundcloud clips
"""
client = soundcloud.Client(client_id=config.client_id)
#tracks = client.get('/tracks', tags='hip-hop, pop, rock', license='cc-by-sa')
tracks = client.get('/tracks', tags='hip-hop, pop, rock')
tasks = []
n = 0
for t in tracks:
if n < 10:
e = client.get('/oembed', url=t.permalink_url)
task_info = {'question': 'Is this a hip-hop song?', 'embed': e.html}
tasks.append(dict(info=task_info))
n = n + 1
else:
break
return tasks
if __name__ == '__main__':
file = open('soundcloud_tasks.json', 'w')
clips = get_soundcloud_clips()
file.write(json.dumps(clips))
file.close()