<commit_before>import getHistory from '../utils/history'
import Ajax from './ajax'
import { USERNAME } from "../utils/constants"
import getSettings from '../stores/settings'

// NOTE: Since the host might change, we create a new Ajax object every time
function getAjax(customSettings) {

    let settings = getSettings();
    if (customSettings) {
        settings = customSettings;
    }

    var beetsServer = `http://${settings.values.host}/api`;

    var credentials = btoa(unescape(encodeURIComponent(USERNAME + ':' + settings.values.password)))
    return new Ajax(beetsServer, {
        'headers': {
            'Authorization': "Basic " + credentials
        }
    });
}

export function playlistSongs(playlistName) {

    return getAjax().get(`/playlists/${playlistName}`)
        .then(response => response.json().then(json => json))
        .then((json) => {
            return json.results;
        });
}

export function playlists() {

    return getAjax().get(`/playlists`)
        .then(response => response.json().then(json => json))
        .then((json) => {<commit_msg>fix - rating songs doesn't work<commit_after>import getHistory from '../utils/history'
import Ajax from './ajax'
import { USERNAME } from "../utils/constants"
import getSettings from '../stores/settings'

// NOTE: Since the host might change, we create a new Ajax object every time
function getAjax(customSettings) {

    let settings = getSettings();
    if (customSettings) {
        settings = customSettings;
    }

    var beetsServer = `http://${settings.values.host}/api`;

    var credentials = btoa(unescape(encodeURIComponent(USERNAME + ':' + settings.values.password)))
    return new Ajax(beetsServer, {
        'headers': {
            'Authorization': "Basic " + credentials,
            'Content-Type': "application/json"
        }
    });
}

export function playlistSongs(playlistName) {

    return getAjax().get(`/playlists/${playlistName}`)
        .then(response => response.json().then(json => json))
        .then((json) => {
            return json.results;
        });
}

export function playlists() {

    return getAjax().get(`/playlists`)
        .then(response => response.json().then(json => json))
        .then((json) => {
{'fraction_non_alphanumeric': 0.14821428571428572, 'fraction_numerical': 0.0, 'mean_word_length': 2.9384885764499122, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, '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': '5201162', 'n_tokens_mistral': 643, 'n_tokens_neox': 635, 'n_words': 152}