<commit_before>import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import SpotifyWebApi from 'spotify-web-api-js';
import AlbumList from './album_list';
import ArtistInformation from './artist_information';
import SearchBar from './search_bar';

var access_token;
var callback_url = window.location.href;
const api_url = "https://accounts.spotify.com/authorize?client_id=97f162d3fb7940b9bc87ac13b118a406&response_type=token&redirect_uri="+callback_url;

class App extends Component{
    constructor(props){
        super(props);
        this.state = {current_artist: [], albums: []};
        var hash;
    //if the hash isnt initialised, replace the location to the api.
        if(!window.location.hash){
            window.location.replace(api_url);
    //the api will return a callback url tha will be splitted in order to get the access token.
        }else{
            var url = window.location.href;
            hash = url.split('#')[1];
            hash = hash.split('&')[0];
            hash = hash.split('=')[1];
            console.log("Hash: ", hash);
        }
        access_token = hash;
        
        var spotifyApi = new SpotifyWebApi();
        spotifyApi.setAccessToken(access_token);
        
        spotifyApi.getArtist('3dRfiJ2650SZu6GbydcHNb', (err, data) => {
            if(err){
                console.log(err);
                window.location.replace(api_url);
            }
            this.setState({current_artist: data});
            console.log("current_artist",this.state.current_artist);
        });

        spotifyApi.getArtistAlbums('3dRfiJ2650SZu6GbydcHNb', (err, data) => {
            if(err){
                console.log(err);
                window.location.replace(api_url);
            }
            console.log('Artist albums', data);
            console.log('Album result: ', data.items);
            this.setState({albums: data.items});
        });

    }
    render(){
        return (
            <div className="container">
                <nav>
                    <SearchBar/>
                </nav>
                <ArtistInformation current_artist={this.state.current_artist}/>
                <AlbumList albums={this.state.albums}/>
            </div>
        );
    }
}

ReactDOM.render(<App/>, document.querySelector('#root'));<commit_msg>Correções no uso da api: Adicionando album_type e market BR<commit_after>import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import SpotifyWebApi from 'spotify-web-api-js';
import AlbumList from './album_list';
import ArtistInformation from './artist_information';
import SearchBar from './search_bar';

var access_token;
var callback_url = window.location.href;
const api_url = "https://accounts.spotify.com/authorize?client_id=97f162d3fb7940b9bc87ac13b118a406&response_type=token&redirect_uri="+callback_url;

class App extends Component{
    constructor(props){
        super(props);
        this.state = {current_artist: [], albums: []};
        var hash;
    //if the hash isnt initialised, replace the location to the api.
        if(!window.location.hash){
            window.location.replace(api_url);
    //the api will return a callback url tha will be splitted in order to get the access token.
        }else{
            var url = window.location.href;
            hash = url.split('#')[1];
            hash = hash.split('&')[0];
            hash = hash.split('=')[1];
            console.log("Hash: ", hash);
        }
        access_token = hash;
        
        var spotifyApi = new SpotifyWebApi();
        spotifyApi.setAccessToken(access_token);
        
        spotifyApi.getArtist('3dRfiJ2650SZu6GbydcHNb', (err, data) => {
            if(err){
                console.log(err);
                window.location.replace(api_url);
            }
            this.setState({current_artist: data});
            console.log("current_artist",this.state.current_artist);
        });

        spotifyApi.getArtistAlbums('3dRfiJ2650SZu6GbydcHNb',{album_type: 'album', limit: 50, market: 'BR'}, (err, data) => {
            if(err){
                console.log(err);
                window.location.replace(api_url);
            }
            console.log('Artist albums', data);
            console.log('Album result: ', data.items);
            this.setState({albums: data.items});
        });

    }
    render(){
        return (
            <div className="container">
                <nav>
                    <SearchBar/>
                </nav>
                <ArtistInformation current_artist={this.state.current_artist}/>
                <AlbumList albums={this.state.albums}/>
            </div>
        );
    }
}

ReactDOM.render(<App/>, document.querySelector('#root'));
{'fraction_non_alphanumeric': 0.12850812407680945, 'fraction_numerical': 0.015615108672715762, 'mean_word_length': 2.17056856187291, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '2072588', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1380, 'n_words': 275}