<commit_before>
#!/usr/bin/env python
# coding=utf-8
#
# Copyright 2015 Arn-O. See the LICENSE file at the top-level directory of this
# distribution and at
# https://github.com/Arn-O/py-kodi-remote-controller/blob/master/LICENSE.

'''
Module of functions for echonest API management.
'''

import requests
import logging

#TODO: rename to tasteprofile in place of echonest
def echonest_favorite(api_key, profile_id, song_id):
    '''Make a song favorite in echonest tasteprofile'''
    logging.debug('call set_echonest_favorite')
    url = 'http://developer.echonest.com/api/v4/tasteprofile/favorite'
    payload = {"api_key": api_key,
              "id": profile_id,
              "item": str(song_id)
              }
    r = requests.get(url, params=payload)
    logging.debug('URL: %s', r.url)
    logging.debug('return: %s', r.text)

def echonest_skip(api_key, profile_id, song_id):
    '''Skip a song favorite in echonest taste profile'''
    logging.debug('call set_echonest_skip')
    url = 'http://developer.echonest.com/api/v4/tasteprofile/skip'
    payload = {"api_key": api_key,
              "id": profile_id,
              "item": str(song_id)
              }
    r = requests.get(url, params=payload)
    logging.debug('URL: %s', r.url)
    logging.debug('return: %s', r.text)

def echonest_info(api_key, profile_id):
    '''Display info about echonest profile'''
    logging.debug('call echonest_info')
    url = 'http://developer.echonest.com/api/v4/tasteprofile/profile'
    payload = {"api_key": api_key,
              "id": profile_id
              }
    r = requests.get(url, params=payload)
    logging.debug('URL: %s', r.url)
    logging.debug('return: %s', r.text)
    ret = r.json()
    return ret['response']['catalog']

def echonest_read(api_key, profile_id, item_id):
    '''Display dat about a given item'''
    logging.debug('call echonest_read')
    url = 'http://developer.echonest.com/api/v4/tasteprofile/read'
    payload = {
            'api_key': api_key,
            'id': profile_id,
            'item_id': str(item_id)<commit_msg>fetch additional song and artist data #42<commit_after>
#!/usr/bin/env python
# coding=utf-8
#
# Copyright 2015 Arn-O. See the LICENSE file at the top-level directory of this
# distribution and at
# https://github.com/Arn-O/py-kodi-remote-controller/blob/master/LICENSE.

'''
Module of functions for echonest API management.
'''

import requests
import logging

#TODO: rename to tasteprofile in place of echonest
def echonest_favorite(api_key, profile_id, song_id):
    '''Make a song favorite in echonest tasteprofile'''
    logging.debug('call set_echonest_favorite')
    url = 'http://developer.echonest.com/api/v4/tasteprofile/favorite'
    payload = {"api_key": api_key,
              "id": profile_id,
              "item": str(song_id)
              }
    r = requests.get(url, params=payload)
    logging.debug('URL: %s', r.url)
    logging.debug('return: %s', r.text)

def echonest_skip(api_key, profile_id, song_id):
    '''Skip a song favorite in echonest taste profile'''
    logging.debug('call set_echonest_skip')
    url = 'http://developer.echonest.com/api/v4/tasteprofile/skip'
    payload = {"api_key": api_key,
              "id": profile_id,
              "item": str(song_id)
              }
    r = requests.get(url, params=payload)
    logging.debug('URL: %s', r.url)
    logging.debug('return: %s', r.text)

def echonest_info(api_key, profile_id):
    '''Display info about echonest profile'''
    logging.debug('call echonest_info')
    url = 'http://developer.echonest.com/api/v4/tasteprofile/profile'
    payload = {"api_key": api_key,
              "id": profile_id
              }
    r = requests.get(url, params=payload)
    logging.debug('URL: %s', r.url)
    logging.debug('return: %s', r.text)
    ret = r.json()
    return ret['response']['catalog']

def echonest_read(api_key, profile_id, item_id):
    '''Display dat about a given item'''
    logging.debug('call echonest_read')
    url = 'http://developer.echonest.com/api/v4/tasteprofile/read'
    payload = {
            'api_key': api_key,
            'id': profile_id,
            'item_id': str(item_id),
            'bucket': [
                'artist_discovery', 'artist_familiarity', 'artist_hotttnesss',
                'song_currency', 'song_hotttnesss', 'song_type',
                ]
{'fraction_non_alphanumeric': 0.14042748793380833, 'fraction_numerical': 0.004596644449551827, 'mean_word_length': 2.963570127504554, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6973217', 'n_tokens_mistral': 1500, 'n_tokens_neox': 1442, 'n_words': 320}