diff options
| author | Eugen Wissner <belka@caraus.de> | 2025-11-16 12:47:23 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2025-11-16 12:47:23 +0100 |
| commit | a3530666a60dd004fe2c28bb87fbabdf5e5bebab (patch) | |
| tree | 6fb162130eac52f948757e2c4975d7669fe0e49d /bin/7digital.rb | |
| parent | 964d815a90a78c0ebbfc2fa57f8b847c1fab298d (diff) | |
| download | kazbek-a3530666a60dd004fe2c28bb87fbabdf5e5bebab.tar.gz | |
7digital.rb: Support MissingFiles.txt
Diffstat (limited to 'bin/7digital.rb')
| -rwxr-xr-x | bin/7digital.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/7digital.rb b/bin/7digital.rb index fc90823..0fb894e 100755 --- a/bin/7digital.rb +++ b/bin/7digital.rb @@ -1,13 +1,12 @@ #!/usr/bin/env ruby # This Source Code Form is subject to the terms of the Mozilla Public License, # v. 2.0. If a copy of the MPL was not distributed with this file, You can -# obtain one at https://mozilla.org/MPL/2.0/. -} +# obtain one at https://mozilla.org/MPL/2.0/. # frozen_string_literal: true require 'pathname' require 'open3' -require 'optparse' require 'zip' # Renames music files in a directory according to the file's tags. @@ -38,7 +37,6 @@ end def extract_and_rename_archive(album_archive, music_directory) music_directory.mkpath - artist_name, album_name = album_archive.basename('.zip').to_s.split(' - ') Zip::File.open album_archive.to_path do |zip_file| zip_file.each do |entry| @@ -78,6 +76,7 @@ unless ARGV.length == 2 exit 1 end +exit_code = 0 album_archive = Pathname.new ARGV[0] music_directory = Pathname.new ARGV[1] metadata = {} @@ -87,7 +86,12 @@ extract_and_rename_archive album_archive, music_directory Dir.each_child music_directory do |filename| song_path = music_directory + filename - metadata[song_path] = probe_song(song_path) + if filename == 'MissingFiles.txt' + IO.copy_stream File.open(song_path, 'r'), $stderr + exit_code = 2 + else + metadata[song_path] = probe_song(song_path) + end end metadata.each_pair do |from, to| @@ -96,3 +100,5 @@ metadata.each_pair do |from, to| album_path.mkpath File.rename(from, album_path + to.to_s) end + +exit exit_code |
