Class: AutoTune::Designator
- Inherits:
-
Object
- Object
- AutoTune::Designator
- Defined in:
- lib/autotune/designator.rb
Class Method Summary collapse
- .set_album(album, song) ⇒ Object
- .set_album_artist_name(album_artist, song) ⇒ Object
- .set_all(tune_tags, song) ⇒ Object
- .set_artist(artist, song) ⇒ Object
- .set_artist_id(artist_id, song) ⇒ Object
- .set_artwork(artwork, song) ⇒ Object
- .set_catalogue_id(catalogue_id, song) ⇒ Object
- .set_composer(composer, song) ⇒ Object
- .set_composer_id(composer_id, song) ⇒ Object
- .set_copyright(copyright, song) ⇒ Object
- .set_disk_number(disk_number, total_disks, song) ⇒ Object
- .set_genre(genre, song) ⇒ Object
- .set_genre_id(genre_id, song) ⇒ Object
- .set_playlist_id(playlist_id, song) ⇒ Object
- .set_rating(rating, song) ⇒ Object
- .set_release_date(release_date, song) ⇒ Object
- .set_tempo(tempo, song) ⇒ Object
- .set_title(title, song) ⇒ Object
- .set_track_number(track_number, total_tracks, song) ⇒ Object
- .track_number(track_number, song) ⇒ Object
Class Method Details
.set_album(album, song) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/autotune/designator.rb', line 58 def self.set_album(album, song) if File.exists? song TagLib::FileRef.open(song) do |tune| unless tune.null? tune.tag.album = album unless album.nil? tune.save end end end end |
.set_album_artist_name(album_artist, song) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/autotune/designator.rb', line 170 def self.set_album_artist_name(album_artist, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless album_artist.nil? item = TagLib::MP4::Item.from_string_list([album_artist]) tune.tag.item_list_map.insert('aART', item) tune.save end end end end end |
.set_all(tune_tags, song) ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/autotune/designator.rb', line 296 def self.set_all(, song) set_artist_id(.at(0), song) set_playlist_id(.at(1), song) set_catalogue_id(.at(2), song) set_artist(.at(3), song) set_album(.at(4), song) set_title(.at(5), song) set_release_date(.at(7), song) (.at(9), song) set_disk_number(.at(11), .at(10), song) set_track_number(.at(13), .at(12), song) set_genre(.at(17), song) set_album_artist_name(.at(19), song) set_genre_id(.at(20), song) set_copyright(.at(21), song) set_composer('', song) set_artwork('/var/tmp/artwork.jpg', song) end |
.set_artist(artist, song) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/autotune/designator.rb', line 47 def self.set_artist(artist, song) if File.exists? song TagLib::FileRef.open(song) do |tune| unless tune.null? tune.tag.artist = artist unless artist.nil? tune.save end end end end |
.set_artist_id(artist_id, song) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/autotune/designator.rb', line 5 def self.set_artist_id(artist_id, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless artist_id.nil? item = TagLib::MP4::Item.from_int(artist_id) tune.tag.item_list_map.insert('atID', item) tune.save end end end end end |
.set_artwork(artwork, song) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/autotune/designator.rb', line 140 def self.set_artwork(artwork, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless artwork.nil? image_data = File.open(artwork, 'rb') { |f| f.read } cover_art = TagLib::MP4::CoverArt.new(TagLib::MP4::CoverArt::JPEG, image_data) item = TagLib::MP4::Item.from_cover_art_list([cover_art]) tune.tag.item_list_map.insert('covr', item) tune.save end end end end end |
.set_catalogue_id(catalogue_id, song) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/autotune/designator.rb', line 33 def self.set_catalogue_id(catalogue_id, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless catalogue_id.nil? item = TagLib::MP4::Item.from_int(catalogue_id) tune.tag.item_list_map.insert('cnID', item) tune.save end end end end end |
.set_composer(composer, song) ⇒ Object
282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/autotune/designator.rb', line 282 def self.set_composer(composer, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless composer.nil? item = TagLib::MP4::Item.from_string_list([composer]) tune.tag.item_list_map.insert('©wrt', item) tune.save end end end end end |
.set_composer_id(composer_id, song) ⇒ Object
240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/autotune/designator.rb', line 240 def self.set_composer_id(composer_id, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless composer_id.nil? item = TagLib::MP4::Item.from_int(composer_id) tune.tag.item_list_map.insert('cmID', item) tune.save end end end end end |
.set_copyright(copyright, song) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/autotune/designator.rb', line 156 def self.set_copyright(copyright, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless copyright.nil? item = TagLib::MP4::Item.from_string_list([copyright]) tune.tag.item_list_map.insert('cprt', item) tune.save end end end end end |
.set_disk_number(disk_number, total_disks, song) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/autotune/designator.rb', line 212 def self.set_disk_number(disk_number, total_disks, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless disk_number.nil? || total_disks.nil? item = TagLib::MP4::Item.from_int_pair([disk_number, total_disks]) tune.tag.item_list_map.insert('disk', item) tune.save end end end end end |
.set_genre(genre, song) ⇒ Object
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/autotune/designator.rb', line 118 def self.set_genre(genre, song) if File.exists? song TagLib::FileRef.open(song) do |tune| unless tune.null? tune.tag.genre = genre unless genre.nil? tune.save end end end end |
.set_genre_id(genre_id, song) ⇒ Object
254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/autotune/designator.rb', line 254 def self.set_genre_id(genre_id, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless genre_id.nil? item = TagLib::MP4::Item.from_int(genre_id) tune.tag.item_list_map.insert('geID', item) tune.save end end end end end |
.set_playlist_id(playlist_id, song) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/autotune/designator.rb', line 19 def self.set_playlist_id(playlist_id, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless playlist_id.nil? item = TagLib::MP4::Item.from_int(playlist_id) tune.tag.item_list_map.insert('plID', item) tune.save end end end end end |
.set_rating(rating, song) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/autotune/designator.rb', line 94 def self.(, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless .nil? if .include? 'clean' item = TagLib::MP4::Item.from_int(2) tune.tag.item_list_map.insert('rtng', item) tune.save elsif .include? 'explicit' item = TagLib::MP4::Item.from_int(1) tune.tag.item_list_map.insert('rtng', item) tune.save elsif .include? 'notExplicit' item = TagLib::MP4::Item.from_int(0) tune.tag.item_list_map.insert('rtng', item) tune.save end end end end end end |
.set_release_date(release_date, song) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/autotune/designator.rb', line 80 def self.set_release_date(release_date, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless release_date.nil? item = TagLib::MP4::Item.from_string_list([release_date]) tune.tag.item_list_map.insert('©day', item) tune.save end end end end end |
.set_tempo(tempo, song) ⇒ Object
268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/autotune/designator.rb', line 268 def self.set_tempo(tempo, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless tempo.nil? item = TagLib::MP4::Item.from_int(tempo) tune.tag.item_list_map.insert('tmpo', item) tune.save end end end end end |
.set_title(title, song) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/autotune/designator.rb', line 69 def self.set_title(title, song) if File.exists? song TagLib::FileRef.open(song) do |tune| unless tune.null? tune.tag.title = title unless title.nil? tune.save end end end end |
.set_track_number(track_number, total_tracks, song) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/autotune/designator.rb', line 198 def self.set_track_number(track_number, total_tracks, song) if File.exists? song if song =~ /.*\.M4A$/i TagLib::MP4::File.open(song) do |tune| unless track_number.nil? || total_tracks.nil? item = TagLib::MP4::Item.from_int_pair([track_number, total_tracks]) tune.tag.item_list_map.insert('trkn', item) tune.save end end end end end |
.track_number(track_number, song) ⇒ Object
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/autotune/designator.rb', line 129 def self.track_number(track_number, song) if File.exists? song TagLib::FileRef.open(song) do |tune| unless tune.null? tune.tag.track = track_number unless track_number.nil? tune.save end end end end |