got_mp3 0.1.1 → 0.1.2

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: 838f650beb51908cd19f1c17ea92c14fc017311a27294e1870f65ba5910110e2
4
- data.tar.gz: 79bc380538aa93ebd4ecc1e007699cad0d1f01f0082c85a7077d1ca2ae52c7dd
3
+ metadata.gz: 03c18932de3d7bcf55555f98c7b4fc677ac64b2262e63330c3629c4bca334d60
4
+ data.tar.gz: 595b8aaaa06da6d1f61fefa3605f8ea446952c26e0022f1607d07ad2d2d494e2
5
5
  SHA512:
6
- metadata.gz: '09309170f4a66c730c1e1a7dca2c27a67a65576eac016b7f8808301d2378cf859b42971661dabb18571e1e6c46cfd865955ba5b35cf4ef6af36a214edcf85ed5'
7
- data.tar.gz: 12f09a40443a40ed6524107b98fb984afce361a721af3584324401cbde2f7e5b60a2ef85000fcfee7dad2bc052306041d212f7fd962dedb7ae24a477f030c225
6
+ metadata.gz: 29561bc4eacd3a9a17149260c2bb4a1cf504894b09468e8eac7e99ce5a5f94cacf87bbdcd7b12d7017d5e19a157457894c4cb72b31f7cbce778a1e5276dff55f
7
+ data.tar.gz: 745f2418ed072cb0b22e74934d996e62daca4b726f90bed3ed7af2d8b528c6bdc3524019b49291b187b039e73cbe4014b5c509f1b9175a7ceba4e0b21bcd3ec2
checksums.yaml.gz.sig CHANGED
@@ -1,4 +1,2 @@
1
- �+�4�ce��ktf��ZR�˸�YV,y.fc
2
- 0,��Nj'
3
- �V
4
- �5�0
1
+ |��H A{CYK�`6�y�qDJ��
2
+ n"]������Qb��K J ��sy`�@�1��/8���;��B�y��@ ��H�����fè��ou�K@q�f�<3���ls@����a?�/�����6���~�x�.6:E��"쓺u� � �1'q��w@ΧU*�F]HI�7��j
data/lib/got_mp3.rb CHANGED
@@ -40,8 +40,24 @@ class GotMP3
40
40
 
41
41
  end
42
42
 
43
- #def go()
44
- #end
43
+ # Adds the album art, track title, and renames the MP3 file
44
+ #
45
+ def go()
46
+
47
+ find_by_ext('.mp3').each do |directory, _ |
48
+
49
+ # find the image file
50
+ img_filename = Dir[File.join(directory, '*.jpg')].first
51
+
52
+ # find the text file
53
+ txt_filename = Dir[File.join(directory, '*.txt')].first
54
+ next unless txt_filename
55
+
56
+ add_image_and_titles(directory, img_filename, txt_filename)
57
+
58
+ end
59
+
60
+ end
45
61
 
46
62
  private
47
63
 
@@ -73,25 +89,29 @@ class GotMP3
73
89
  end
74
90
  end
75
91
 
76
- def add_image_and_titles(directory, img_filename, txt_filename)
92
+ def add_image_and_titles(directory, img_file, txt_file)
77
93
 
78
- image_file = File.new(File.join(directory, img_filename),'rb')
79
- img = image_file.read
94
+ if img_file then
95
+ img = File.new(img_file,'rb').read
96
+ end
80
97
 
81
- txt_file = File.join(directory, txt_filename)
82
98
  track_titles = File.read(txt_file).lines[1..-1].map(&:strip)
83
99
 
84
100
  found = Dir[File.join(directory, "*.mp3")].sort_by { |x| File.mtime(x) }
85
101
  found.each.with_index do |mp3_filepath, i|
86
102
 
87
103
  Mp3Info.open(mp3_filepath) do |mp3|
88
- mp3.tag2.remove_pictures
89
- mp3.tag2.add_picture img
90
- mp3.tag.title = track_titles[trackno-1]
104
+
105
+ if img_file then
106
+ mp3.tag2.remove_pictures
107
+ mp3.tag2.add_picture img
108
+ end
109
+
110
+ mp3.tag.title = track_titles[i]
91
111
  end
92
112
 
93
113
  File.rename(mp3_filepath, File.join(directory,
94
- track_titles[i][/^[^\/]+/].gsub(/\W/,'').rstrip + '.mp3'))
114
+ track_titles[i][/^[^\/]+/].gsub(/:/,'_').rstrip + '.mp3'))
95
115
  end
96
116
 
97
117
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: got_mp3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- �٠�">��ievjj�O̜ld���_���,�)�aϵ�8
1
+ F2���)x70�#SOZe��}#�\i��a| ��*�*`.-�Jo'�%��ގ ֕�f��`ZU1��5��������9\��Z) ^sYJ�(�|���� �AX9���B|��kVWic�^�Q!����.=�X��O��GC�f�"xx��S`�L�2�s�Y�����l6 vձ{z0MZ*�:��3i�K w� ��7��
2
+ ��%�F;܁�g��_�� ��t� d�-�x�\