view Code/preview_mp3.py @ 11:38f44dd7e54b

Creating subset from Taste Profile Retrieving mp3 from 7Digital Successfully Some error due to uniencode of Artist and Song metadata.
author Paulo Chiliguano <p.e.chiliguano@se14.qmul.ac.uk>
date Fri, 17 Jul 2015 21:52:18 +0100
parents cc503565339e
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)