<commit_before>package RAB::RAAPI;

use LWP;
use YAML::Tiny;
use JSON;
use Data::Dumper;
#
# Variables initialization
#

sub GetUserRecentlyPlayedGames
{
    my $rafile = shift;
    my $rayaml = YAML::Tiny->read( $rafile );
    my $user   = shift;

    my $browser = new LWP::UserAgent;
    my $request = new HTTP::Request( GET => "http://retroachievements.org/API/API_GetUserRecentlyPlayedGames.php?z=$rayaml->[0]{ra_user}&y=$rayaml->[0]{ra_api_key}&u=$user" );
    my $headers = $request->headers();
       $headers->header( 'User-Agent','Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/3.4.2 (like Gecko)');
       $headers->header( 'Accept', 'text/html, image/jpeg, image/png, text/*, image/*, */*');
       $headers->header( 'Accept-Encoding','x-gzip, x-deflate, gzip, deflate');
       $headers->header( 'Accept-Charset', 'iso-8859-15, utf-8;q=0.5, *;q=0.5');
       $headers->header( 'Accept-Language', 'fr, en');
       $headers->header( 'Referer', 'http://retroachievements.org/API');
    my $response = $browser->request($request);

    if ($response->is_success)
    {
        return $response->content;
    }
}

sub GetUserRankAndScore
{
    my $rafile = shift;
    my $rayaml = YAML::Tiny->read( $rafile );
    my $user   = shift;

    my $browser = new LWP::UserAgent;
    my $request = new HTTP::Request( GET => "http://retroachievements.org/API/API_GetUserRankAndScore.php?z=$rayaml->[0]{ra_user}&y=$rayaml->[0]{ra_api_key}&u=$user" );
    my $headers = $request->headers();
       $headers->header( 'User-Agent','Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/3.4.2 (like Gecko)');
       $headers->header( 'Accept', 'text/html, image/jpeg, image/png, text/*, image/*, */*');
       $headers->header( 'Accept-Encoding','x-gzip, x-deflate, gzip, deflate');
       $headers->header( 'Accept-Charset', 'iso-8859-15, utf-8;q=0.5, *;q=0.5');
       $headers->header( 'Accept-Language', 'fr, en');
       $headers->header( 'Referer', 'http://retroachievements.org/API');
    my $response = $browser->request($request);

    if ($response->is_success)
    {   
        return $response->content;
    }

}

sub GetUserProgress
{
    my $rafile = shift;
    my $rayaml = YAML::Tiny->read( $rafile );
    my $user   = shift;
    my $csvref = shift;
    my $csv    = join(',', @{$csvref});

    my $browser = new LWP::UserAgent;
    my $request = new HTTP::Request( GET => "http://retroachievements.org/API/API_GetUserProgress.php?z=$rayaml->[0]{ra_user}&y=$rayaml->[0]{ra_api_key}&u=$user&i=$csv" );
    my $headers = $request->headers();
       $headers->header( 'User-Agent','Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/3.4.2 (like Gecko)');
       $headers->header( 'Accept', 'text/html, image/jpeg, image/png, text/*, image/*, */*');
       $headers->header( 'Accept-Encoding','x-gzip, x-deflate, gzip, deflate');
       $headers->header( 'Accept-Charset', 'iso-8859-15, utf-8;q=0.5, *;q=0.5');
       $headers->header( 'Accept-Language', 'fr, en');
       $headers->header( 'Referer', 'http://retroachievements.org/API');
    my $response = $browser->request($request);

    if ($response->is_success)
    {   
        return decode_json($response->content);

#        foreach my $id ( keys %{$JSON} )
#        {
#            print STDERR Dumper $JSON->{$id};
#            foreach my $label ( keys %{$JSON->{$id}} )
#            {
#                $NEWJSON{$id}{$label} = $JSON->{$id}->{$label}
#            }
#        }
#        print STDERR Dumper %NEWJSON;
    }
    else
    {
        print STDERR Dumper $response;
    }
}

1;<commit_msg>Small clean in RAAPI.pm<commit_after>package RAB::RAAPI;

use LWP;
use YAML::Tiny;
use JSON;
use Data::Dumper;
#
# Variables initialization
#

sub GetUserRecentlyPlayedGames
{
    my $rafile = shift;
    my $rayaml = YAML::Tiny->read( $rafile );
    my $user   = shift;

    my $browser = new LWP::UserAgent;
    my $request = new HTTP::Request( GET => "http://retroachievements.org/API/API_GetUserRecentlyPlayedGames.php?z=$rayaml->[0]{ra_user}&y=$rayaml->[0]{ra_api_key}&u=$user" );
    my $headers = $request->headers();
       $headers->header( 'User-Agent','Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/3.4.2 (like Gecko)');
       $headers->header( 'Accept', 'text/html, image/jpeg, image/png, text/*, image/*, */*');
       $headers->header( 'Accept-Encoding','x-gzip, x-deflate, gzip, deflate');
       $headers->header( 'Accept-Charset', 'iso-8859-15, utf-8;q=0.5, *;q=0.5');
       $headers->header( 'Accept-Language', 'fr, en');
       $headers->header( 'Referer', 'http://retroachievements.org/API');
    my $response = $browser->request($request);

    if ($response->is_success)
    {
        return $response->content;
    }
}

sub GetUserRankAndScore
{
    my $rafile = shift;
    my $rayaml = YAML::Tiny->read( $rafile );
    my $user   = shift;

    my $browser = new LWP::UserAgent;
    my $request = new HTTP::Request( GET => "http://retroachievements.org/API/API_GetUserRankAndScore.php?z=$rayaml->[0]{ra_user}&y=$rayaml->[0]{ra_api_key}&u=$user" );
    my $headers = $request->headers();
       $headers->header( 'User-Agent','Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/3.4.2 (like Gecko)');
       $headers->header( 'Accept', 'text/html, image/jpeg, image/png, text/*, image/*, */*');
       $headers->header( 'Accept-Encoding','x-gzip, x-deflate, gzip, deflate');
       $headers->header( 'Accept-Charset', 'iso-8859-15, utf-8;q=0.5, *;q=0.5');
       $headers->header( 'Accept-Language', 'fr, en');
       $headers->header( 'Referer', 'http://retroachievements.org/API');
    my $response = $browser->request($request);

    if ($response->is_success)
    {   
        return $response->content;
    }

}

sub GetUserProgress
{
    my $rafile = shift;
    my $rayaml = YAML::Tiny->read( $rafile );
    my $user   = shift;
    my $csvref = shift;
    my $csv    = join(',', @{$csvref});

    my $browser = new LWP::UserAgent;
    my $request = new HTTP::Request( GET => "http://retroachievements.org/API/API_GetUserProgress.php?z=$rayaml->[0]{ra_user}&y=$rayaml->[0]{ra_api_key}&u=$user&i=$csv" );
    my $headers = $request->headers();
       $headers->header( 'User-Agent','Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/3.4.2 (like Gecko)');
       $headers->header( 'Accept', 'text/html, image/jpeg, image/png, text/*, image/*, */*');
       $headers->header( 'Accept-Encoding','x-gzip, x-deflate, gzip, deflate');
       $headers->header( 'Accept-Charset', 'iso-8859-15, utf-8;q=0.5, *;q=0.5');
       $headers->header( 'Accept-Language', 'fr, en');
       $headers->header( 'Referer', 'http://retroachievements.org/API');
    my $response = $browser->request($request);

    if ($response->is_success)
    {   
        return decode_json($response->content);
    }
    else
    {
        print STDERR Dumper $response;
    }
}

1;
{'fraction_non_alphanumeric': 0.206006706516985, 'fraction_numerical': 0.017786849394955534, 'mean_word_length': 3.2794759825327513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 91, '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': '4986911', 'n_tokens_mistral': 2568, 'n_tokens_neox': 2502, 'n_words': 456}