Example #1
0
# setup app
app = Flask(__name__)
app.secret_key = os.environ.get('APP_SECRET')

# setup cache
cache = SimpleCache()

# setup rdio api vars
rdio_key = os.environ.get('RDIO_API_KEY')
rdio_secret = os.environ.get('RDIO_API_SECRET')
playback_token = None

# echonest data (will do requests on startup)
# Note: echonest api key should be setup as env variable
# and not in this file. Name should be ECHO_NEST_API_KEY
styles = artist.list_terms('style')
moods = artist.list_terms('mood')

def get_rdio_api():
  """ create user-specific or generic rdio api """
  token = session.get('at')
  secret = session.get('ats')
  if token and secret:
    api = Rdio((rdio_key, rdio_secret), (token, secret))
  else:
    api = Rdio((rdio_key, rdio_secret))
  return api

def get_playback_token():
  """ returns a playback token for the flash player """
  token = cache.get('playback_token')
Example #2
0
# setup app
app = Flask(__name__)
app.secret_key = os.environ.get("APP_SECRET")

# setup cache
cache = SimpleCache()

# setup rdio api vars
rdio_key = os.environ.get("RDIO_API_KEY")
rdio_secret = os.environ.get("RDIO_API_SECRET")
playback_token = None

# echonest data (will do requests on startup)
# Note: echonest api key should be setup as env variable
# and not in this file. Name should be ECHO_NEST_API_KEY
styles = artist.list_terms("style")
moods = artist.list_terms("mood")


def get_rdio_api():
    """ create user-specific or generic rdio api """
    token = session.get("at")
    secret = session.get("ats")
    if token and secret:
        api = Rdio((rdio_key, rdio_secret), (token, secret))
    else:
        api = Rdio((rdio_key, rdio_secret))
    return api


def get_playback_token():
Example #3
0
from pyechonest import song, artist


BUCKET = 'rdio-US'

app = Flask(__name__)
app.secret_key = os.environ.get('APP_SECRET')

cache = SimpleCache()

rdio_key = os.environ.get('RDIO_API_KEY')
rdio_secret = os.environ.get('RDIO_API_SECRET')
playback_token = None

styles = artist.list_terms('chris isaak)
moods = artist.list_terms('wicked game')

def get_rdio_api():

  token = session.get('at')
  secret = session.get('ats')
  if token and secret:
    api = Rdio((rdio_key, rdio_secret), (token, secret))
  else:
    api = Rdio((rdio_key, rdio_secret))
  return api

def get_playback_token():
  """ returns a playback token for the flash player """
  token = cache.get('playback_token')
  if token:
Example #4
0
#-*- coding: utf-8 -*-
import os
import random
import json

import requests
from pyechonest import config as econfig, artist as eartist

from sm.core.views import TemplateView, JSONView
from sm.utils import flatten_iterator


econfig.ECHO_NEST_API_KEY = os.environ.get('ECHO_NEXT_API_KEY', '')

moods = eartist.list_terms('mood')
styles = eartist.list_terms('style')


class Home(TemplateView):
    template_name = 'home.html'


class GetTracks(JSONView):

    def get_context_data(self, **kwargs):
        query = self.request.GET.get('query', '')
        parts = query.lower().split()
        artists, songs = [], []

        if any(p in moods for p in parts):
            for part in parts: