unitf-tag 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e8a3abd8e593009ee730ed4ee98c85f9f0b5665cdccf7ac1ea68b0f29e793a6
4
- data.tar.gz: 2b62f8700524ba32f9961b14c129869a98b4e0fbf304c05173f9e059820d8bb3
3
+ metadata.gz: 06c56d0fa1fc49c5a570c177637c1b7c036bda285d36d5ae8281086081cf9626
4
+ data.tar.gz: a3694678b4751cb0d454729bec368954a3092ec074e447e964b183cb80f83273
5
5
  SHA512:
6
- metadata.gz: d5a1dd21d9cddb72642a99e8d0f1274f6e95a3fc76e80d9bb71838c6addc201814ac3dd0ff1d38482af6464ab37eddd5cd643d70240bf7fdf5fba80866d9c156
7
- data.tar.gz: 6e7d036234644964322c41dd0dcc4d8e9982c76c6abc4dd430c28a88431f635194da76826c153dcd249b6c0e4a0d26c2e2892b74f75f8063d7ece32fdb99cca7
6
+ metadata.gz: 3cf9edd750d87169f314adc4280c5820b66c40de4d23a4b0ab7df2385719472e6178b4e259996317f271063624e205990ef53937b3998a1b2ab69c5608289979
7
+ data.tar.gz: 80f6a13bb946ec007218efe31733b349da349f0f62486a26bb4ab1dd9e06b93755f1e39b95ce0209e31605bed12042265194fd38777132b16d46c794f02e2740
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # UnitF::Tag
2
2
 
3
+ ## v0.2.1
4
+ - Add `UnitF::Tag.auto_track`
5
+ - Add `UnitF::Tag.open`
6
+
3
7
  ## v0.2.0
4
8
  - `UnitF::Tag::File` no longer inherits anything]
5
9
  - Spec Tests
data/bin/test.rb CHANGED
@@ -4,7 +4,4 @@ require 'unitf/tag'
4
4
 
5
5
  UnitF::Log.to_console
6
6
 
7
- UnitF::Tag.update('test-data/song.mp3') do |file|
8
- puts "FILE: #{file}"
9
- file.tag.artist = "Update #{Time.now.to_s}"
10
- end
7
+ UnitF::Tag.auto_track(dir: '/Users/mbaron/music2/WFMU/BJ/2025')
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Unitf
4
4
  module Tag
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
data/lib/unitf/tag.rb CHANGED
@@ -19,6 +19,12 @@ module UnitF
19
19
  end
20
20
  end
21
21
 
22
+ def open(file_path)
23
+ UnitF::Tag::File.new(file_path).open do |file|
24
+ yield file
25
+ end
26
+ end
27
+
22
28
  def list(files, format: :json)
23
29
  buff = []
24
30
  files.each do |file|
@@ -35,9 +41,32 @@ module UnitF
35
41
  end
36
42
  puts JSON.pretty_generate(buff) if format == :json
37
43
  end
44
+
45
+ def auto_track(dir:)
46
+ UnitF::Log.info("Auto track #{dir}")
47
+ track = 1
48
+
49
+ Dir.glob("#{dir}/*.mp3").sort.each do |file_path|
50
+ if ::File.basename(file_path).match?(/^\d+(\s|\.|-)/)
51
+ UnitF::Log.warn("Skipping #{file_path}")
52
+ next
53
+ end
54
+
55
+ UnitF::Tag.open(file_path) do |file|
56
+ if file.tag.track != track
57
+ UnitF::Log.info("Setting track to #{track} #{file_path}")
58
+ file.tag.track = track
59
+ file.save
60
+ end
61
+ end
62
+
63
+ track += 1
64
+ end
65
+ end
38
66
  end
39
67
 
40
68
  class Error < StandardError; end
69
+
41
70
  class MissingCover < Error; end
42
71
  end
43
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unitf-tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Baron