#!/usr/bin/perl -w use strict; use warnings; use MP3::Tag; use LWP::UserAgent; my $dir = "./"; my $ua = LWP::UserAgent->new(); my $url = ""; ## <<< url to get files from my $buffer; my @files; my $response = $ua->get($url); if($response->is_success){ my $con = $response->content; while ($con =~ //g){ push @files, "$1.mp3"; } } foreach my $file(@files) { print "Reading $file..."; $ua->get($url.$file, ':content_cb' => \&first_chunk, ':read_size_hint' => 10240 ); sub first_chunk { my ($chunk, $response_ref, $protocol_ref) = @_; $buffer .= $chunk; die() if length($buffer) >= 10240; } ## Clean filename $file =~ tr/+/ /; $file =~ s/%([a-fA-F0-9]{2,2})/chr(hex($1))/eg; $file =~ s///g; ## Save file open FILE, ">$file", or die $!; print FILE $buffer; close FILE; print " Done!\n"; ## Clear buffer $buffer = ""; ## Find tags my $filename = "$dir$file"; my $mp3 = MP3::Tag->new($filename); my ($song, $track, $artist, $album) = $mp3->autoinfo(); ## Print tag: Artist - Album (if any) - Song unless ($album) { if ($artist) { $album = " - "; } } else { $album = " - $album - "; } print "$artist$album$song\n"; }