
It so happened that in the long life of a music lover I had accumulated over 1000 discs of an “archaic” audio CD format. And what to do in the era of social networks, in general, and Last.fm in particular, with so many disks? That's right, you need to send everything to Last.fm and preferably in a crowd, not listening to them on the computer (although this number is only a month and a half of continuous assault on neighbors' ears), and besides, I do not listen to audio CDs on the computer. To solve such a "difficult" task, you need only four things: the great and powerful language of PERL, the Last.fm API, CDDB and be a bit of a programmer.
Either to the joy, or unfortunately, I have only 3/4 of the necessary, as I am not a programmer and in no way my profession is related to computers (sic!). Well, eyes hurt, and hands do; the desire to have beautiful statistics and profile is overpowered by the lack of necessary skills :).
1. Last.fm API 
There is nothing complicated, you can read in detail on
the description page , and in brief, it works like this.
1.1
We send HTTP / 1.1 GET request to the address
http://post.audioscrobbler.com:80/.
The query string should look like this:
http://post.audioscrobbler.com/?hs=true&p=1.2.1&c= <client-id> & v = <client-ver> & u = <user> & t = <timestamp> & a = <auth> <pre>
<client-id> = id of client program
<client-ver> = client version
<user> = logically, this is the username
<timestamp> = Unix time
<auth> = authorization token which is equal to md5 (md5 (password) + timestamp)
Unix time is equal to the number of seconds since January 1, 1970.
')
1.2
After all sent we receive from the server a response that looks like this:
Ok
17E61E13454CDD8B68E8D7DEEEDF6170
http://post.audioscrobbler.com:80/np_1.2
http://post2.audioscrobbler.com:80/protocol_1.2
We see that everything is fine, we are happy and "we press a hand to the server."
1.3
We begin the process of transferring data about music (in the Scrobbling Last.fm dialect) to the server
To the address received in response to the first request, we send a POST request, which must contain:
<sessionID> = session ID, which also received earlier
<artist> = Name of your favorite VIA
<track> = The name of the song of your favorite VIA
<time> = Again, UNIX Time at the time of the start of playback.
These are all required fields. Curious can see the
full list . The most interesting thing is that the timestamp can be any and the “music of the future” is normal.

But the great PERL language would not be so great if we could not use third-party modules. I used
Net :: LastFM :: Submission , although there are other options.
2. CDDB (Compact Disc Data Base) 
In fact, we will not use the CDDB, which is owned by Gracenote (Sony), but the free analogue of
freedb . Gracenote's policy is a bit similar to AOL's favorite policy, at one point they simply banned all “unlicensed” applications so that they would switch to CDDB2 format, which, as you might guess, is not backwards compatible with CDDB1 and it seems that its license is not at all GNU Public.
What is CDDB in essence? On one island was born such a
Hindu Taiwanese
Ti Kan who started it all. The idea of Mr. Ti Kahn was very simple, each disc is determined by an almost unique id which consists of a checksum of the start time of each of the tracks, the total playing time and the total number of tracks. At one time, our Taiwanese replenished the database himself, and well-wishers sent him a description of the disk and its id on soap. Naturally, once he got tired of it and in the end it turned into CDDB, freedb, MusicBrainz, etc.
But I deviated from the theme of his majesty PERL. To get the list of tracks from freedb, we need to use the simplest module / script
CDDB_get.pm and remember to insert a CD into the CD-ROM.
3. What did it all happen? 
As a result, we have a simple script that, when launched, searches for a disk on freedb, optionally displays a list of all suitable options, sends a list of songs from this disk to Last.fm, waits 30 seconds for you to insert the next disk and does its job again.
#!/usr/bin/perl -w
use Net::LastFM::Submission;
use CDDB_get qw( get_cddb );
my %config;
#CONFIG_______________________________________________________________________________
$config{CDDB_HOST}="freedb.freedb.org"; # cddb host
$config{CDDB_PORT}=8880; # cddb port
$config{CDDB_MODE}="cddb"; # cddb mode: cddb or http
$config{CD_DEVICE}="/dev/cdrom"; # cd device
$config{input}=0; # 1: ask user if more than one possibility, 0: no user interaction
$lfmuser='user';
$lfmpass='password';
#____________________________________________________________________________________
open (DB,">>musiclist.txt"); #just for stats
my $submit = Net::LastFM::Submission->new(
'user' => $lfmuser,
'password' => $lfmpass)
$submit->handshake;
%cd=get_cddb(\%config);
while ($previd ne $cd{id}){
unless(defined $cd{title}) { die "no cddb entry found"; }
print "artist: $cd{artist}\n","title: $cd{title}\n","year: $cd{year}\n","id: $cd{id}\n";
print DB $cd{artist}," - ",$cd{title}," \[$cd{year}\]\n";
my $n=1;
foreach my $i ( @{$cd{track}} ) {
print "$n: $i\n";
$submit->submit(
'artist' => $cd{artist},
'title' => $i,
'album' =>$cd{title},
'id' =>$n,
'time' => time - (180-($n+5))*60 # 3 hours back
);
$n++;
}
$previd=$cd{id};
print "_" x 20,"\n30 seconds pause for the next CD ...\n";
sleep(30);
%cd=get_cddb(\%config);
}
As a result, we have a completed profile with a delay of 3 hours:

All this is written by a layman, so do not judge strictly. Also add - this is most likely not a script implementation, but a script idea and I think that in a week a check will be added to the code that the user enters and scrobbling with the actual duration of the songs. Plus, you need to think about what time to put in order to avoid the “music of the future”. The ideal option would be a demon that, when loading an audio disk, writes its id to the base, and at night, for example, scrobbles all tracks from the base while preserving the real sequence and time, and at will, several favorite songs scrobble many times.