Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Absolute Beginner Talk
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Absolute Beginner Talk
The perfect starting place to find out more about computers, Linux and Ubuntu.

 
Thread Tools Display Modes
Old August 3rd, 2008   #1
geb666
First Cup of Ubuntu
 
Join Date: Aug 2008
Beans: 2
[SOLVED] Adding mp3 info columns (e.g. bitrate, etc.) to nautilus list view

Here's a solution I found to a problem some people posted about in these threads, however, I can't seem to reply to those posts so I'm creating this new thread. First, you need to install python-nautilus and python-mutagen. You might have to add the python-nautilus library path to the PYTHONPATH variable. Then create a directory called python-extensions in ~/.nautilus. Put the script below in that directory in a file called bsc.py or you can download the attachment. Remember that python uses tabs for defining scope, so if you copy and paste the script below then you'll have to replace the spaces with tabs. Finally, restart nautilus. That should do it.

P.S. I took the code from this post and modified it.


Code:
import os
import urllib
import nautilus
from mutagen.easyid3 import EasyID3
from mutagen.mp3 import MPEGInfo

class ColumnExtension(nautilus.ColumnProvider, nautilus.InfoProvider):
        def __init__(self):
                pass

        def get_columns(self):
                return (nautilus.Column("NautilusPython::title_column",
                                "title",
                                "Title",
                                "Song title"),
                nautilus.Column("NautilusPython::album_column",
                                "album",
                                "Album",
                                "Album"),
                nautilus.Column("NautilusPython::artist_column",
                                "artist",
                                "Artist",
                                "Artist"),
                nautilus.Column("NautilusPython::bitrate_column",
                                "bitrate",
                                "Bitrate",
                                "Bitrate"),)

        def update_file_info(self, file):
                if file.get_uri_scheme() != 'file':
                        return
                if file.is_mime_type('audio/mpeg'):
                        filename = urllib.unquote(file.get_uri()[7:])
                        audio = EasyID3(filename)

                if (os.path.isfile (filename)):
                        mpfile = open (filename)
                        mpinfo = MPEGInfo (mpfile)
                        br = str(mpinfo.bitrate/1000) + " Kbps"
                else:
                        br = ""

                file.add_string_attribute('title', audio["title"][0])
                file.add_string_attribute('album', audio["album"][0])
                file.add_string_attribute('artist', audio["artist"][0])
                file.add_string_attribute('bitrate', br)
                self.get_columns()
Attached Files
File Type: py bsc.py (1.2 KB, 194 views)

Last edited by geb666; August 3rd, 2008 at 03:15 PM.. Reason: adding solved and thread links
geb666 is offline   Reply With Quote
Old August 3rd, 2008   #2
forestpiskie
a luminous zuminous horoscope fish
 
forestpiskie's Avatar
 
Join Date: May 2007
Location: The New Forest
Beans: 6,590
Ubuntu 9.10 Karmic Koala
Re: Adding mp3 info columns (e.g. bitrate, etc.) to nautilus list view

It could be that the original thread is in the archive - perhaps you could link to it so others can see.

Could you also mark the thread as solved - it appeared that the thread was an unanswered support request, thanks.
__________________
The solved tool has come back - Thread Tools

You can visit #ubuntu-beginners-help on irc.freenode.net for real time help

A computer is a means to an end. The person you're helping probably cares mostly about the end. This is reasonable.
By the time they ask you for help, they've probably tried several things. As a result, their computer might be in a strange state. This is natural.
forestpiskie is online now   Reply With Quote
Old January 20th, 2009   #3
darrell_123
First Cup of Ubuntu
 
Join Date: Jan 2009
Beans: 2
Re: [SOLVED] Adding mp3 info columns (e.g. bitrate, etc.) to nautilus list view

Geb - worked like a charm. This was driving me crazy. Thanks so much for posting it. The only thing I noticed is it doesn't seem to work on network shared folders.

Last edited by darrell_123; January 20th, 2009 at 11:26 PM..
darrell_123 is offline   Reply With Quote
Old January 30th, 2009   #4
jmdsdf
5 Cups of Ubuntu
 
Join Date: Sep 2008
Location: Kingston, Canada
Beans: 35
Kubuntu 9.10 Karmic Koala
Send a message via ICQ to jmdsdf Send a message via AIM to jmdsdf Send a message via MSN to jmdsdf Send a message via Yahoo to jmdsdf
Re: [SOLVED] Adding mp3 info columns (e.g. bitrate, etc.) to nautilus list view

I love this solution! Thanks guys! It was, however, missing one critical feature for me. It was missing a way to show the ID3 date tag. I've updated the script a bit, and here is my revision:

It would be great if this script were also updated with support for displaying JPEG EXIF shooting data. I, unfortunately, am not a Python wizard.

UPDATE: I have tried my best and updated this script with EXIF shooting information! It seems to work okay!

UPDATE #2: It now works better! Sometimes mp3 info was there but not getting filled in, also mp3 length support is now added.

UPDATE #3: Thanks to SabreWolfy for finding another unhandled exception!

UPDATE #4: Thanks to gueba for discovering this script wasn't properly closing file handles until it terminates

UPDATE #5: Thanks to Pitxyoki for discovering this script wasn't properly closing file handles if there's an exception

UPDATE #6 (9/17/2009): Thanks to enbeto for finding a way to read video information!

UPDATE #7 (9/23/2009): This is now in a Debian package for easy installation. I have kept the bsc-v2.py source attached in case anyone wants to review it. This is my first attempt at a Debian package, so please be nice in criticisms!

UPDATE #8 (9/27/2009): Updated nautilus-columns to support ID3 tags in FLAC, thanks l-x-l!

UPDATE #9 (10/5/2009): MKV support added. Version bump to 0.01.

UPDATE #10 (10/6/2009): postinit script automatically restarts Nautilus so options can be seen without logging in and logging out. Thanks thegutterpoet!

UPDATE #10 (10/26/2009): album/date added for FLAC/video. Thanks eldon.t!
Attached Files
File Type: py bsc-v2.py (8.8 KB, 64 views)
File Type: deb nautilus-columns-0.01.deb (3.5 KB, 195 views)

Last edited by jmdsdf; October 26th, 2009 at 09:33 PM.. Reason: Updated script (thanks SabreWolfy/gueba/Pitxyoki/ebento/l-x-l!/eldon.t)
jmdsdf is offline   Reply With Quote
Old February 2nd, 2009   #5
mrucci
First Cup of Ubuntu
 
Join Date: Feb 2009
Beans: 2
Question Re: [SOLVED] Adding mp3 info columns (e.g. bitrate, etc.) to nautilus list view

Can someone help me please?

ID3 tag organization columns are necessary.
I have followed this tutorial and used both provided files, the original and the edited one, neither work for me. I created the directory under /.nautilus, places the file there, and restarted nautilus. nothing happens.
One thing I do not understand is the lin in the instructions stating to change a path in capital letters?

please help the noob!
mrucci is offline   Reply With Quote
Old February 2nd, 2009   #6
jerome1232
Iced Blended Vanilla Crème Ubuntu
 
jerome1232's Avatar
 
Join Date: Dec 2007
Location: California
Beans: 2,929
Ubuntu 9.04 Jaunty Jackalope
Re: [SOLVED] Adding mp3 info columns (e.g. bitrate, etc.) to nautilus list view

Quote:
Originally Posted by mrucci View Post
Can someone help me please?

ID3 tag organization columns are necessary.
I have followed this tutorial and used both provided files, the original and the edited one, neither work for me. I created the directory under /.nautilus, places the file there, and restarted nautilus. nothing happens.
One thing I do not understand is the lin in the instructions stating to change a path in capital letters?

please help the noob!
One important detail, did you put it under /.nautilus or ~/.nautilus, they are two very different places on your file system.
__________________
"You can't expect to hold supreme executive power just because some watery tart lobbed a sword at you"

"Don't let your mind wander -- it's too little to be let out alone."
jerome1232 is offline   Reply With Quote
Old February 2nd, 2009   #7
jmdsdf
5 Cups of Ubuntu
 
Join Date: Sep 2008
Location: Kingston, Canada
Beans: 35
Kubuntu 9.10 Karmic Koala
Send a message via ICQ to jmdsdf Send a message via AIM to jmdsdf Send a message via MSN to jmdsdf Send a message via Yahoo to jmdsdf
Re: Adding mp3 info columns (e.g. bitrate, etc.) to nautilus list view

mrucci, ensure all the dependencies are present, ensure that the script goes into ~/.nautilus/python-extensions/ or /usr/lib/nautilus/extensions-2.0/python/. Make sure you restart Nautilus (I just run "killall nautilus" from the terminal, or run dialog, i.e. Alt-F2). Then open Nautilus, and under Edit | Preferences | List Columns, you should see the extra columns. I hope this helps!

Btw, I updated the script with some more field I hope these will help everyone with managing photos with meta data. One shortcoming I have noticed is that Nautilus, unlike Windows Explorer, does not remember which folders should have which column headers. Oh well. A small annoyance, but not a critical one.
jmdsdf is offline   Reply With Quote
Old February 2nd, 2009   #8
mrucci
First Cup of Ubuntu
 
Join Date: Feb 2009
Beans: 2
Re: [SOLVED] Adding mp3 info columns (e.g. bitrate, etc.) to nautilus list view

Aahh! Thank you so much! It works now! one thing I passed was that there are instructions in the py file. need to read more.

But yes, I think my directory orientation was off.

Thanks for the help everyone, working great now!
mrucci is offline   Reply With Quote
Old February 4th, 2009   #9
SpetsnazC4
Spilled the Beans
 
Join Date: Dec 2007
Beans: 14
Re: [SOLVED] Adding mp3 info columns (e.g. bitrate, etc.) to nautilus list view

Thanks for this great post! It's just what I need. Is there a way to view the mp3 track length/duration in a column?
SpetsnazC4 is offline   Reply With Quote
Old February 5th, 2009   #10
SabreWolfy
Gee! These Aren't Roasted!
 
SabreWolfy's Avatar
 
Join Date: Apr 2008
Beans: 170
Ubuntu 9.10 Karmic Koala
Question Re: [SOLVED] Adding mp3 info columns (e.g. bitrate, etc.) to nautilus list view

<Experienced difficulties installing and using the script, but resolved them (my errors). Previous post here deleted.>

Last edited by SabreWolfy; February 5th, 2009 at 05:50 PM..
SabreWolfy is offline   Reply With Quote

Bookmarks

Tags
bitrate, columns, mp3, nautilus

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:49 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry