-
Notifications
You must be signed in to change notification settings - Fork 0
/
FixLiveDL
executable file
·53 lines (43 loc) · 1.05 KB
/
FixLiveDL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl
use MP3::Info;
use MP3::Tag;
use Getopt::Std;
$tn = 1;
print "Enter album title: ";
chomp ($album = <STDIN>);
print "Enter artist: ";
chomp ($artist = <STDIN>);
print "Enter artist sort: ";
chomp ($tsop = <STDIN>);
while (<*.mp3>)
{
system "chmod 644 '$_'";
#system "eyeD3 --remove-images '$_' >/dev/null";
system "id3v2 -s '$_'";
system "id3v2 -2 -T $tn '$_'";
system "id3v2 -2 --TPOS=\"\" '$_'";
system "id3v2 -2 -A \"$album\" '$_'";
system "id3v2 -2 -a \"$artist\" '$_'";
system "SetTSOP \"$tsop\" '$_'" if $tsop ne "";
$tn++;
my $tag = get_mp3tag($_);
if ($tag)
{
my $title = $tag->{TITLE};
my $tracknum = $tag->{TRACKNUM};
my $newname = sprintf("%02d_%s.mp3", $tracknum, fix_name($title));
print "rename $_ to $newname\n";
rename($_, $newname);
}
}
sub fix_name
{
my $name = shift;
$name =~ s/&/and/g;
$name =~ s/[\(\)\[\]\{\}\,\'\.\?\/\\:"!<>]//g;
$name =~ s/#/Number/g;
$name =~ s/ +/ /g;
$name =~ s/ $//g;
$name =~ s/ /_/g;
return $name;
}