From a3530666a60dd004fe2c28bb87fbabdf5e5bebab Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 16 Nov 2025 12:47:23 +0100 Subject: [PATCH] 7digital.rb: Support MissingFiles.txt --- .gitignore | 2 +- Gemfile | 2 +- bin/7digital.rb | 14 ++++++++++---- bin/cross_toolchain.rb | 2 +- bin/mock_server.rb | 2 +- bin/pg_jekyll.rb | 2 +- bin/read_logs.rb | 2 +- bin/rename.rb | 2 +- locopy/bin/locopy.rb | 3 +++ 9 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index d209af6..682e288 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ /config/*.toml /log/ /tmp/ -/vendor/ +vendor/ diff --git a/Gemfile b/Gemfile index 82fe10b..48768fa 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -source "https://rubygems.org" +source 'https://rubygems.org' gem 'rubyzip', '~> 3.2' gem 'pg', '~> 1.6' 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 diff --git a/bin/cross_toolchain.rb b/bin/cross_toolchain.rb index 42b1865..29645c5 100755 --- a/bin/cross_toolchain.rb +++ b/bin/cross_toolchain.rb @@ -1,7 +1,7 @@ #!/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 diff --git a/bin/mock_server.rb b/bin/mock_server.rb index 09f6b91..b33eac6 100755 --- a/bin/mock_server.rb +++ b/bin/mock_server.rb @@ -1,7 +1,7 @@ #!/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 diff --git a/bin/pg_jekyll.rb b/bin/pg_jekyll.rb index ed2ac3b..464dcf9 100755 --- a/bin/pg_jekyll.rb +++ b/bin/pg_jekyll.rb @@ -1,7 +1,7 @@ #!/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 diff --git a/bin/read_logs.rb b/bin/read_logs.rb index b53760f..cf4011b 100755 --- a/bin/read_logs.rb +++ b/bin/read_logs.rb @@ -1,7 +1,7 @@ #!/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 diff --git a/bin/rename.rb b/bin/rename.rb index 654f220..1188653 100755 --- a/bin/rename.rb +++ b/bin/rename.rb @@ -1,7 +1,7 @@ #!/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 diff --git a/locopy/bin/locopy.rb b/locopy/bin/locopy.rb index 933789b..f726210 100755 --- a/locopy/bin/locopy.rb +++ b/locopy/bin/locopy.rb @@ -1,4 +1,7 @@ #!/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/. require 'pathname' require 'mysql2'