Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Lamere plamere

View GitHub Profile
View gist:8976417
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 Apr 14, 2014
Example of uploading a track to the Echo Nest for analysis without ENIOS
View TrackUploadSample.m
- (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 Aug 29, 2015
Get Spotify images for the artists that are similar to weezer
View spotify_echonest_example
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 Aug 29, 2015
parses outside lands lineup and generates a json of artists along with Spotify, Echo Nest and Rdio IDs
View parse.py
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 Aug 3, 2014
iterating through artists with spotipy to get the top tracks
View gist:e41f5a163566dddbeba4
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 Jun 20, 2015
An example of using PBL to create a cynical radio station where every 4th song is by Sia or Katy Perry
View cynical_radio.py
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
Example of creating an Echo Nest Personal Catalog from a directory of MP3s
View catalog_sample.py
#!/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 Jan 11, 2012
Top hotttest Twitter artists
View TopTwitter.html
<!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 Jan 12, 2012
Demo of of Echo Nest playlist generation with variety and distribution
View PlaylistWithDistribution.html
!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 Apr 9, 2012
Example of detailed Echo Nest analysis
View analysis.json
{
"bars": [
{
"confidence": 0.451,
"duration": 1.64692,
"start": 0.7151
},
{
"confidence": 0.32,
"duration": 1.64778,