{ "metadata": { "name": "Databases" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "The GTZAN dataset" ] }, { "cell_type": "code", "collapsed": false, "input": [ "gtzan_root = '../GTZAN'" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "import glob\n", "glob.glob(gtzan_root + '/genres/*')" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 2, "text": [ "['../GTZAN/genres/metal',\n", " '../GTZAN/genres/reggae',\n", " '../GTZAN/genres/rock',\n", " '../GTZAN/genres/disco',\n", " '../GTZAN/genres/country',\n", " '../GTZAN/genres/blues',\n", " '../GTZAN/genres/jazz',\n", " '../GTZAN/genres/pop',\n", " '../GTZAN/genres/classical',\n", " '../GTZAN/genres/hiphop']" ] } ], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "genres = [genre[genre.rindex('/') + 1:] for genre in glob.glob(gtzan_root + '/genres/*')]" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "genres" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 4, "text": [ "['metal',\n", " 'reggae',\n", " 'rock',\n", " 'disco',\n", " 'country',\n", " 'blues',\n", " 'jazz',\n", " 'pop',\n", " 'classical',\n", " 'hiphop']" ] } ], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "gtzan_files = dict()\n", "\n", "for genre in genres:\n", " gtzan_files[genre] = glob.glob(gtzan_root + '/genres/' + genre + '/*.au')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ "from essentia.streaming import *" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 6 }, { "cell_type": "code", "collapsed": false, "input": [ "sr = 22050\n", "frameSize = 1024\n", "hopSize = 512" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 7 }, { "cell_type": "code", "collapsed": false, "input": [ "loader = MonoLoader(sampleRate=sr)\n", "frameCutter = FrameCutter(frameSize = frameSize, hopSize = hopSize)\n", "w = Windowing(type = 'hann')\n", "spec = Spectrum()\n", "centroid = Centroid()\n", "rolloff = RollOff()\n", "flux = Flux()\n", "zcr = ZeroCrossingRate()\n", "rms = RMS()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 20 }, { "cell_type": "code", "collapsed": false, "input": [ "# Texture windows\n", "textureTime = 1.0 # seconds\n", "textureSize = int(textureTime * sr/float(hopSize))\n", "textureWindowCutters = []\n", "textureWindowMeans = []\n", "textureWindowVars = []\n", "\n", "for i in range(5):\n", " textureWindowCutters.append(FrameCutter(frameSize = textureSize, hopSize = textureSize))\n", " textureWindowMeans.append(Mean())\n", " textureWindowVars.append(Variance())\n", " \n", "pool = essentia.Pool()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 21 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now connect the graph:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "loader.audio >> frameCutter.signal\n", "frameCutter.frame >> w.frame >> spec.frame\n", "spec.spectrum >> centroid.array\n", "spec.spectrum >> rolloff.spectrum\n", "spec.spectrum >> flux.spectrum\n", "\n", "frameCutter.frame >> zcr.signal\n", "frameCutter.frame >> rms.array\n", "\n", "# We won't store the individual features in the pool\n", "#centroid.centroid >> (pool, 'lowlevel.centroid')\n", "#rolloff.rollOff >> (pool, 'lowlevel.rolloff')\n", "#flux.flux >> (pool, 'lowlevel.flux')\n", "#zcr.zeroCrossingRate >> (pool, 'lowlevel.zcr')\n", "#rms.rms >> (pool, 'lowlevel.rms')" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 22, "text": [ "" ] } ], "prompt_number": 22 }, { "cell_type": "markdown", "metadata": {}, "source": [ "And insert the texture windows:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# We will keep the testure windows\n", "centroid.centroid >> textureWindowCutters[0].signal\n", "rolloff.rollOff >> textureWindowCutters[1].signal\n", "flux.flux >> textureWindowCutters[2].signal\n", "zcr.zeroCrossingRate >> textureWindowCutters[3].signal\n", "rms.rms >> textureWindowCutters[4].signal\n", "\n", "features = ['lowlevel.centroid', 'lowlevel.rolloff', 'lowlevel.flux', 'lowlevel.zcr', 'lowlevel.rms']\n", "\n", "for i in range(5):\n", " textureWindowCutters[i].frame >> textureWindowMeans[i].array\n", " textureWindowCutters[i].frame >> textureWindowVars[i].array\n", "# textureWindowMeans[i].mean >> (pool, '%s_mean'%features[i])\n", "# textureWindowVars[i].variance >> (pool, '%s_var'%features[i])" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 23 }, { "cell_type": "code", "collapsed": false, "input": [ "gtzan_files.keys()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 24, "text": [ "['reggae',\n", " 'classical',\n", " 'country',\n", " 'jazz',\n", " 'metal',\n", " 'pop',\n", " 'disco',\n", " 'hiphop',\n", " 'rock',\n", " 'blues']" ] } ], "prompt_number": 24 }, { "cell_type": "code", "collapsed": false, "input": [ "gtzan_features = dict()\n", "\n", "feature_pools = []\n", "\n", "pool = essentia.Pool()\n", "#for genre in gtzan_files.keys():\n", "genre = 'metal'\n", "\n", "for audiofile in gtzan_files[genre][:10]:\n", " loader.configure(filename = audiofile)\n", "\n", " pool = essentia.Pool()\n", " for i in range(5):\n", " textureWindowMeans[i].mean >> (pool, '%s_mean'%features[i])\n", " textureWindowVars[i].variance >> (pool, '%s_var'%features[i])\n", " \n", " essentia.run(loader)\n", " feature_pools.append(pool)\n", " \n", " for i in range(5):\n", " textureWindowMeans[i].mean.disconnect( (pool, '%s_mean'%features[i]) )\n", " textureWindowVars[i].variance.disconnect( (pool, '%s_mean'%features[i]) )\n", " " ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 25 }, { "cell_type": "code", "collapsed": false, "input": [ "len(feature_pools)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 26, "text": [ "10" ] } ], "prompt_number": 26 }, { "cell_type": "code", "collapsed": false, "input": [ "pool1 = feature_pools[1]" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 27 }, { "cell_type": "code", "collapsed": false, "input": [ "pool1.containsKey('lowlevel.centroid_mean')" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 33, "text": [ "True" ] } ], "prompt_number": 33 }, { "cell_type": "code", "collapsed": false, "input": [ "pool1['lowlevel.centroid_mean']" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 34, "text": [ "array([ 0.12349304, 0.12603827, 0.12369274, 0.12796623, 0.12545626,\n", " 0.12588733, 0.12907386, 0.12259493, 0.12012523, 0.12449955,\n", " 0.12821124, 0.12822448, 0.12692975, 0.12749869, 0.12953703,\n", " 0.07763326, 0.12349304, 0.12603827, 0.12369274, 0.12796623,\n", " 0.12545626, 0.12588733, 0.12907386, 0.12259493, 0.12012523,\n", " 0.12449955, 0.12821124, 0.12822448, 0.12692975, 0.12749869,\n", " 0.12953703, 0.07763326, 0.12349304, 0.12603827, 0.12369274,\n", " 0.12796623, 0.12545626, 0.12588733, 0.12907386, 0.12259493,\n", " 0.12012523, 0.12449955, 0.12821124, 0.12822448, 0.12692975,\n", " 0.12749869, 0.12953703, 0.07763326, 0.08938374, 0.09283585,\n", " 0.0810305 , 0.07962823, 0.10627975, 0.08838628, 0.0812446 ,\n", " 0.07591175, 0.09368064, 0.0791645 , 0.07838911, 0.07688246,\n", " 0.09608771, 0.08181662, 0.0803022 , 0.0789201 , 0.09823932,\n", " 0.09202421, 0.08374907, 0.07282116, 0.08969576, 0.08655645,\n", " 0.09912755, 0.08663792, 0.08775774, 0.07895733, 0.11164059,\n", " 0.08674042, 0.08723493, 0.08756376, 0.07958999, 0.08260456,\n", " 0.07709543, 0.08702885, 0.13156229, 0.11765064, 0.08720219,\n", " 0.0796233 , 0.07631919, 0.07384487, 0.08006869, 0.07127871,\n", " 0.06470564, 0.07387184, 0.08057489, 0.10077029, 0.08958122,\n", " 0.08490527, 0.07346863, 0.10786097, 0.09761067, 0.10034223,\n", " 0.07842575, 0.07795314, 0.09386371, 0.08901539, 0.12124291,\n", " 0.08587018, 0.0993743 , 0.06416983], dtype=float32)" ] } ], "prompt_number": 34 }, { "cell_type": "code", "collapsed": false, "input": [ "len(pool1['lowlevel.centroid_mean'])" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 35, "text": [ "108" ] } ], "prompt_number": 35 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Echo nest Database" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "http://echonest.com/\n", "\n", "From: http://echonest.com/jobs/ :\n", "\n", "\"We\u2019ve built the biggest database about music in the world -- 34 million songs, almost 2.4 million artists, with detailed information on each down to the pitch of every note in a guitar solo. And we\u2019ve done it with off-the-shelf mostly open source technologies such as Solr, Tokyo Tyrant, RabbitMQ and Python combined with the brainpower of a few dissertations, algorithms and hard work over the past few years.\"\n", "\n", "* https://lucene.apache.org/solr/\n", "* http://fallabs.com/tokyotyrant/\n", "* https://www.rabbitmq.com/\n", "\n", "Amazon EC2\n", "Tornado\n", "Python, Lua, svn\n", "\n", "What they do:\n", "\n", "http://the.echonest.com/solutions/\n", "\n", "Their API:\n", "\n", "* https://developer.echonest.com/\n", "* http://developer.echonest.com/docs/v4\n", "\n", "Read their license carefully, in particular:\n", "\n", "Don't: (ii) crawl, spider, index or in any way store information obtained from the APIs (except ephemeral copies in a cache pursuant to industry norms)\n", "\n", "You can do all the web calls yourself, or you can use:\n", "https://github.com/echonest/pyechonest\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from keys import mykey" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 36 }, { "cell_type": "code", "collapsed": false, "input": [ "from pyechonest import config\n", "config.ECHO_NEST_API_KEY=mykey" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 37 }, { "cell_type": "markdown", "metadata": {}, "source": [ "http://developer.echonest.com/api/v4/artist/hotttnesss?api_key=FILDTEOIK2HBORODV&name=lady+gaga&format=json" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import json" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 38 }, { "cell_type": "code", "collapsed": false, "input": [ "json.loads('{\"response\": {\"status\": {\"version\": \"4.2\", \"code\": 0, \"message\": \"Success\"}, \"artist\": {\"hotttnesss\": 0.941778, \"id\": \"ARX6TAQ11C8A415850\", \"name\": \"Lady Gaga\"}}}')" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 39, "text": [ "{u'response': {u'artist': {u'hotttnesss': 0.941778,\n", " u'id': u'ARX6TAQ11C8A415850',\n", " u'name': u'Lady Gaga'},\n", " u'status': {u'code': 0, u'message': u'Success', u'version': u'4.2'}}}" ] } ], "prompt_number": 39 }, { "cell_type": "markdown", "metadata": {}, "source": [ "https://developer.echonest.com/raw_tutorials/responses.html" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from pyechonest import track" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 40 }, { "cell_type": "code", "collapsed": false, "input": [ "ls /home/andres/Music/Messiaen/Turangalila\\ Symphonie" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "06 AudioTrack 06.mp3 08 AudioTrack 08.mp3\r\n" ] } ], "prompt_number": 41 }, { "cell_type": "code", "collapsed": false, "input": [ "track_info = track.track_from_filename('/home/andres/Music/Messiaen/Turangalila Symphonie/08 AudioTrack 08.mp3')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 42 }, { "cell_type": "code", "collapsed": false, "input": [ "track_info" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 43, "text": [ "" ] } ], "prompt_number": 43 }, { "cell_type": "code", "collapsed": false, "input": [ "dir(track_info)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 44, "text": [ "['__class__',\n", " '__delattr__',\n", " '__dict__',\n", " '__doc__',\n", " '__format__',\n", " '__getattribute__',\n", " '__hash__',\n", " '__init__',\n", " '__module__',\n", " '__new__',\n", " '__reduce__',\n", " '__reduce_ex__',\n", " '__repr__',\n", " '__setattr__',\n", " '__sizeof__',\n", " '__str__',\n", " '__subclasshook__',\n", " '__weakref__',\n", " '_object_type',\n", " u'acousticness',\n", " 'analysis_url',\n", " u'analyzer_version',\n", " u'artist',\n", " u'artist_id',\n", " u'audio_md5',\n", " u'bitrate',\n", " 'cache',\n", " u'danceability',\n", " u'duration',\n", " u'energy',\n", " 'get_analysis',\n", " 'get_attribute',\n", " 'id',\n", " u'key',\n", " u'liveness',\n", " u'loudness',\n", " 'md5',\n", " u'mode',\n", " 'post_attribute',\n", " u'release',\n", " u'samplerate',\n", " u'song_id',\n", " u'speechiness',\n", " u'status',\n", " u'tempo',\n", " u'time_signature',\n", " u'title',\n", " u'valence']" ] } ], "prompt_number": 44 }, { "cell_type": "code", "collapsed": false, "input": [ "track_info.analysis_url" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 45, "text": [ "u'http://echonest-analysis.s3.amazonaws.com/TR/TRIQQNI14499DEC798/3/full.json?AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1394225367&Signature=oyOku5O%2Bb5mWj5oyT1DPsv0gsAo%3D'" ] } ], "prompt_number": 45 }, { "cell_type": "code", "collapsed": false, "input": [ "import urllib2\n", "import json\n", "\n", "response = urllib2.urlopen(track_info.analysis_url)\n", "data = json.load(response)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 46 }, { "cell_type": "code", "collapsed": false, "input": [ "data.keys()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 47, "text": [ "[u'bars', u'track', u'segments', u'beats', u'meta', u'sections', u'tatums']" ] } ], "prompt_number": 47 }, { "cell_type": "code", "collapsed": false, "input": [ "data['track'].keys()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 48, "text": [ "[u'mode_confidence',\n", " u'end_of_fade_in',\n", " u'key_confidence',\n", " u'synchstring',\n", " u'synch_version',\n", " u'duration',\n", " u'rhythm_version',\n", " u'rhythmstring',\n", " u'echoprintstring',\n", " u'sample_md5',\n", " u'time_signature_confidence',\n", " u'echoprint_version',\n", " u'start_of_fade_out',\n", " u'analysis_sample_rate',\n", " u'analysis_channels',\n", " u'tempo',\n", " u'offset_seconds',\n", " u'tempo_confidence',\n", " u'key',\n", " u'decoder',\n", " u'code_version',\n", " u'window_seconds',\n", " u'codestring',\n", " u'mode',\n", " u'time_signature',\n", " u'num_samples',\n", " u'loudness',\n", " u'decoder_version']" ] } ], "prompt_number": 48 }, { "cell_type": "code", "collapsed": false, "input": [ "analysis = track_info.get_analysis()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 49 }, { "cell_type": "code", "collapsed": false, "input": [ "type(analysis) # Not working?" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 50, "text": [ "NoneType" ] } ], "prompt_number": 50 }, { "cell_type": "code", "collapsed": false, "input": [ "from pyechonest import song" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 52 }, { "cell_type": "markdown", "metadata": {}, "source": [ "http://developer.echonest.com/docs/v4/song.html" ] }, { "cell_type": "code", "collapsed": false, "input": [ "results = song.search(artist=\"Led Zeppelin\", title='Rock and Roll', results=3, buckets=['audio_summary'])" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 53 }, { "cell_type": "code", "collapsed": false, "input": [ "results" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 54, "text": [ "[,\n", " ,\n", " ]" ] } ], "prompt_number": 54 }, { "cell_type": "code", "collapsed": false, "input": [ "version1 = results[0]" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 55 }, { "cell_type": "code", "collapsed": false, "input": [ "version1" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 56, "text": [ "" ] } ], "prompt_number": 56 }, { "cell_type": "code", "collapsed": false, "input": [ "dir(version1)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 57, "text": [ "['__class__',\n", " '__delattr__',\n", " '__dict__',\n", " '__doc__',\n", " '__format__',\n", " '__getattribute__',\n", " '__hash__',\n", " '__init__',\n", " '__module__',\n", " '__new__',\n", " '__reduce__',\n", " '__reduce_ex__',\n", " '__repr__',\n", " '__setattr__',\n", " '__sizeof__',\n", " '__str__',\n", " '__subclasshook__',\n", " '__weakref__',\n", " '_object_type',\n", " 'artist_familiarity',\n", " 'artist_hotttnesss',\n", " 'artist_id',\n", " 'artist_location',\n", " 'artist_name',\n", " 'audio_summary',\n", " 'cache',\n", " 'get_artist_familiarity',\n", " 'get_artist_hotttnesss',\n", " 'get_artist_location',\n", " 'get_attribute',\n", " 'get_audio_summary',\n", " 'get_foreign_id',\n", " 'get_song_currency',\n", " 'get_song_discovery',\n", " 'get_song_hotttnesss',\n", " 'get_song_type',\n", " 'get_tracks',\n", " 'id',\n", " 'post_attribute',\n", " 'song_currency',\n", " 'song_discovery',\n", " 'song_hotttnesss',\n", " 'song_type',\n", " 'title']" ] } ], "prompt_number": 57 }, { "cell_type": "code", "collapsed": false, "input": [ "for v in results:\n", " print v.song_hotttnesss," ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "0.681588 " ] }, { "output_type": "stream", "stream": "stdout", "text": [ "0.681588 " ] }, { "output_type": "stream", "stream": "stdout", "text": [ "0.681588\n" ] } ], "prompt_number": 59 }, { "cell_type": "code", "collapsed": false, "input": [ "version1.audio_summary" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 60, "text": [ "{u'acousticness': 0.000527,\n", " u'analysis_url': u'http://echonest-analysis.s3.amazonaws.com/TR/QG3fkwxmTF3idAnKRE6Te14zFFVdDnRdKilzVQIrxJQ7wr1p8bjgTdPt5zqqRSbrSRgy3ZAmJTRLROGhg%3D/3/full.json?AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1394225642&Signature=97nqfqSJMz1VIy1hKODajbbNIqE%3D',\n", " u'audio_md5': u'58882547724329387e8e72e025b3ed00',\n", " u'danceability': 0.32473,\n", " u'duration': 219.79955,\n", " u'energy': 0.892717,\n", " u'key': 9,\n", " u'liveness': 0.106599,\n", " u'loudness': -7.432,\n", " u'mode': 1,\n", " u'speechiness': 0.037498,\n", " u'tempo': 169.22,\n", " u'time_signature': 4,\n", " u'valence': 0.90403}" ] } ], "prompt_number": 60 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "7digital" ] }, { "cell_type": "code", "collapsed": false, "input": [ "f = urllib2.urlopen(\"http://api.7digital.com/1.2/track/preview?trackid={0}&oauth_consumer_key={1}\".format(7digital_id,key)) \n", "fh = open('./test.mp3', 'wb')\n", "fh.write(f.read())\n", "\n", "fh.close()\n", "\n", "f.close()" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Other client libraries:\n", "\n", "http://developer.echonest.com/client_libraries.html" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ " Million song dataset" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "http://labrosa.ee.columbia.edu/millionsong/\n", "\n", "From echonest, but downloadable for offline usage.\n", "\n", "http://www.infochimps.com/collections/million-songs\n", "\n", "Data for songs:\n", "\n", "http://labrosa.ee.columbia.edu/millionsong/pages/example-track-description\n", "\n", "Some existing code to work with the MSDB:\n", "\n", "https://github.com/tbertinmahieux/MSongsDB" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "MusicBrainz.org" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "http://musicbrainz.org/\n", "\n", "Python API:\n", "\n", "https://musicbrainz.org/doc/python-musicbrainz2\n", "\n", "However: *Status: Deprecated as of May 2011. This library is not compatible with the current MusicBrainz schema, but will still work with older versions and with the ws/1 legacy web service.*\n", "\n", "You can actually add to this database!\n", "\n", "Includes cover art.\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# from http://bugs.musicbrainz.org/browser/python-musicbrainz2/trunk/examples/getartist.py\n", "import sys\n", "import logging\n", "import musicbrainz2.webservice as ws\n", "import musicbrainz2.model as m\n", "\n", "logging.basicConfig()\n", "logger = logging.getLogger()\n", "logger.setLevel(logging.DEBUG)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 61 }, { "cell_type": "markdown", "metadata": {}, "source": [ "https://musicbrainz.org/doc/MusicBrainz_Identifier" ] }, { "cell_type": "code", "collapsed": false, "input": [ "artist_id = ''" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 62 }, { "cell_type": "markdown", "metadata": {}, "source": [ "http://users.musicbrainz.org/~matt/python-musicbrainz2/html/" ] }, { "cell_type": "code", "collapsed": false, "input": [ "q = ws.Query()\n", "\n", "try:\n", "\t# The result should include all official albums.\n", "\t#\n", "\tinc = ws.ArtistIncludes(\n", "\t\treleases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM),\n", "\t\ttags=True, releaseGroups=True)\n", "\tartist = q.getArtistById(artist_id, inc)\n", "except ws.WebServiceError, e:\n", "\tprint 'Error:', e\n", "\tsys.exit(1)\n", "\n", "\n", "print \"Id :\", artist.id\n", "print \"Name :\", artist.name\n", "print \"SortName :\", artist.sortName\n", "print \"UniqueName :\", artist.getUniqueName()\n", "print \"Type :\", artist.type\n", "print \"BeginDate :\", artist.beginDate\n", "print \"EndDate :\", artist.endDate\n", "print \"Tags :\", ', '.join([t.value for t in artist.tags])\n", "print" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": [ "DEBUG::GET http://musicbrainz.org/ws/1/artist/?type=xml&inc=sa-Official+tags+sa-Album+release-groups\n" ] }, { "output_type": "stream", "stream": "stderr", "text": [ "DEBUG::GET failed: HTTP Error 400: Bad Request\n" ] }, { "ename": "SystemExit", "evalue": "1", "output_type": "pyerr", "traceback": [ "An exception has occurred, use %tb to see the full traceback.\n", "\u001b[0;31mSystemExit\u001b[0m\u001b[0;31m:\u001b[0m 1\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "Error: HTTP Error 400: Bad Request\n" ] }, { "output_type": "stream", "stream": "stderr", "text": [ "To exit: use 'exit', 'quit', or Ctrl-D." ] } ], "prompt_number": 63 }, { "cell_type": "code", "collapsed": false, "input": [ "if len(artist.getReleases()) == 0:\n", "\tprint \"No releases found.\"\n", "else:\n", "\tprint \"Releases:\"\n", "\n", "for release in artist.getReleases():\n", "\tprint\n", "\tprint \"Id :\", release.id\n", "\tprint \"Title :\", release.title\n", "\tprint \"ASIN :\", release.asin\n", "\tprint \"Text :\", release.textLanguage, '/', release.textScript\n", "\tprint \"Types :\", release.types" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'artist' is not defined", "output_type": "pyerr", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0martist\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetReleases\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0;34m\"No releases found.\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0;34m\"Releases:\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mNameError\u001b[0m: name 'artist' is not defined" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "if len(artist.getReleaseGroups()) == 0:\n", "\tprint\n", "\tprint \"No release groups found.\"\n", "else:\n", "\tprint\n", "\tprint \"Release groups:\"\n", "\n", "for rg in artist.getReleaseGroups():\n", "\tprint\n", "\tprint \"Id :\", rg.id\n", "\tprint \"Title :\", rg.title\n", "\tprint \"Type :\", rg.type\n", "\n", "print\n", "\n", "#\n", "# Using the release IDs and Query.getReleaseById(), you could now request \n", "# those releases, including the tracks, release events, the associated\n", "# DiscIDs, and more. The 'getrelease.py' example shows how this works.\n", "#\n", "\n", "# EOF" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "7digital" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "http://developer.7digital.com/our-api-glance" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Other services" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Look at the services supported by echonest. Also:\n", "\n", "http://developer.jamendo.com/v3.0\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "http://magnatune.com/info/api" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Last.fm" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "http://www.last.fm/api" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import pylast\n", "\n", "#At http://code.google.com/p/pylast/" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "from keys import lastfm_api_key, lastfm_api_secret, lastfm_username, lastfm_password\n", "\n", "# You have to have your own unique two values for API_KEY and API_SECRET\n", "# Obtain yours from http://www.last.fm/api/account for Last.fm\n", "\n", "API_KEY = lastfm_api_key\n", "API_SECRET = lastfm_api_secret\n", "\n", "# In order to perform a write operation you need to authenticate yourself\n", "username = lastfm_username\n", "password_hash = pylast.md5(lastfm_password)\n", "\n", "network = pylast.LastFMNetwork(api_key = API_KEY, api_secret = \n", " API_SECRET, username = username, password_hash = password_hash)\n", "\n", "# now you can use that object every where\n", "artist = network.get_artist(\"The Beatles\")\n", "#artist.shout(\"<3\")\n", "\n", "track = network.get_track(\"Iron Maiden\", \"The Nomad\")\n", "#track.love()\n", "#track.add_tags((\"awesome\", \"favorite\"))\n", "\n", "# type help(pylast.LastFMNetwork) or help(pylast) in a python interpreter to get more help\n", "# about anything and see examples of how it works" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "artist.get_listener_count()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 11, "text": [ "3192937" ] } ], "prompt_number": 11 }, { "cell_type": "code", "collapsed": false, "input": [ "albums = artist.get_top_albums()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 13 }, { "cell_type": "code", "collapsed": false, "input": [ "help(albums[0])" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Help on TopItem in module pylast object:\n", "\n", "class TopItem(__builtin__.tuple)\n", " | TopItem(item, weight)\n", " | \n", " | Method resolution order:\n", " | TopItem\n", " | __builtin__.tuple\n", " | __builtin__.object\n", " | \n", " | Methods defined here:\n", " | \n", " | __getnewargs__(self)\n", " | Return self as a plain tuple. Used by copy and pickle.\n", " | \n", " | __repr__(self)\n", " | Return a nicely formatted representation string\n", " | \n", " | _asdict(self)\n", " | Return a new OrderedDict which maps field names to their values\n", " | \n", " | _replace(_self, **kwds)\n", " | Return a new TopItem object replacing specified fields with new values\n", " | \n", " | ----------------------------------------------------------------------\n", " | Class methods defined here:\n", " | \n", " | _make(cls, iterable, new=, len=) from __builtin__.type\n", " | Make a new TopItem object from a sequence or iterable\n", " | \n", " | ----------------------------------------------------------------------\n", " | Static methods defined here:\n", " | \n", " | __new__(_cls, item, weight)\n", " | Create new instance of TopItem(item, weight)\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data descriptors defined here:\n", " | \n", " | __dict__\n", " | Return a new OrderedDict which maps field names to their values\n", " | \n", " | item\n", " | Alias for field number 0\n", " | \n", " | weight\n", " | Alias for field number 1\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data and other attributes defined here:\n", " | \n", " | _fields = ('item', 'weight')\n", " | \n", " | ----------------------------------------------------------------------\n", " | Methods inherited from __builtin__.tuple:\n", " | \n", " | __add__(...)\n", " | x.__add__(y) <==> x+y\n", " | \n", " | __contains__(...)\n", " | x.__contains__(y) <==> y in x\n", " | \n", " | __eq__(...)\n", " | x.__eq__(y) <==> x==y\n", " | \n", " | __ge__(...)\n", " | x.__ge__(y) <==> x>=y\n", " | \n", " | __getattribute__(...)\n", " | x.__getattribute__('name') <==> x.name\n", " | \n", " | __getitem__(...)\n", " | x.__getitem__(y) <==> x[y]\n", " | \n", " | __getslice__(...)\n", " | x.__getslice__(i, j) <==> x[i:j]\n", " | \n", " | Use of negative indices is not supported.\n", " | \n", " | __gt__(...)\n", " | x.__gt__(y) <==> x>y\n", " | \n", " | __hash__(...)\n", " | x.__hash__() <==> hash(x)\n", " | \n", " | __iter__(...)\n", " | x.__iter__() <==> iter(x)\n", " | \n", " | __le__(...)\n", " | x.__le__(y) <==> x<=y\n", " | \n", " | __len__(...)\n", " | x.__len__() <==> len(x)\n", " | \n", " | __lt__(...)\n", " | x.__lt__(y) <==> x x*n\n", " | \n", " | __ne__(...)\n", " | x.__ne__(y) <==> x!=y\n", " | \n", " | __rmul__(...)\n", " | x.__rmul__(n) <==> n*x\n", " | \n", " | __sizeof__(...)\n", " | T.__sizeof__() -- size of T in memory, in bytes\n", " | \n", " | count(...)\n", " | T.count(value) -> integer -- return number of occurrences of value\n", " | \n", " | index(...)\n", " | T.index(value, [start, [stop]]) -> integer -- return first index of value.\n", " | Raises ValueError if the value is not present.\n", "\n" ] } ], "prompt_number": 17 }, { "cell_type": "code", "collapsed": false, "input": [ "help(albums[0].item)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Help on Album in module pylast object:\n", "\n", "class Album(_BaseObject, _Taggable)\n", " | An album.\n", " | \n", " | Method resolution order:\n", " | Album\n", " | _BaseObject\n", " | _Taggable\n", " | __builtin__.object\n", " | \n", " | Methods defined here:\n", " | \n", " | __eq__(self, other)\n", " | \n", " | __init__(self, artist, title, network)\n", " | Create an album instance.\n", " | # Parameters:\n", " | * artist: An artist name or an Artist object.\n", " | * title: The album title.\n", " | \n", " | __ne__(self, other)\n", " | \n", " | __repr__(self)\n", " | \n", " | __str__ = r(*args)\n", " | \n", " | get_artist(self)\n", " | Returns the associated Artist object.\n", " | \n", " | get_cover_image(self, size=3)\n", " | Returns a uri to the cover image\n", " | size can be one of:\n", " | COVER_EXTRA_LARGE\n", " | COVER_LARGE\n", " | COVER_MEDIUM\n", " | COVER_SMALL\n", " | \n", " | get_id(self)\n", " | Returns the ID\n", " | \n", " | get_listener_count(self)\n", " | Returns the number of liteners on the network\n", " | \n", " | get_mbid(self)\n", " | Returns the MusicBrainz id of the album.\n", " | \n", " | get_name(self)\n", " | Returns the album title (alias to Album.get_title).\n", " | \n", " | get_playcount(self)\n", " | Returns the number of plays on the network\n", " | \n", " | get_release_date(self)\n", " | Retruns the release date of the album.\n", " | \n", " | get_title(self)\n", " | Returns the album title.\n", " | \n", " | get_top_tags(self, limit=None)\n", " | Returns a list of the most-applied tags to this album.\n", " | \n", " | get_tracks(self)\n", " | Returns the list of Tracks on this album.\n", " | \n", " | get_url(self, domain_name=0)\n", " | Returns the url of the album page on the network. \n", " | # Parameters:\n", " | * domain_name str: The network's language domain. Possible values:\n", " | o DOMAIN_ENGLISH\n", " | o DOMAIN_GERMAN\n", " | o DOMAIN_SPANISH\n", " | o DOMAIN_FRENCH\n", " | o DOMAIN_ITALIAN\n", " | o DOMAIN_POLISH\n", " | o DOMAIN_PORTUGUESE\n", " | o DOMAIN_SWEDISH\n", " | o DOMAIN_TURKISH\n", " | o DOMAIN_RUSSIAN\n", " | o DOMAIN_JAPANESE\n", " | o DOMAIN_CHINESE\n", " | \n", " | get_wiki_content(self)\n", " | Returns the content of the wiki.\n", " | \n", " | get_wiki_published_date(self)\n", " | Returns the date of publishing this version of the wiki.\n", " | \n", " | get_wiki_summary(self)\n", " | Returns the summary of the wiki.\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data and other attributes defined here:\n", " | \n", " | artist = None\n", " | \n", " | title = None\n", " | \n", " | ----------------------------------------------------------------------\n", " | Methods inherited from _BaseObject:\n", " | \n", " | __hash__(self)\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data descriptors inherited from _BaseObject:\n", " | \n", " | __dict__\n", " | dictionary for instance variables (if defined)\n", " | \n", " | __weakref__\n", " | list of weak references to the object (if defined)\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data and other attributes inherited from _BaseObject:\n", " | \n", " | network = None\n", " | \n", " | ----------------------------------------------------------------------\n", " | Methods inherited from _Taggable:\n", " | \n", " | add_tag(self, tag)\n", " | Adds one tag.\n", " | * tag: a tag name or a Tag object.\n", " | \n", " | add_tags(self, tags)\n", " | Adds one or several tags.\n", " | * tags: A sequence of tag names or Tag objects.\n", " | \n", " | clear_tags(self)\n", " | Clears all the user-set tags.\n", " | \n", " | get_tags(self)\n", " | Returns a list of the tags set by the user to this object.\n", " | \n", " | remove_tag(self, tag)\n", " | Remove a user's tag from this object.\n", " | \n", " | remove_tags(self, tags)\n", " | Removes one or several tags from this object.\n", " | * tags: a sequence of tag names or Tag objects.\n", " | \n", " | set_tags(self, tags)\n", " | Sets this object's tags to only those tags.\n", " | * tags: a sequence of tag names or Tag objects.\n", "\n" ] } ], "prompt_number": 19 }, { "cell_type": "code", "collapsed": false, "input": [ "for album in albums:\n", " print album.item.get_title() + ', ', " ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Abbey Road, Revolver, Sgt. Pepper's Lonely Hearts Club Band, Rubber Soul, Magical Mystery Tour, Let It Be, Help!, Please Please Me, A Hard Day's Night, With The Beatles, Beatles for Sale, Yellow Submarine, Love, The Beatles, The Beatles (The White Album), The Beatles 1, Let It Be... Naked, The White Album, Past Masters, Vol. 2, 1962-1966, Hey Jude, Anthology 1, Anthology 2, Past Masters, Vol. 1, Anthology 3, 1967-1970, Live at the BBC, The Alternate Abbey Road, The Beatles (The White Album) (disc 1), In The Beginning, Love Songs, The Beatles (The White Album) (disc 2), The Decca Tapes, Live at the BBC (disc 1), Live at the BBC (disc 2), 1967-1970 (disc 1), The Beatles (disc 1), White Album (Disc 1), Free as a Bird, Yellow Submarine Songtrack, Anthology 1 (disc 1), Anthology 3 (disc 1), Get Back, Meet the Beatles, Anthology 3 (disc 2), Beatles VI, Anthology 2 (disc 1), Anthology 1 (disc 2), Love Me Do, Anthology 2 (disc 2), \n" ] } ], "prompt_number": 35 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or you can get things yourself as XML or json" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import urllib2\n", "import json\n", "\n", "artist = 'The Beatles'\n", "ret_format = 'json'\n", "\n", "query_url = 'http://ws.audioscrobbler.com/2.0/?method=artist.getTags&artist=%s&user=%s&api_key=%s&format=json' % (artist, lastfm_username, lastfm_api_key)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 28 }, { "cell_type": "code", "collapsed": false, "input": [ "response = urllib2.urlopen(query_url)\n", "data = json.load(response)" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "BadStatusLine", "evalue": "''", "output_type": "pyerr", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mBadStatusLine\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mresponse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0murllib2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0murlopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mquery_url\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mjson\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresponse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/lib/python2.7/urllib2.pyc\u001b[0m in \u001b[0;36murlopen\u001b[0;34m(url, data, timeout)\u001b[0m\n\u001b[1;32m 125\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0m_opener\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 126\u001b[0m \u001b[0m_opener\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbuild_opener\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 127\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_opener\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 128\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 129\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0minstall_opener\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mopener\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/lib/python2.7/urllib2.pyc\u001b[0m in \u001b[0;36mopen\u001b[0;34m(self, fullurl, data, timeout)\u001b[0m\n\u001b[1;32m 402\u001b[0m \u001b[0mreq\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmeth\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mreq\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 403\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 404\u001b[0;31m \u001b[0mresponse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_open\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mreq\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 405\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 406\u001b[0m \u001b[0;31m# post-process response\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/lib/python2.7/urllib2.pyc\u001b[0m in \u001b[0;36m_open\u001b[0;34m(self, req, data)\u001b[0m\n\u001b[1;32m 420\u001b[0m \u001b[0mprotocol\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mreq\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_type\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 421\u001b[0m result = self._call_chain(self.handle_open, protocol, protocol +\n\u001b[0;32m--> 422\u001b[0;31m '_open', req)\n\u001b[0m\u001b[1;32m 423\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 424\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/lib/python2.7/urllib2.pyc\u001b[0m in \u001b[0;36m_call_chain\u001b[0;34m(self, chain, kind, meth_name, *args)\u001b[0m\n\u001b[1;32m 380\u001b[0m \u001b[0mfunc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhandler\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmeth_name\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 381\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 382\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 383\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mresult\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 384\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/lib/python2.7/urllib2.pyc\u001b[0m in \u001b[0;36mhttp_open\u001b[0;34m(self, req)\u001b[0m\n\u001b[1;32m 1212\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1213\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mhttp_open\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreq\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1214\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdo_open\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhttplib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mHTTPConnection\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreq\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1215\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1216\u001b[0m \u001b[0mhttp_request\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mAbstractHTTPHandler\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdo_request_\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/lib/python2.7/urllib2.pyc\u001b[0m in \u001b[0;36mdo_open\u001b[0;34m(self, http_class, req)\u001b[0m\n\u001b[1;32m 1185\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1186\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1187\u001b[0;31m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mh\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetresponse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbuffering\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1188\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# buffering kw not supported\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1189\u001b[0m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mh\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetresponse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/lib/python2.7/httplib.pyc\u001b[0m in \u001b[0;36mgetresponse\u001b[0;34m(self, buffering)\u001b[0m\n\u001b[1;32m 1043\u001b[0m \u001b[0mresponse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mresponse_class\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1044\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1045\u001b[0;31m \u001b[0mresponse\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbegin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1046\u001b[0m \u001b[0;32massert\u001b[0m \u001b[0mresponse\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwill_close\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0m_UNKNOWN\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1047\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__state\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_CS_IDLE\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/lib/python2.7/httplib.pyc\u001b[0m in \u001b[0;36mbegin\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 407\u001b[0m \u001b[0;31m# read until we get a non-100 response\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 408\u001b[0m \u001b[0;32mwhile\u001b[0m \u001b[0mTrue\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 409\u001b[0;31m \u001b[0mversion\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstatus\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreason\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_read_status\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 410\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mstatus\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0mCONTINUE\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 411\u001b[0m \u001b[0;32mbreak\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/lib/python2.7/httplib.pyc\u001b[0m in \u001b[0;36m_read_status\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 371\u001b[0m \u001b[0;31m# Presumably, the server closed the connection before\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 372\u001b[0m \u001b[0;31m# sending a valid response.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 373\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mBadStatusLine\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 374\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 375\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mversion\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstatus\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreason\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msplit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mBadStatusLine\u001b[0m: ''" ] } ], "prompt_number": 29 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Hmm... what's wrong?" ] }, { "cell_type": "code", "collapsed": false, "input": [ "artist_enc = urllib2.quote(artist)\n", "artist_enc" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 32, "text": [ "'The%20Beatles'" ] } ], "prompt_number": 32 }, { "cell_type": "code", "collapsed": false, "input": [ "query_url = 'http://ws.audioscrobbler.com/2.0/?method=artist.getTags&artist=%s&user=%s&api_key=%s&format=json' % (artist_enc, lastfm_username, lastfm_api_key)\n", "response = urllib2.urlopen(query_url)\n", "data = json.load(response)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 34 }, { "cell_type": "code", "collapsed": false, "input": [ "data" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 37, "text": [ "{u'tags': {u'#text': u'\\n', u'artist': u'The Beatles'}}" ] } ], "prompt_number": 37 }, { "cell_type": "code", "collapsed": false, "input": [ "artist = 'Lady Gaga'\n", "artist_enc = urllib2.quote(artist)\n", "artist_enc\n", "query_url = 'http://ws.audioscrobbler.com/2.0/?method=artist.getTags&artist=%s&user=%s&api_key=%s&format=json' % (artist_enc, lastfm_username, lastfm_api_key)\n", "response = urllib2.urlopen(query_url)\n", "data = json.load(response)\n", "data" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 39, "text": [ "{u'tags': {u'#text': u'\\n', u'artist': u'Lady Gaga'}}" ] } ], "prompt_number": 39 }, { "cell_type": "code", "collapsed": false, "input": [ "artist = 'The Beatles'\n", "artist_enc = urllib2.quote(artist)\n", "artist_enc\n", "query_url = 'http://ws.audioscrobbler.com/2.0/?method=artist.getTopTags&artist=%s&user=%s&api_key=%s&format=json' % (artist_enc, lastfm_username, lastfm_api_key)\n", "response = urllib2.urlopen(query_url)\n", "data = json.load(response)\n", "data" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 41, "text": [ "{u'toptags': {u'@attr': {u'artist': u'The Beatles'},\n", " u'tag': [{u'count': u'100',\n", " u'name': u'classic rock',\n", " u'url': u'http://www.last.fm/tag/classic%20rock'},\n", " {u'count': u'71', u'name': u'rock', u'url': u'http://www.last.fm/tag/rock'},\n", " {u'count': u'57',\n", " u'name': u'british',\n", " u'url': u'http://www.last.fm/tag/british'},\n", " {u'count': u'54', u'name': u'60s', u'url': u'http://www.last.fm/tag/60s'},\n", " {u'count': u'40', u'name': u'pop', u'url': u'http://www.last.fm/tag/pop'},\n", " {u'count': u'12',\n", " u'name': u'psychedelic',\n", " u'url': u'http://www.last.fm/tag/psychedelic'},\n", " {u'count': u'10',\n", " u'name': u'The Beatles',\n", " u'url': u'http://www.last.fm/tag/the%20beatles'},\n", " {u'count': u'10',\n", " u'name': u'oldies',\n", " u'url': u'http://www.last.fm/tag/oldies'},\n", " {u'count': u'5',\n", " u'name': u'beatles',\n", " u'url': u'http://www.last.fm/tag/beatles'},\n", " {u'count': u'5',\n", " u'name': u'Psychedelic Rock',\n", " u'url': u'http://www.last.fm/tag/psychedelic%20rock'},\n", " {u'count': u'4',\n", " u'name': u'british invasion',\n", " u'url': u'http://www.last.fm/tag/british%20invasion'},\n", " {u'count': u'3',\n", " u'name': u'alternative',\n", " u'url': u'http://www.last.fm/tag/alternative'},\n", " {u'count': u'3',\n", " u'name': u'britpop',\n", " u'url': u'http://www.last.fm/tag/britpop'},\n", " {u'count': u'3',\n", " u'name': u'Rock and Roll',\n", " u'url': u'http://www.last.fm/tag/rock%20and%20roll'},\n", " {u'count': u'3',\n", " u'name': u'pop rock',\n", " u'url': u'http://www.last.fm/tag/pop%20rock'},\n", " {u'count': u'3',\n", " u'name': u'classic',\n", " u'url': u'http://www.last.fm/tag/classic'},\n", " {u'count': u'2', u'name': u'70s', u'url': u'http://www.last.fm/tag/70s'},\n", " {u'count': u'2',\n", " u'name': u'indie',\n", " u'url': u'http://www.last.fm/tag/indie'},\n", " {u'count': u'2', u'name': u'UK', u'url': u'http://www.last.fm/tag/uk'},\n", " {u'count': u'2',\n", " u'name': u'rock n roll',\n", " u'url': u'http://www.last.fm/tag/rock%20n%20roll'},\n", " {u'count': u'2',\n", " u'name': u'legend',\n", " u'url': u'http://www.last.fm/tag/legend'},\n", " {u'count': u'1',\n", " u'name': u'liverpool',\n", " u'url': u'http://www.last.fm/tag/liverpool'},\n", " {u'count': u'1',\n", " u'name': u'favorites',\n", " u'url': u'http://www.last.fm/tag/favorites'},\n", " {u'count': u'1',\n", " u'name': u'experimental',\n", " u'url': u'http://www.last.fm/tag/experimental'},\n", " {u'count': u'1',\n", " u'name': u'male vocalists',\n", " u'url': u'http://www.last.fm/tag/male%20vocalists'},\n", " {u'count': u'1',\n", " u'name': u'singer-songwriter',\n", " u'url': u'http://www.last.fm/tag/singer-songwriter'},\n", " {u'count': u'1',\n", " u'name': u'Progressive rock',\n", " u'url': u'http://www.last.fm/tag/progressive%20rock'},\n", " {u'count': u'1', u'name': u'beat', u'url': u'http://www.last.fm/tag/beat'},\n", " {u'count': u'1',\n", " u'name': u'john lennon',\n", " u'url': u'http://www.last.fm/tag/john%20lennon'},\n", " {u'count': u'1', u'name': u'Love', u'url': u'http://www.last.fm/tag/love'},\n", " {u'count': u'1',\n", " u'name': u\"60's\",\n", " u'url': u'http://www.last.fm/tag/60%27s'},\n", " {u'count': u'1',\n", " u'name': u'indie rock',\n", " u'url': u'http://www.last.fm/tag/indie%20rock'},\n", " {u'count': u'1',\n", " u'name': u'jecks',\n", " u'url': u'http://www.last.fm/tag/jecks'},\n", " {u'count': u'1',\n", " u'name': u'english',\n", " u'url': u'http://www.last.fm/tag/english'},\n", " {u'count': u'1',\n", " u'name': u'Awesome',\n", " u'url': u'http://www.last.fm/tag/awesome'},\n", " {u'count': u'1', u'name': u'folk', u'url': u'http://www.last.fm/tag/folk'},\n", " {u'count': u'1',\n", " u'name': u'genius',\n", " u'url': u'http://www.last.fm/tag/genius'},\n", " {u'count': u'0',\n", " u'name': u'paul mccartney',\n", " u'url': u'http://www.last.fm/tag/paul%20mccartney'},\n", " {u'count': u'0',\n", " u'name': u'groovy',\n", " u'url': u'http://www.last.fm/tag/groovy'},\n", " {u'count': u'0',\n", " u'name': u'alternative rock',\n", " u'url': u'http://www.last.fm/tag/alternative%20rock'},\n", " {u'count': u'0',\n", " u'name': u'george harrison',\n", " u'url': u'http://www.last.fm/tag/george%20harrison'},\n", " {u'count': u'0',\n", " u'name': u'acoustic',\n", " u'url': u'http://www.last.fm/tag/acoustic'},\n", " {u'count': u'0', u'name': u'soul', u'url': u'http://www.last.fm/tag/soul'},\n", " {u'count': u'0',\n", " u'name': u'england',\n", " u'url': u'http://www.last.fm/tag/england'},\n", " {u'count': u'0',\n", " u'name': u'Favorite',\n", " u'url': u'http://www.last.fm/tag/favorite'},\n", " {u'count': u'0',\n", " u'name': u\"rock'n'roll\",\n", " u'url': u'http://www.last.fm/tag/rock%27n%27roll'},\n", " {u'count': u'0',\n", " u'name': u'psychedelic pop',\n", " u'url': u'http://www.last.fm/tag/psychedelic%20pop'},\n", " {u'count': u'0',\n", " u'name': u'merseybeat',\n", " u'url': u'http://www.last.fm/tag/merseybeat'},\n", " {u'count': u'0',\n", " u'name': u'Best Band EVER',\n", " u'url': u'http://www.last.fm/tag/best%20band%20ever'},\n", " {u'count': u'0', u'name': u'funk', u'url': u'http://www.last.fm/tag/funk'},\n", " {u'count': u'0',\n", " u'name': u'hard rock',\n", " u'url': u'http://www.last.fm/tag/hard%20rock'},\n", " {u'count': u'0', u'name': u'jazz', u'url': u'http://www.last.fm/tag/jazz'},\n", " {u'count': u'0',\n", " u'name': u'british rock',\n", " u'url': u'http://www.last.fm/tag/british%20rock'},\n", " {u'count': u'0',\n", " u'name': u'Pop-Rock',\n", " u'url': u'http://www.last.fm/tag/pop-rock'},\n", " {u'count': u'0',\n", " u'name': u'legends',\n", " u'url': u'http://www.last.fm/tag/legends'},\n", " {u'count': u'0',\n", " u'name': u'ringo starr',\n", " u'url': u'http://www.last.fm/tag/ringo%20starr'},\n", " {u'count': u'0',\n", " u'name': u'blues',\n", " u'url': u'http://www.last.fm/tag/blues'},\n", " {u'count': u'0',\n", " u'name': u'funky',\n", " u'url': u'http://www.last.fm/tag/funky'},\n", " {u'count': u'0',\n", " u'name': u'overrated',\n", " u'url': u'http://www.last.fm/tag/overrated'},\n", " {u'count': u'0',\n", " u'name': u'folk rock',\n", " u'url': u'http://www.last.fm/tag/folk%20rock'},\n", " {u'count': u'0',\n", " u'name': u'British Psychedelia',\n", " u'url': u'http://www.last.fm/tag/british%20psychedelia'},\n", " {u'count': u'0',\n", " u'name': u'classics',\n", " u'url': u'http://www.last.fm/tag/classics'},\n", " {u'count': u'0',\n", " u'name': u'Favorite Artists',\n", " u'url': u'http://www.last.fm/tag/favorite%20artists'},\n", " {u'count': u'0',\n", " u'name': u'classic pop',\n", " u'url': u'http://www.last.fm/tag/classic%20pop'},\n", " {u'count': u'0',\n", " u'name': u'Favourites',\n", " u'url': u'http://www.last.fm/tag/favourites'},\n", " {u'count': u'0',\n", " u'name': u'the best',\n", " u'url': u'http://www.last.fm/tag/the%20best'},\n", " {u'count': u'0',\n", " u'name': u'metal',\n", " u'url': u'http://www.last.fm/tag/metal'},\n", " {u'count': u'0',\n", " u'name': u'rock & roll',\n", " u'url': u'http://www.last.fm/tag/rock%2B%2526%2Broll'},\n", " {u'count': u'0',\n", " u'name': u'amazing',\n", " u'url': u'http://www.last.fm/tag/amazing'},\n", " {u'count': u'0',\n", " u'name': u'1960s',\n", " u'url': u'http://www.last.fm/tag/1960s'},\n", " {u'count': u'0', u'name': u'emo', u'url': u'http://www.last.fm/tag/emo'},\n", " {u'count': u'0',\n", " u'name': u'Pop/Rock',\n", " u'url': u'http://www.last.fm/tag/pop%252Frock'},\n", " {u'count': u'0',\n", " u'name': u'electronic',\n", " u'url': u'http://www.last.fm/tag/electronic'},\n", " {u'count': u'0',\n", " u'name': u'favourite',\n", " u'url': u'http://www.last.fm/tag/favourite'},\n", " {u'count': u'0',\n", " u'name': u'Progressive',\n", " u'url': u'http://www.last.fm/tag/progressive'},\n", " {u'count': u'0', u'name': u'80s', u'url': u'http://www.last.fm/tag/80s'},\n", " {u'count': u'0',\n", " u'name': u'instrumental',\n", " u'url': u'http://www.last.fm/tag/instrumental'},\n", " {u'count': u'0', u'name': u'punk', u'url': u'http://www.last.fm/tag/punk'},\n", " {u'count': u'0',\n", " u'name': u'folk-rock',\n", " u'url': u'http://www.last.fm/tag/folk-rock'},\n", " {u'count': u'0',\n", " u'name': u'brit pop',\n", " u'url': u'http://www.last.fm/tag/brit%20pop'},\n", " {u'count': u'0',\n", " u'name': u'sixties',\n", " u'url': u'http://www.last.fm/tag/sixties'},\n", " {u'count': u'0',\n", " u'name': u'soft rock',\n", " u'url': u'http://www.last.fm/tag/soft%20rock'},\n", " {u'count': u'0', u'name': u'fun', u'url': u'http://www.last.fm/tag/fun'},\n", " {u'count': u'0',\n", " u'name': u'influential',\n", " u'url': u'http://www.last.fm/tag/influential'},\n", " {u'count': u'0',\n", " u'name': u'60s rock',\n", " u'url': u'http://www.last.fm/tag/60s%20rock'},\n", " {u'count': u'0',\n", " u'name': u'rock-n-roll',\n", " u'url': u'http://www.last.fm/tag/rock-n-roll'},\n", " {u'count': u'0', u'name': u'best', u'url': u'http://www.last.fm/tag/best'},\n", " {u'count': u'0',\n", " u'name': u'art rock',\n", " u'url': u'http://www.last.fm/tag/art%20rock'},\n", " {u'count': u'0',\n", " u'name': u'guitar',\n", " u'url': u'http://www.last.fm/tag/guitar'},\n", " {u'count': u'0',\n", " u'name': u'power pop',\n", " u'url': u'http://www.last.fm/tag/power%20pop'},\n", " {u'count': u'0',\n", " u'name': u'good music',\n", " u'url': u'http://www.last.fm/tag/good%20music'},\n", " {u'count': u'0',\n", " u'name': u'indie pop',\n", " u'url': u'http://www.last.fm/tag/indie%20pop'},\n", " {u'count': u'0',\n", " u'name': u'baroque pop',\n", " u'url': u'http://www.last.fm/tag/baroque%20pop'},\n", " {u'count': u'0',\n", " u'name': u'great',\n", " u'url': u'http://www.last.fm/tag/great'},\n", " {u'count': u'0',\n", " u'name': u'happy',\n", " u'url': u'http://www.last.fm/tag/happy'},\n", " {u'count': u'0',\n", " u'name': u'chillout',\n", " u'url': u'http://www.last.fm/tag/chillout'},\n", " {u'count': u'0',\n", " u'name': u'Favorite Bands',\n", " u'url': u'http://www.last.fm/tag/favorite%20bands'},\n", " {u'count': u'0',\n", " u'name': u'brit rock',\n", " u'url': u'http://www.last.fm/tag/brit%20rock'},\n", " {u'count': u'0',\n", " u'name': u'Britrock',\n", " u'url': u'http://www.last.fm/tag/britrock'},\n", " {u'count': u'0',\n", " u'name': u'band',\n", " u'url': u'http://www.last.fm/tag/band'}]}}" ] } ], "prompt_number": 41 }, { "cell_type": "code", "collapsed": false, "input": [ "for tag in data['toptags']['tag']:\n", " print tag" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "{u'count': u'100', u'url': u'http://www.last.fm/tag/classic%20rock', u'name': u'classic rock'}\n", "{u'count': u'71', u'url': u'http://www.last.fm/tag/rock', u'name': u'rock'}\n", "{u'count': u'57', u'url': u'http://www.last.fm/tag/british', u'name': u'british'}\n", "{u'count': u'54', u'url': u'http://www.last.fm/tag/60s', u'name': u'60s'}\n", "{u'count': u'40', u'url': u'http://www.last.fm/tag/pop', u'name': u'pop'}\n", "{u'count': u'12', u'url': u'http://www.last.fm/tag/psychedelic', u'name': u'psychedelic'}\n", "{u'count': u'10', u'url': u'http://www.last.fm/tag/the%20beatles', u'name': u'The Beatles'}\n", "{u'count': u'10', u'url': u'http://www.last.fm/tag/oldies', u'name': u'oldies'}\n", "{u'count': u'5', u'url': u'http://www.last.fm/tag/beatles', u'name': u'beatles'}\n", "{u'count': u'5', u'url': u'http://www.last.fm/tag/psychedelic%20rock', u'name': u'Psychedelic Rock'}\n", "{u'count': u'4', u'url': u'http://www.last.fm/tag/british%20invasion', u'name': u'british invasion'}\n", "{u'count': u'3', u'url': u'http://www.last.fm/tag/alternative', u'name': u'alternative'}\n", "{u'count': u'3', u'url': u'http://www.last.fm/tag/britpop', u'name': u'britpop'}\n", "{u'count': u'3', u'url': u'http://www.last.fm/tag/rock%20and%20roll', u'name': u'Rock and Roll'}\n", "{u'count': u'3', u'url': u'http://www.last.fm/tag/pop%20rock', u'name': u'pop rock'}\n", "{u'count': u'3', u'url': u'http://www.last.fm/tag/classic', u'name': u'classic'}\n", "{u'count': u'2', u'url': u'http://www.last.fm/tag/70s', u'name': u'70s'}\n", "{u'count': u'2', u'url': u'http://www.last.fm/tag/indie', u'name': u'indie'}\n", "{u'count': u'2', u'url': u'http://www.last.fm/tag/uk', u'name': u'UK'}\n", "{u'count': u'2', u'url': u'http://www.last.fm/tag/rock%20n%20roll', u'name': u'rock n roll'}\n", "{u'count': u'2', u'url': u'http://www.last.fm/tag/legend', u'name': u'legend'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/liverpool', u'name': u'liverpool'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/favorites', u'name': u'favorites'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/experimental', u'name': u'experimental'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/male%20vocalists', u'name': u'male vocalists'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/singer-songwriter', u'name': u'singer-songwriter'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/progressive%20rock', u'name': u'Progressive rock'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/beat', u'name': u'beat'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/john%20lennon', u'name': u'john lennon'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/love', u'name': u'Love'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/60%27s', u'name': u\"60's\"}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/indie%20rock', u'name': u'indie rock'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/jecks', u'name': u'jecks'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/english', u'name': u'english'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/awesome', u'name': u'Awesome'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/folk', u'name': u'folk'}\n", "{u'count': u'1', u'url': u'http://www.last.fm/tag/genius', u'name': u'genius'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/paul%20mccartney', u'name': u'paul mccartney'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/groovy', u'name': u'groovy'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/alternative%20rock', u'name': u'alternative rock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/george%20harrison', u'name': u'george harrison'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/acoustic', u'name': u'acoustic'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/soul', u'name': u'soul'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/england', u'name': u'england'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/favorite', u'name': u'Favorite'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/rock%27n%27roll', u'name': u\"rock'n'roll\"}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/psychedelic%20pop', u'name': u'psychedelic pop'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/merseybeat', u'name': u'merseybeat'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/best%20band%20ever', u'name': u'Best Band EVER'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/funk', u'name': u'funk'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/hard%20rock', u'name': u'hard rock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/jazz', u'name': u'jazz'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/british%20rock', u'name': u'british rock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/pop-rock', u'name': u'Pop-Rock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/legends', u'name': u'legends'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/ringo%20starr', u'name': u'ringo starr'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/blues', u'name': u'blues'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/funky', u'name': u'funky'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/overrated', u'name': u'overrated'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/folk%20rock', u'name': u'folk rock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/british%20psychedelia', u'name': u'British Psychedelia'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/classics', u'name': u'classics'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/favorite%20artists', u'name': u'Favorite Artists'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/classic%20pop', u'name': u'classic pop'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/favourites', u'name': u'Favourites'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/the%20best', u'name': u'the best'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/metal', u'name': u'metal'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/rock%2B%2526%2Broll', u'name': u'rock & roll'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/amazing', u'name': u'amazing'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/1960s', u'name': u'1960s'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/emo', u'name': u'emo'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/pop%252Frock', u'name': u'Pop/Rock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/electronic', u'name': u'electronic'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/favourite', u'name': u'favourite'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/progressive', u'name': u'Progressive'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/80s', u'name': u'80s'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/instrumental', u'name': u'instrumental'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/punk', u'name': u'punk'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/folk-rock', u'name': u'folk-rock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/brit%20pop', u'name': u'brit pop'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/sixties', u'name': u'sixties'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/soft%20rock', u'name': u'soft rock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/fun', u'name': u'fun'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/influential', u'name': u'influential'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/60s%20rock', u'name': u'60s rock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/rock-n-roll', u'name': u'rock-n-roll'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/best', u'name': u'best'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/art%20rock', u'name': u'art rock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/guitar', u'name': u'guitar'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/power%20pop', u'name': u'power pop'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/good%20music', u'name': u'good music'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/indie%20pop', u'name': u'indie pop'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/baroque%20pop', u'name': u'baroque pop'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/great', u'name': u'great'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/happy', u'name': u'happy'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/chillout', u'name': u'chillout'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/favorite%20bands', u'name': u'Favorite Bands'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/brit%20rock', u'name': u'brit rock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/britrock', u'name': u'Britrock'}\n", "{u'count': u'0', u'url': u'http://www.last.fm/tag/band', u'name': u'band'}\n" ] } ], "prompt_number": 44 }, { "cell_type": "code", "collapsed": false, "input": [ "for tag in data['toptags']['tag']:\n", " print tag['name'], ':', int(tag['count'])" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "classic rock : 100\n", "rock : 71\n", "british : 57\n", "60s : 54\n", "pop : 40\n", "psychedelic : 12\n", "The Beatles : 10\n", "oldies : 10\n", "beatles : 5\n", "Psychedelic Rock : 5\n", "british invasion : 4\n", "alternative : 3\n", "britpop : 3\n", "Rock and Roll : 3\n", "pop rock : 3\n", "classic : 3\n", "70s : 2\n", "indie : 2\n", "UK : 2\n", "rock n roll : 2\n", "legend : 2\n", "liverpool : 1\n", "favorites : 1\n", "experimental : 1\n", "male vocalists : 1\n", "singer-songwriter : 1\n", "Progressive rock : 1\n", "beat : 1\n", "john lennon : 1\n", "Love : 1\n", "60's : 1\n", "indie rock : 1\n", "jecks : 1\n", "english : 1\n", "Awesome : 1\n", "folk : 1\n", "genius : 1\n", "paul mccartney : 0\n", "groovy : 0\n", "alternative rock : 0\n", "george harrison : 0\n", "acoustic : 0\n", "soul : 0\n", "england : 0\n", "Favorite : 0\n", "rock'n'roll : 0\n", "psychedelic pop : 0\n", "merseybeat : 0\n", "Best Band EVER : 0\n", "funk : 0\n", "hard rock : 0\n", "jazz : 0\n", "british rock : 0\n", "Pop-Rock : 0\n", "legends : 0\n", "ringo starr : 0\n", "blues : 0\n", "funky : 0\n", "overrated : 0\n", "folk rock : 0\n", "British Psychedelia : 0\n", "classics : 0\n", "Favorite Artists : 0\n", "classic pop : 0\n", "Favourites : 0\n", "the best : 0\n", "metal : 0\n", "rock & roll : 0\n", "amazing : 0\n", "1960s : 0\n", "emo : 0\n", "Pop/Rock : 0\n", "electronic : 0\n", "favourite : 0\n", "Progressive : 0\n", "80s : 0\n", "instrumental : 0\n", "punk : 0\n", "folk-rock : 0\n", "brit pop : 0\n", "sixties : 0\n", "soft rock : 0\n", "fun : 0\n", "influential : 0\n", "60s rock : 0\n", "rock-n-roll : 0\n", "best : 0\n", "art rock : 0\n", "guitar : 0\n", "power pop : 0\n", "good music : 0\n", "indie pop : 0\n", "baroque pop : 0\n", "great : 0\n", "happy : 0\n", "chillout : 0\n", "Favorite Bands : 0\n", "brit rock : 0\n", "Britrock : 0\n", "band : 0\n" ] } ], "prompt_number": 46 }, { "cell_type": "code", "collapsed": false, "input": [ "artist = 'The Beatles'\n", "artist_enc = urllib2.quote(artist)\n", "artist_enc\n", "query_url = 'http://ws.audioscrobbler.com/2.0/?method=artist.getTopTracks&artist=%s&user=%s&api_key=%s&format=json' % (artist_enc, lastfm_username, lastfm_api_key)\n", "response = urllib2.urlopen(query_url)\n", "data = json.load(response)\n", "#data" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 48 }, { "cell_type": "code", "collapsed": false, "input": [ "data.keys()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 49, "text": [ "[u'toptracks']" ] } ], "prompt_number": 49 }, { "cell_type": "code", "collapsed": false, "input": [ "data['toptracks'].keys()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 50, "text": [ "[u'track', u'@attr']" ] } ], "prompt_number": 50 }, { "cell_type": "code", "collapsed": false, "input": [ "len(data['toptracks']['track'])" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 52, "text": [ "50" ] } ], "prompt_number": 52 }, { "cell_type": "code", "collapsed": false, "input": [ "for track in data['toptracks']['track']:\n", " print \"'%s', \"%track['name']" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "'Come Together', \n", "'Here Comes the Sun', \n", "'Let It Be', \n", "'Yesterday', \n", "'Something', \n", "'Eleanor Rigby', \n", "'Help!', \n", "'Hey Jude', \n", "'Yellow Submarine', \n", "'All You Need Is Love', \n", "'Lucy in the Sky with Diamonds', \n", "'While My Guitar Gently Weeps', \n", "'Love Me Do', \n", "'Can't Buy Me Love', \n", "'A Day in the Life', \n", "'Strawberry Fields Forever', \n", "'Get Back', \n", "'A Hard Day's Night', \n", "'I Want to Hold Your Hand', \n", "'Blackbird', \n", "'Ticket to Ride', \n", "'Penny Lane', \n", "'Oh! Darling', \n", "'With a Little Help from My Friends', \n", "'In My Life', \n", "'Octopus's Garden', \n", "'Across the Universe', \n", "'Twist and Shout', \n", "'Because', \n", "'All My Loving', \n", "'Ob-La-Di, Ob-La-Da', \n", "'I Am the Walrus', \n", "'Drive My Car', \n", "'Golden Slumbers', \n", "'And I Love Her', \n", "'Eight Days a Week', \n", "'Girl', \n", "'Michelle', \n", "'She Loves You', \n", "'I Want You (She's So Heavy)', \n", "'Maxwell's Silver Hammer', \n", "'You Never Give Me Your Money', \n", "'I Saw Her Standing There', \n", "'Carry That Weight', \n", "'Happiness Is a Warm Gun', \n", "'I'm Only Sleeping', \n", "'Sgt. Pepper's Lonely Hearts Club Band', \n", "'Nowhere Man', \n", "'Taxman', \n", "'Dear Prudence', \n" ] } ], "prompt_number": 54 }, { "cell_type": "code", "collapsed": false, "input": [ "data['toptracks']['track'][0].keys()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 55, "text": [ "[u'streamable',\n", " u'@attr',\n", " u'name',\n", " u'artist',\n", " u'url',\n", " u'image',\n", " u'listeners',\n", " u'mbid',\n", " u'duration',\n", " u'playcount']" ] } ], "prompt_number": 55 }, { "cell_type": "markdown", "metadata": {}, "source": [ "No tags here, must fetch them" ] }, { "cell_type": "code", "collapsed": false, "input": [ "track_name = data['toptracks']['track'][0]['name']\n", "track_enc = urllib2.quote(track_name)\n", "query_url = 'http://ws.audioscrobbler.com/2.0/?method=track.getTopTags&track=%s&user=%s&api_key=%s&format=json' % (track_enc, lastfm_username, lastfm_api_key)\n", "response = urllib2.urlopen(query_url)\n", "tags_data = json.load(response)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 56 }, { "cell_type": "code", "collapsed": false, "input": [ "tags_data" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 57, "text": [ "{u'error': 6,\n", " u'links': [],\n", " u'message': u'You must supply either a track & artist name or a track mbid.'}" ] } ], "prompt_number": 57 }, { "cell_type": "code", "collapsed": false, "input": [ "track_name = data['toptracks']['track'][0]['name']\n", "track_enc = urllib2.quote(track_name)\n", "query_url = 'http://ws.audioscrobbler.com/2.0/?method=track.getTopTags&artist=%s&track=%s&user=%s&api_key=%s&format=json' % (artist_enc, track_enc, lastfm_username, lastfm_api_key)\n", "response = urllib2.urlopen(query_url)\n", "tags_data = json.load(response)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 58 }, { "cell_type": "code", "collapsed": false, "input": [ "tags_data" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "pyout", "prompt_number": 59, "text": [ "{u'toptags': {u'@attr': {u'artist': u'The Beatles',\n", " u'track': u'Come Together'},\n", " u'tag': [{u'count': u'100',\n", " u'name': u'classic rock',\n", " u'url': u'http://www.last.fm/tag/classic%20rock'},\n", " {u'count': u'66', u'name': u'rock', u'url': u'http://www.last.fm/tag/rock'},\n", " {u'count': u'63',\n", " u'name': u'The Beatles',\n", " u'url': u'http://www.last.fm/tag/the%20beatles'},\n", " {u'count': u'60', u'name': u'60s', u'url': u'http://www.last.fm/tag/60s'},\n", " {u'count': u'45',\n", " u'name': u'british',\n", " u'url': u'http://www.last.fm/tag/british'},\n", " {u'count': u'20', u'name': u'pop', u'url': u'http://www.last.fm/tag/pop'},\n", " {u'count': u'16',\n", " u'name': u'beatles',\n", " u'url': u'http://www.last.fm/tag/beatles'},\n", " {u'count': u'12',\n", " u'name': u'oldies',\n", " u'url': u'http://www.last.fm/tag/oldies'},\n", " {u'count': u'11',\n", " u'name': u'psychedelic',\n", " u'url': u'http://www.last.fm/tag/psychedelic'},\n", " {u'count': u'6',\n", " u'name': u'classic',\n", " u'url': u'http://www.last.fm/tag/classic'},\n", " {u'count': u'6',\n", " u'name': u'come together',\n", " u'url': u'http://www.last.fm/tag/come%20together'},\n", " {u'count': u'5',\n", " u'name': u'john lennon',\n", " u'url': u'http://www.last.fm/tag/john%20lennon'},\n", " {u'count': u'5',\n", " u'name': u'Rock and Roll',\n", " u'url': u'http://www.last.fm/tag/rock%20and%20roll'},\n", " {u'count': u'5',\n", " u'name': u'favorites',\n", " u'url': u'http://www.last.fm/tag/favorites'},\n", " {u'count': u'4', u'name': u'1969', u'url': u'http://www.last.fm/tag/1969'},\n", " {u'count': u'4',\n", " u'name': u'Psychedelic Rock',\n", " u'url': u'http://www.last.fm/tag/psychedelic%20rock'},\n", " {u'count': u'4',\n", " u'name': u'britpop',\n", " u'url': u'http://www.last.fm/tag/britpop'},\n", " {u'count': u'4',\n", " u'name': u'blues',\n", " u'url': u'http://www.last.fm/tag/blues'},\n", " {u'count': u'4',\n", " u'name': u'rock n roll',\n", " u'url': u'http://www.last.fm/tag/rock%20n%20roll'},\n", " {u'count': u'4',\n", " u'name': u'Abbey Road',\n", " u'url': u'http://www.last.fm/tag/abbey%20road'},\n", " {u'count': u'4',\n", " u'name': u'british invasion',\n", " u'url': u'http://www.last.fm/tag/british%20invasion'},\n", " {u'count': u'3',\n", " u'name': u'Awesome',\n", " u'url': u'http://www.last.fm/tag/awesome'},\n", " {u'count': u'3', u'name': u'cool', u'url': u'http://www.last.fm/tag/cool'},\n", " {u'count': u'3', u'name': u'UK', u'url': u'http://www.last.fm/tag/uk'},\n", " {u'count': u'2',\n", " u'name': u'chill',\n", " u'url': u'http://www.last.fm/tag/chill'},\n", " {u'count': u'2',\n", " u'name': u'best songs ever',\n", " u'url': u'http://www.last.fm/tag/best%20songs%20ever'},\n", " {u'count': u'2',\n", " u'name': u'favorite songs',\n", " u'url': u'http://www.last.fm/tag/favorite%20songs'},\n", " {u'count': u'2',\n", " u'name': u'experimental',\n", " u'url': u'http://www.last.fm/tag/experimental'},\n", " {u'count': u'2',\n", " u'name': u'Favorite',\n", " u'url': u'http://www.last.fm/tag/favorite'},\n", " {u'count': u'2', u'name': u'sexy', u'url': u'http://www.last.fm/tag/sexy'},\n", " {u'count': u'2',\n", " u'name': u'Mellow',\n", " u'url': u'http://www.last.fm/tag/mellow'},\n", " {u'count': u'1', u'name': u'70s', u'url': u'http://www.last.fm/tag/70s'},\n", " {u'count': u'1',\n", " u'name': u'groovy',\n", " u'url': u'http://www.last.fm/tag/groovy'},\n", " {u'count': u'1',\n", " u'name': u'classics',\n", " u'url': u'http://www.last.fm/tag/classics'},\n", " {u'count': u'1',\n", " u'name': u'hard rock',\n", " u'url': u'http://www.last.fm/tag/hard%20rock'},\n", " {u'count': u'1',\n", " u'name': u'male vocalists',\n", " u'url': u'http://www.last.fm/tag/male%20vocalists'},\n", " {u'count': u'1', u'name': u'Love', u'url': u'http://www.last.fm/tag/love'},\n", " {u'count': u'1', u'name': u'fip', u'url': u'http://www.last.fm/tag/fip'},\n", " {u'count': u'1',\n", " u'name': u'British Psychedelia',\n", " u'url': u'http://www.last.fm/tag/british%20psychedelia'},\n", " {u'count': u'1',\n", " u'name': u'pop rock',\n", " u'url': u'http://www.last.fm/tag/pop%20rock'},\n", " {u'count': u'1',\n", " u'name': u'blues rock',\n", " u'url': u'http://www.last.fm/tag/blues%20rock'},\n", " {u'count': u'1',\n", " u'name': u'legends',\n", " u'url': u'http://www.last.fm/tag/legends'},\n", " {u'count': u'1',\n", " u'name': u'guitar',\n", " u'url': u'http://www.last.fm/tag/guitar'},\n", " {u'count': u'1',\n", " u'name': u'paul mccartney',\n", " u'url': u'http://www.last.fm/tag/paul%20mccartney'},\n", " {u'count': u'1',\n", " u'name': u'timeless',\n", " u'url': u'http://www.last.fm/tag/timeless'},\n", " {u'count': u'1',\n", " u'name': u'Best Band EVER',\n", " u'url': u'http://www.last.fm/tag/best%20band%20ever'},\n", " {u'count': u'1',\n", " u'name': u'liverpool',\n", " u'url': u'http://www.last.fm/tag/liverpool'},\n", " {u'count': u'1',\n", " u'name': u'amazing',\n", " u'url': u'http://www.last.fm/tag/amazing'},\n", " {u'count': u'1',\n", " u'name': u'alternative',\n", " u'url': u'http://www.last.fm/tag/alternative'},\n", " {u'count': u'1',\n", " u'name': u'drums',\n", " u'url': u'http://www.last.fm/tag/drums'},\n", " {u'count': u'1',\n", " u'name': u'favourite',\n", " u'url': u'http://www.last.fm/tag/favourite'},\n", " {u'count': u'1',\n", " u'name': u'funky',\n", " u'url': u'http://www.last.fm/tag/funky'},\n", " {u'count': u'1',\n", " u'name': u'catchy',\n", " u'url': u'http://www.last.fm/tag/catchy'},\n", " {u'count': u'1',\n", " u'name': u'Favourites',\n", " u'url': u'http://www.last.fm/tag/favourites'},\n", " {u'count': u'1',\n", " u'name': u'Rolling Stone 500 Greatest Songs of All Time',\n", " u'url': u'http://www.last.fm/tag/rolling%20stone%20500%20greatest%20songs%20of%20all%20time'},\n", " {u'count': u'1', u'name': u'beat', u'url': u'http://www.last.fm/tag/beat'},\n", " {u'count': u'0',\n", " u'name': u'Favorite Artists',\n", " u'url': u'http://www.last.fm/tag/favorite%20artists'},\n", " {u'count': u'0',\n", " u'name': u'Rock Roll',\n", " u'url': u'http://www.last.fm/tag/rock%20%20roll'},\n", " {u'count': u'0',\n", " u'name': u\"60's\",\n", " u'url': u'http://www.last.fm/tag/60%27s'},\n", " {u'count': u'0',\n", " u'name': u'Porieux-loved',\n", " u'url': u'http://www.last.fm/tag/porieux-loved'},\n", " {u'count': u'0',\n", " u'name': u'Energetic',\n", " u'url': u'http://www.last.fm/tag/energetic'},\n", " {u'count': u'0',\n", " u'name': u'old school',\n", " u'url': u'http://www.last.fm/tag/old%20school'},\n", " {u'count': u'0',\n", " u'name': u'the best',\n", " u'url': u'http://www.last.fm/tag/the%20best'},\n", " {u'count': u'0',\n", " u'name': u'classic pop',\n", " u'url': u'http://www.last.fm/tag/classic%20pop'},\n", " {u'count': u'0',\n", " u'name': u'poprock',\n", " u'url': u'http://www.last.fm/tag/poprock'},\n", " {u'count': u'0',\n", " u'name': u'album rock',\n", " u'url': u'http://www.last.fm/tag/album%20rock'},\n", " {u'count': u'0',\n", " u'name': u'groove',\n", " u'url': u'http://www.last.fm/tag/groove'},\n", " {u'count': u'0',\n", " u'name': u'england',\n", " u'url': u'http://www.last.fm/tag/england'},\n", " {u'count': u'0',\n", " u'name': u'perfect',\n", " u'url': u'http://www.last.fm/tag/perfect'},\n", " {u'count': u'0', u'name': u'funk', u'url': u'http://www.last.fm/tag/funk'},\n", " {u'count': u'0',\n", " u'name': u'indie',\n", " u'url': u'http://www.last.fm/tag/indie'},\n", " {u'count': u'0',\n", " u'name': u'english',\n", " u'url': u'http://www.last.fm/tag/english'},\n", " {u'count': u'0',\n", " u'name': u'brit rock',\n", " u'url': u'http://www.last.fm/tag/brit%20rock'},\n", " {u'count': u'0',\n", " u'name': u'drugs',\n", " u'url': u'http://www.last.fm/tag/drugs'},\n", " {u'count': u'0',\n", " u'name': u'great lyrics',\n", " u'url': u'http://www.last.fm/tag/great%20lyrics'},\n", " {u'count': u'0',\n", " u'name': u'alternative rock',\n", " u'url': u'http://www.last.fm/tag/alternative%20rock'},\n", " {u'count': u'0',\n", " u'name': u'best song ever',\n", " u'url': u'http://www.last.fm/tag/best%20song%20ever'},\n", " {u'count': u'0',\n", " u'name': u'mpsvdloved',\n", " u'url': u'http://www.last.fm/tag/mpsvdloved'},\n", " {u'count': u'0',\n", " u'name': u'male vocalist',\n", " u'url': u'http://www.last.fm/tag/male%20vocalist'},\n", " {u'count': u'0',\n", " u'name': u'drug-influenced',\n", " u'url': u'http://www.last.fm/tag/drug-influenced'},\n", " {u'count': u'0',\n", " u'name': u'george harrison',\n", " u'url': u'http://www.last.fm/tag/george%20harrison'},\n", " {u'count': u'0',\n", " u'name': u'jecks',\n", " u'url': u'http://www.last.fm/tag/jecks'},\n", " {u'count': u'0',\n", " u'name': u'Let It Be',\n", " u'url': u'http://www.last.fm/tag/let%20it%20be'},\n", " {u'count': u'0',\n", " u'name': u'electric piano',\n", " u'url': u'http://www.last.fm/tag/electric%20piano'},\n", " {u'count': u'0',\n", " u'name': u'Masterpiece',\n", " u'url': u'http://www.last.fm/tag/masterpiece'},\n", " {u'count': u'0',\n", " u'name': u'Funk Rock',\n", " u'url': u'http://www.last.fm/tag/funk%20rock'},\n", " {u'count': u'0',\n", " u'name': u'9 of 10 stars',\n", " u'url': u'http://www.last.fm/tag/9%20of%2010%20stars'},\n", " {u'count': u'0', u'name': u'fun', u'url': u'http://www.last.fm/tag/fun'},\n", " {u'count': u'0',\n", " u'name': u'Makes Me Smile',\n", " u'url': u'http://www.last.fm/tag/makes%20me%20smile'},\n", " {u'count': u'0',\n", " u'name': u'1960s',\n", " u'url': u'http://www.last.fm/tag/1960s'},\n", " {u'count': u'0',\n", " u'name': u'sixties',\n", " u'url': u'http://www.last.fm/tag/sixties'},\n", " {u'count': u'0',\n", " u'name': u'Legendary',\n", " u'url': u'http://www.last.fm/tag/legendary'},\n", " {u'count': u'0',\n", " u'name': u'amayzes loved',\n", " u'url': u'http://www.last.fm/tag/amayzes%20loved'},\n", " {u'count': u'0',\n", " u'name': u'blues influences',\n", " u'url': u'http://www.last.fm/tag/blues%20influences'},\n", " {u'count': u'0',\n", " u'name': u'the word come',\n", " u'url': u'http://www.last.fm/tag/the%20word%20come'},\n", " {u'count': u'0',\n", " u'name': u'soft rock',\n", " u'url': u'http://www.last.fm/tag/soft%20rock'},\n", " {u'count': u'0',\n", " u'name': u'together',\n", " u'url': u'http://www.last.fm/tag/together'},\n", " {u'count': u'0',\n", " u'name': u'other',\n", " u'url': u'http://www.last.fm/tag/other'},\n", " {u'count': u'0', u'name': u'sing', u'url': u'http://www.last.fm/tag/sing'},\n", " {u'count': u'0',\n", " u'name': u'the word together',\n", " u'url': u'http://www.last.fm/tag/the%20word%20together'}]}}" ] } ], "prompt_number": 59 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Gracenote" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "https://developer.gracenote.com/web-api" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }