Sha256: fe48acb7211299f782b4a9e5d7373cf24fdbf21fb335c748e3cb54dbbde1c10a

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

unless ARGV.size == 1
  warn "#{File.basename(__FILE__)}: Missing required parameter for the mp3 file to process"
  exit(1)
end

require 'mp3info'
begin
  file_name = ARGV.first

  puts "Listing tags for file: #{file_name}"

  # rubocop:disable Metrics/BlockLength
  Mp3Info.open(file_name) do |mp3info|
    puts 'ID3v1 tags:'
    mp3info.tag.each_key do |key|
      puts "  #{key} => #{mp3info.tag.send(key)}"
    end
    puts
    puts 'ID3v2 tags:'
    mp3info.tag2.each_key do |key|
      case key
      when 'PIC'
      when 'APIC'
      # picture - do not print binary data
      when 'ULT'
        print '  ULT => '
        block_counter = 0
        mp3info.tag2.ULT.bytes do |b|
          print format('0x%02x ', b.to_i)
          print b > 31 ? " '#{b.chr}' " : ' ' * 5
          if (block_counter += 1) > 7 # display in blocks of 8 bytes
            puts
            print ' ' * 9
            block_counter = 0
          end
        end
        puts
      else
        puts "  #{key} => #{mp3info.tag2.send(key)}"
      end
    end
  end
  # rubocop:enable Metrics/BlockLength

  puts "Modification date: #{File.new(file_name).mtime}"
rescue StandardError
  puts "Error: #{$ERROR_INFO.message}"
  exit(1)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dropcaster-1.2.0 bin/lstags