Difference between
modified post 1e by Anonymous on Thu 6th Sep 2012 09:53
original post 42d8059b by Anonymous on Wed 5th Sep 2012 14:55
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | #!/usr/bin/perl | |
| 2 | 2 | ||
| 3 | 3 | use 5.14.0; | |
| 4 | 4 | use strict; | |
| 5 | 5 | use warnings; | |
| 6 | 6 | #use File::Find qw(finddepth); | |
| 7 | 7 | use File::Copy qw(move); | |
| 8 | 8 | use File::Basename qw(basename dirname); | |
| 9 | 9 | use File::Path qw(make_path); | |
| 10 | 10 | ||
| 11 | 11 | #my $library = "/home/sir/Music/Songbird Music"; | |
| 12 | 12 | my $library = "/home/sir/Music/Songbird Music"; | |
| 13 | 13 | my (%files, @files, @dirs); | |
| 14 | + | my $flac_version = '1.2.1'; | |
| 14 | 15 | ||
| 15 | 16 | getdirs($library); | |
| 16 | 17 | ||
| 17 | 18 | foreach my $dn (sort(@dirs)) { | |
| 18 | 19 | chomp(my $ls = `ls "$dn"/*.flac 2> /dev/null | head -n 1`); | |
| 19 | 20 | if (-f $ls) { | |
| 20 | 21 | # my @stat = stat($dn); | |
| 21 | 22 | # my $ino = $stat[1]; | |
| 22 | 23 | # say "$dn has $ino"; | |
| 23 | 24 | undef %files; | |
| 24 | 25 | undef @files; | |
| 25 | 26 | getfiles($dn); | |
| 26 | 27 | my $fc = scalar(@files); | |
| 27 | 28 | if ($fc > 0) { | |
| 28 | 29 | #replaygain($dn); | |
| 29 | 30 | for (my $n = 0; $n < $fc; $n++) { | |
| 30 | - | #say $files[$n]; | |
| 31 | 31 | my $fn = $files[$n]; | |
| 32 | - | ||
| 32 | + | vendor($fn); | |
| 33 | - | #rmtag($fn, 'rating'); | |
| 33 | + | rmtag($fn, 'rating'); | |
| 34 | - | #albumartist($fn, $fc); | |
| 34 | + | albumartist($fn, $fc); | |
| 35 | - | #track($fn); | |
| 35 | + | track($fn); | |
| 36 | - | #totaltracks($fn, $fc); | |
| 36 | + | totaltracks($fn, $fc); | |
| 37 | 37 | # empty($fn); | |
| 38 | 38 | # duplicate($fn); | |
| 39 | 39 | discnum($fn, $n, $fc); | |
| 40 | 40 | } | |
| 41 | 41 | } | |
| 42 | 42 | } | |
| 43 | 43 | } | |
| 44 | 44 | # Make this subroutine and the whole script so that each file name is stored in a hash and that each member contains an anonymous hash with the tags (the alltags hash). | |
| 45 | 45 | # This means it won't have to look up the tags again for the albumartist subroutine. | |
| 46 | 46 | ||
| 47 | 47 | sub gettags { | |
| 48 | 48 | my $fn = quotemeta(shift); | |
| 49 | 49 | my (%alltags, @mflac); | |
| 50 | - | open(OUTPUT, '-|', qq{metaflac --no-utf8-convert --export-tags-to=- $fn}) || die "can't run metaflac: $!"; | |
| 50 | + | open(OUTPUT, '-|', qq{metaflac --no-utf8-convert --show-vendor-tag --export-tags-to=- $fn}) || die "can't run metaflac: $!"; | |
| 51 | 51 | chomp(@mflac = (<OUTPUT>)); | |
| 52 | 52 | foreach (@mflac) { | |
| 53 | - | my @tag = split('='); | |
| 53 | + | my (@tag, $tagname); | |
| 54 | - | my $tagname = lc($tag[0]) or say $fn; | |
| 54 | + | if (/^reference/) { | |
| 55 | + | @tag = split(' '); | |
| 57 | 58 | } else { | |
| 59 | + | @tag = split('='); | |
| 59 | 61 | } | |
| 62 | + |
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
kpaste.net RSS