Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View plamere's full-sized avatar

Paul Lamere plamere

View GitHub Profile
Perhaps an analogy would help ... like comparing an API to a car dashboard.
The dashboard is the interface between the car and the human - it has all
the controls you need to make the car do its job. An API is like the
dashboard for a software system. It provides the interface for another
system (typically another computer) to get a system to do its job.
@plamere
plamere / TrackUploadSample.m
Created April 14, 2014 11:02
Example of uploading a track to the Echo Nest for analysis without ENIOS
- (void) uploadTrack: (Track *) track {
NSDictionary *params = @{
@"filetype" : @"m4a",
@"api_key" : self.apiKey,
};
NSFileManager *fm = [NSFileManager defaultManager];
NSURL *audioPath = [self pathToAudio:track];
NSString *path = [audioPath path];
NSData *data = [fm contentsAtPath:path];
@plamere
plamere / spotify_echonest_example
Last active August 29, 2015 14:02
Get Spotify images for the artists that are similar to weezer
import pyen
import spotipy
import sys
'''
get a set of images for artists that are similar to
the given seed artist
'''
en = pyen.Pyen()
@plamere
plamere / parse.py
Last active August 29, 2015 14:04
parses outside lands lineup and generates a json of artists along with Spotify, Echo Nest and Rdio IDs
import sys
from bs4 import BeautifulSoup
import json
import pyen
en = pyen.Pyen()
def get_fid(artist, idspace):
if 'foreign_ids' in artist and len(artist['foreign_ids']) > 0:
for fids in artist['foreign_ids']:
if fids['catalog'] == idspace:
@plamere
plamere / gist:e41f5a163566dddbeba4
Created August 3, 2014 16:27
iterating through artists with spotipy to get the top tracks
for start in xrange(0, 10000, page_size):
response = en.get('catalog/read', id=tpid, start=start,
results=page_size, bucket=['id:spotify'])
if len(response['catalog']['items']) == 0:
break
spaids = []
for item in response['catalog']['items']:
if 'artist_name' in item:
spid = item['request']['item_id']
@plamere
plamere / cynical_radio.py
Created June 20, 2015 09:50
An example of using PBL to create a cynical radio station where every 4th song is by Sia or Katy Perry
from pbl import *
gold = Concatenate([ArtistTopTracks('Sia'), ArtistTopTracks('Katy Perry')])
norm = PlaylistSource("Today's Top Hits")
radio = Alternate([norm, norm, norm, Shuffler(gold)])
radio = PlaylistSave(radio, 'cynical radio', 'plamere', max_size=40)
@plamere
plamere / catalog_sample.py
Created May 25, 2011 18:51
Example of creating an Echo Nest Personal Catalog from a directory of MP3s
#!/usr/bin/env python
# encoding: utf-8
"""
Copyright (c) 2010 The Echo Nest. All rights reserved.
Created by Tyler Williams on 2011-04-08
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
@plamere
plamere / TopTwitter.html
Created January 11, 2012 13:08
Top hotttest Twitter artists
<!DOCTYPE html>
<html>
<head>
<title>Top Twitter</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<link type="text/css" href="styles.css" rel="stylesheet" />
</head>
<body>
<h1 id='title'> Top 100 artists with verified Twitter accounts</h1>
<ol id="results"> </ol>
@plamere
plamere / PlaylistWithDistribution.html
Created January 12, 2012 13:45
Demo of of Echo Nest playlist generation with variety and distribution
!DOCTYPE html>
<html>
<head>
<title>Playlist Distribution Demo</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<link type="text/css" href="demo_styles.css" rel="stylesheet" />
</head>
<body>
@plamere
plamere / analysis.json
Created April 9, 2012 09:56
Example of detailed Echo Nest analysis
{
"bars": [
{
"confidence": 0.451,
"duration": 1.64692,
"start": 0.7151
},
{
"confidence": 0.32,
"duration": 1.64778,