![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Absolute Beginner Talk The perfect starting place to find out more about computers, Linux and Ubuntu. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
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()
Last edited by geb666; August 3rd, 2008 at 03:15 PM.. Reason: adding solved and thread links |
|
|
|
|
|
#2 |
|
a luminous zuminous horoscope fish
![]() 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.
|
|
|
|
|
|
#3 |
|
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.. |
|
|
|
|
|
#4 |
|
5 Cups of Ubuntu
![]() |
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! Last edited by jmdsdf; October 26th, 2009 at 09:33 PM.. Reason: Updated script (thanks SabreWolfy/gueba/Pitxyoki/ebento/l-x-l!/eldon.t) |
|
|
|
|
|
#5 |
|
First Cup of Ubuntu
![]() Join Date: Feb 2009
Beans: 2
|
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! |
|
|
|
|
|
#6 | |
|
Iced Blended Vanilla Crème Ubuntu
![]() 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:
__________________
"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." |
|
|
|
|
|
|
#7 |
|
5 Cups of Ubuntu
![]() |
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. |
|
|
|
|
|
#8 |
|
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! |
|
|
|
|
|
#9 |
|
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?
|
|
|
|
|
|
#10 |
|
Gee! These Aren't Roasted!
![]() Join Date: Apr 2008
Beans: 170
Ubuntu 9.10 Karmic Koala
|
<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.. |
|
|
|
| Bookmarks |
| Tags |
| bitrate, columns, mp3, nautilus |
| Thread Tools | |
| Display Modes | |
|
|