Mercurial > hg > hybrid-music-recommender-using-content-based-and-social-information
view Code/preview_mp3.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 |
line wrap: on
line source
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ import oauth2 as oauth import csv import time import webbrowser consumer_key = '7ds28qendsk9' consumer_secret = 'm5nsktn3hu6x45cy' consumer = oauth.Consumer(consumer_key, consumer_secret) with open('C:\Users\Paulo\Documents\Queen Mary\MSc Project\Dataset\echonest.txt', 'rb') as input: idreader = csv.reader(input) for row in idreader: request_url = row[1] req = oauth.Request(method="GET", url=request_url,is_form_encoded=True) req['oauth_timestamp'] = oauth.Request.make_timestamp() req['oauth_nonce'] = oauth.Request.make_nonce() req['country'] = "GB" sig_method = oauth.SignatureMethod_HMAC_SHA1() req.sign_request(sig_method, consumer, token=None) #print req.to_url() new = 2 # open in a new tab, if possible # open a public URL, in this case, the webbrowser docs webbrowser.open(req.to_url(),new=new) time.sleep(22)