Quantcast
Channel: The Echo Nest Developer Forum
Viewing all articles
Browse latest Browse all 1582

Get notified when a track analysis completes

$
0
0

Hi there,

Currently when I use track/upload with the audio_summary tag, I immediately receive a status='pending' response. But then I have to manually query with a loop with the returned Track ID to check when the audio_summary track analysis status changes from 'pending' to 'complete'.

I am using Python right now but I was wondering if there is any way to register a callback mechanism with EchoNest so that when the analysis completes, the callback code can handle the status change.

----Current code

def wait_for_analysis(t, echoid, check_track_suitability):
    while True:
        response = en.get('track/profile', id=echoid, bucket=['audio_summary'])
        if response['track']['status'] <> 'pending':
            break
        time.sleep(1)
    check_for_suitable_tracks(response['track']['audio_summary'].items(), t, check_track_suitability)

def analyze_sc_track(t, check_track_suitability):
    urlString = "https://api.soundcloud.com/tracks/" + str(t.id) + "/stream?consumer_key%xxxxxx"
    response = en.post('track/upload', url=urlString)
    echoid = response['track']['id']
    wait_for_analysis(t, echoid, check_track_suitability)

Let me know! Thanks.


Viewing all articles
Browse latest Browse all 1582

Trending Articles