27. Download OrgasmSoundLibrary data#

This is part of the orgasm sound classification problem.

Where is the data?

The data is acquired from https://orgasmsoundlibrary.com/#gallery

The API is here: https://orgasmsoundlibrary.com/data/bijoux.json

28. Get API#

import json
import requests
API_PATH = "https://orgasmsoundlibrary.com/data/bijoux.json"
req = requests.get(API_PATH)
req_json = req.json()
with open("data/bijoux.json", "w") as fp:
    json.dump(req_json, fp)

29. Download Audio#

BASE_URL = "https://orgasmsoundlibrary.com/"
req_json_org = req_json.get('Orgasmos')
def download_file(url):
    audio_file_name = url.split('/')[-1]
    audio_url_req = requests.get(url)
    audio_url_req = audio_url_req

    with open('data/audio/'+audio_file_name, 'wb') as f:
        f.write(audio_url_req.content)
        
    print('\r', f'Downloaded audio from {audio_file_name}', end='')
flag = 0

for record in req_json_org:
    record_audio_url = BASE_URL + record.get('audio').strip()
    if record_audio_url:
        download_file(record_audio_url)
        flag += 1
    else:
        print('No url found for record: {}'.format( record.get('id') ) )
    print('\r', 'Downloaded',flag, end='')
    
 Downloaded 1097o from 5uxP52MW90YeC3rUMNyRcLbFDsjRM3kp.mp3