Mercurial > hg > hybrid-music-recommender-using-content-based-and-social-information
view Code/preview_clip.py @ 10:cc503565339e
Downloading a preview mp3 subset from 7digital
author | Paulo Chiliguano <p.e.chiliguano@se14.qmul.ac.uk> |
---|---|
date | Wed, 15 Jul 2015 19:25:16 +0100 |
parents | |
children | 38f44dd7e54b |
line wrap: on
line source
# -*- coding: utf-8 -*- """ Created on Wed Jul 15 00:41:44 2015 @author: paulochiliguano """ import csv import time from pyechonest import song, config config.ECHO_NEST_API_KEY="LINDFDUTQZQ781IE8" with open('/homes/pchilguano/dataset/test_echonest.txt', 'rb') as input, open('/homes/pchilguano/dataset/test_echonest_url.txt', 'wb') as output: writer = csv.writer(output, delimiter=',') #for i in xrange(1412): # input.readline() next = input.readline() while next != "": try: s = song.Song(next[:-2]) except IndexError: time.sleep(3) next = input.readline() else: time.sleep(3) ss_tracks = s.get_tracks('7digital-UK') time.sleep(3) #print(len(ss_tracks)) if len(ss_tracks) != 0: ss_track = ss_tracks[0] preview_url = ss_track.get('preview_url') print([next[:-2], preview_url]) writer.writerow([next[:-2], preview_url]) next = input.readline()