Posts Tagged ‘ruby’

simple is beautiful - command line id3 tagging

Sunday, March 16th, 2008

generally speaking, my set of mp3s is very well tagged. for my personal mp3s, i used to exclusively use easytag to tag them, and now i use a combination of easytag and amarok (which is totally awesome by the way!)

but sometimes, i have to mass edit id3tags for mp3s on the server, and i don't have the luxury of using such gui tools for the editing. as thus, i've been mainly using id3v2 within some perl scripts to tag mp3s. this turns out to work great, but i also wanted to be able to add album art to the mp3s from the command line.

i couldn't figure out how to do it using id3v2 (perhaps using the custom frames, there's a way, but nothing extremely simple and obvious from what i was looking at). then i found the solution in the form of a id3lib-ruby, a ruby wrapper for id3lib, the same library that id3v2 is based on.

with this, everything turns out to be extremely easy -

 
require 'id3lib'
 
tag = ID3Lib::Tag.new('myfile.mp3')
cover = {
   :id => :APIC,
   :mimetype => 'image/jpeg',
   :picturetype => 3,
   :data => File.read('cover.jpg')
}
 
tag << cover
tag.update!

and that's it. nice and simple. by the way, a picturetype of 3 denotes a front cover and is the default value (just learned that from a quick search). oh and the output mp3 image cover shows up fine in both linux and on itunes. beautiful!

ruby and rcairo

Wednesday, May 9th, 2007

i've recently been playing more and more with ruby and i really like it. at the same time, i've been loving launchy, an open source application launcher for windows (currently using it on my work laptop).

since i love launchy so much, i started to wonder, "why not write something similar for linux?" - now i know one will say that deskbar does the job, but its not quite the same. so anyway, because i wanted transparency and so on, i decided to look into cairo, and the rcairo ruby bindings.

here's a screenshot of what i've been playing with so far:

rcairo demo

note the very right side is the part showing of my open gvim window. while i have yet to organize the code and start writing it for real, the ruby file i have is a proof of concept of all the required pieces i can think of (cairo wise anyway) working together.

hitchhiker’s guide, ruby mozembed

Friday, September 9th, 2005

"Space is big. You just won't believe how vastly, hugely, mind- bogglingly big it is. I mean, you may think it's a long way down the road to the chemist's, but that's just peanuts to space."

i finally got around to reading the hitchhiker's guide to the galaxy. really funny book. maybe i will try to read the other books at some point.

i played around some today with ruby-gnome2 bindings. all i can say is wow. the website documentation is incredible, and you can do so much in so little code. i played around some with ruby-gtkmozembed, and in a few lines of code, you basically have a fully functional webbrowser.

 
require 'gtkmozembed'
 
class Main
def initialize
Gtk.init
window = Gtk::Window.new
window.resize(800, 600)
window.title = "ahmed's google test"
 
browser = Gtk::MozEmbed.new
browser.chrome_mask = Gtk::MozEmbed::ALLCHROME
browser.location = "http://www.google.com"
browser.signal_connect("title"){
window.title = browser.title;
}
 
window < < browser
window.show_all
window.signal_connect("destroy"){ Gtk::main_quit }
end
end
 
Main.new
Gtk.mai

that's all for now.