Changeset 20 in flacrip for trunk/applymeta
- Timestamp:
- 10/06/14 17:31:24 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/applymeta
r8 r20 8 8 9 9 GetOptions( 10 'file|f=s' => \my $META_FILE, 11 'clear' => \my $CLEAR, 10 'file|f=s' => \my $META_FILE, 11 'clear' => \my $CLEAR, 12 'tracks|t=s' => \my $TRACKS, 12 13 ); 13 14 my @AUDIO_FILES = @ARGV;15 14 16 15 my $meta; … … 27 26 my $metadata = $meta->splitToTree; 28 27 29 for my $i (1 .. @AUDIO_FILES) { 30 my $mp3 = MP3::Tag->new($AUDIO_FILES[$i - 1]); 28 my $track_count = scalar grep { /^TRACK/ } keys %{ $metadata }; 29 30 my @track_numbers; 31 foreach (split /,/, $TRACKS) { 32 if (/^(\d+)$/) { 33 push @track_numbers, $1; 34 } elsif (/^(\d+)-(\d+)$/) { 35 push @track_numbers, ($1 .. $2); 36 } elsif (/^-(\d+)$/) { 37 push @track_numbers, (1 .. $1); 38 } elsif (/^(\d+)-$/) { 39 push @track_numbers, ($1 .. $track_count); 40 } 41 } 42 43 for my $i (@track_numbers) { 44 my $audio_file = shift or die "No more audio files to process\n"; 45 my $mp3 = MP3::Tag->new($audio_file); 31 46 32 47 # first clear the tags if asked … … 47 62 $mp3->select_id3v2_frame_by_descr('TPE2', $metadata->{ALBUMARTIST}) if $metadata->{ALBUMARTIST}; 48 63 $mp3->update_tags; 49 printf " Apply to %s\n", $ AUDIO_FILES[$i - 1];64 printf " Apply to %s\n", $audio_file; 50 65 51 66 #TODO: full version of a make-string-filename-safe function
Note: See TracChangeset
for help on using the changeset viewer.