Convert MP3 Tags From Cyrillic Chars To Translit
Join the DZone community and get the full member experience.
Join For FreeConvert mp3 tags from cyrillic chars to traslit latin
#!/usr/bin/env ruby
require 'mp3info'
require 'iconv'
require 'russian'
######## Please install following gems:
## gem sources -a http://gems.github.com
# sudo gem install ruby-mp3info
# sudo gem install yaroslav-russian
converter = Iconv.new('utf-8', 'CP1251')
files = Dir['**/*.mp3']
files.each do |mp3_file|
##iso-8859-1, utf-8
Mp3Info.open(mp3_file, :encoding => 'iso-8859-1') do |mp3|
puts "FOR #{mp3_file}"
title = mp3.tag.title
artist = mp3.tag.artist
album = mp3.tag.album
title, artist, album = [title, artist, album].map{|x| converter.iconv(x)}
t_title, t_artist, t_album = [title, artist, album].map{|x| Russian.translit(x)}
puts "#{artist}: #{album} - #{title}"
puts "#{t_artist}: #{t_album} - #{t_title}"
#### uncomment for the final run!
# mp3.tag.title = t_title
# mp3.tag.artist = t_artist
# mp3.tag.album = t_album
end
end
MP3
Convert (command)
Opinions expressed by DZone contributors are their own.
Comments