Skip to content

Commit

Permalink
First commit. Adds hard-coded tags and artwork from sample.png to sam…
Browse files Browse the repository at this point in the history
…ple.mp3.
  • Loading branch information
ngreenstein committed Jun 11, 2012
0 parents commit 89860c5
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitignore
@@ -0,0 +1,21 @@
# custom
sample copy.mp3

# osx noise
.DS_Store
profile

# xcode noise
build/*
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
xcuserdata

# svn & cvs
.svn
CVS
39 changes: 39 additions & 0 deletions main.rb
@@ -0,0 +1,39 @@
### Depends on: ###
# taglib: http://developer.kde.org/~wheeler/taglib.html `brew install taglib`
# taglib-ruby: http://robinst.github.com/taglib-ruby/ `gem install taglib-ruby`

require 'rubygems'
require 'taglib'

#Define attributes
title = "Track Name Goes Here"
artist = "Artist Goes Here"
album = "Album Goes Here"
year = 2012
track_number = 1
genre = "Genre Goes Here"

#Open file
TagLib::MPEG::File.open("sample.mp3") do |file|
tag = file.id3v2_tag(true)

# Set attributes
tag.title = title
tag.artist = artist
tag.album = album
tag.year = year
tag.track = track_number
tag.genre = genre

#Add artwork
artframe = TagLib::ID3v2::AttachedPictureFrame.new
artframe.mime_type = "image/png"
artframe.description = "Cover"
artframe.type = TagLib::ID3v2::AttachedPictureFrame::FrontCover
artframe.picture = File.open("sample.png", 'rb') { |f| f.read }

tag.add_frame(artframe)

#Save file
file.save
end
Binary file added sample.mp3
Binary file not shown.
Binary file added sample.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 89860c5

Please sign in to comment.