Created
July 18, 2019 11:41
-
-
Save egze/065202130d04ab9271fdeba6aa5232df to your computer and use it in GitHub Desktop.
Fixes wrong cp1251 encoding (Ïîñòàðàåìñÿ áîëüøå) in ID3 tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'taglib' | |
files_names = Dir["*.mp3"].sort | |
files_names.each do |file_name| | |
TagLib::MPEG::File.open(file_name) do |mp3_file| | |
## ID3 tag | |
tag = mp3_file.id3v2_tag | |
tag.title = "#{ tag.track } - #{ tag.title.encode(Encoding::CP1252).force_encoding(Encoding::CP1251).encode(Encoding::UTF_8).gsub(/\d\)\s/, "") }" | |
tag.artist = tag.artist.encode(Encoding::CP1252).force_encoding(Encoding::CP1251).encode(Encoding::UTF_8) | |
tag.album = tag.album.encode(Encoding::CP1252).force_encoding(Encoding::CP1251).encode(Encoding::UTF_8) | |
mp3_file.save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment