Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60523 > unrolled thread

Access and write .mp3 metadata/tags using Python 3

Started byandonefilms@gmail.com
First post2013-11-26 07:41 -0800
Last post2013-11-27 10:20 +1000
Articles 6 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Access and write .mp3 metadata/tags using Python 3 andonefilms@gmail.com - 2013-11-26 07:41 -0800
    Re: Access and write .mp3 metadata/tags using Python 3 Tim Chase <python.list@tim.thechases.com> - 2013-11-26 09:59 -0600
      Re: Access and write .mp3 metadata/tags using Python 3 andonefilms@gmail.com - 2013-11-26 09:10 -0800
        Re: Access and write .mp3 metadata/tags using Python 3 Michael Torrie <torriem@gmail.com> - 2013-11-26 10:22 -0700
    Re: Access and write .mp3 metadata/tags using Python 3 Michael Torrie <torriem@gmail.com> - 2013-11-26 09:41 -0700
    Re: Access and write .mp3 metadata/tags using Python 3 alex23 <wuwei23@gmail.com> - 2013-11-27 10:20 +1000

#60523 — Access and write .mp3 metadata/tags using Python 3

Fromandonefilms@gmail.com
Date2013-11-26 07:41 -0800
SubjectAccess and write .mp3 metadata/tags using Python 3
Message-ID<07682b1c-ae9a-4d0b-878e-abef0eb15f8a@googlegroups.com>
Hey everyone.

I'm trying to figure out how to get python to access the properties section of an mp3 file. When you right click an mp3 file and go to properties you can edit the title, album, and things like that.  I also want to be able to read the length of the mp3.

Is there a pythonic way to do this? I asked a professor of mine and he said to look into the OS module. 

Any help is much appreciated!

Thank you

Tyler

[toc] | [next] | [standalone]


#60524

FromTim Chase <python.list@tim.thechases.com>
Date2013-11-26 09:59 -0600
Message-ID<mailman.3247.1385481459.18130.python-list@python.org>
In reply to#60523
On 2013-11-26 07:41, andonefilms@gmail.com wrote:
> Hey everyone.
> 
> I'm trying to figure out how to get python to access the properties
> section of an mp3 file. When you right click an mp3 file and go to
> properties you can edit the title, album, and things like that.  I
> also want to be able to read the length of the mp3.
> 
> Is there a pythonic way to do this? I asked a professor of mine and
> he said to look into the OS module. 

There are a couple libraries that ease that[1].  Matters are
complicated by the fact that there are two different versions of ID3
tags, v1 and v2.  However most of those libraries should handle them
just fine.

Also, I don't believe that the playtime length is actually encoded in
the file itself, so you might have to do some calculations to find
that.  I've wondered this myself and would be interested to learn
more.  You might look at[2] which seems to offer code using one of
those modules.

Based on the two links, it looks like Mutagen might be the first stop
for getting both parts that you need.

-tkc


[1]
https://wiki.python.org/moin/UsefulModules#ID3_Handling

[2]
http://stackoverflow.com/questions/6037826/finding-the-length-of-an-mp3-file


[toc] | [prev] | [next] | [standalone]


#60527

Fromandonefilms@gmail.com
Date2013-11-26 09:10 -0800
Message-ID<e5a2cc22-5ccd-4061-80b1-2fd5b7a55557@googlegroups.com>
In reply to#60524
> 
> There are a couple libraries that ease that[1].  Matters are
> 
> complicated by the fact that there are two different versions of ID3
> 
> tags, v1 and v2.  However most of those libraries should handle them
> 
> just fine.
> 
> 
> 
> Also, I don't believe that the playtime length is actually encoded in
> 
> the file itself, so you might have to do some calculations to find
> 
> that.  I've wondered this myself and would be interested to learn
> 
> more.  You might look at[2] which seems to offer code using one of
> 
> those modules.
> 
> 
> 
> Based on the two links, it looks like Mutagen might be the first stop
> 
> for getting both parts that you need.
> 
> 
> 
> -tkc
> 
> 
> 
> 
> 
> [1]
> 
> https://wiki.python.org/moin/UsefulModules#ID3_Handling
> 
> 
> 
> [2]
> 
> http://stackoverflow.com/questions/6037826/finding-the-length-of-an-mp3-file

I'm still a bit new to this.  When I download a module like Mutagen and unzip it I have a folder and tons of files within folders?  I see no file simply called mutagen?  So how can I import the module?

[toc] | [prev] | [next] | [standalone]


#60528

FromMichael Torrie <torriem@gmail.com>
Date2013-11-26 10:22 -0700
Message-ID<mailman.3250.1385486570.18130.python-list@python.org>
In reply to#60527
On 11/26/2013 10:10 AM, andonefilms@gmail.com wrote:
> I'm still a bit new to this.  When I download a module like Mutagen
> and unzip it I have a folder and tons of files within folders?  I see
> no file simply called mutagen?  So how can I import the module?

Also you can install many things using python's built-in package manager:

pip-python install mutagen

[toc] | [prev] | [next] | [standalone]


#60525

FromMichael Torrie <torriem@gmail.com>
Date2013-11-26 09:41 -0700
Message-ID<mailman.3248.1385484124.18130.python-list@python.org>
In reply to#60523
On 11/26/2013 08:41 AM, andonefilms@gmail.com wrote:
> I'm trying to figure out how to get python to access the properties
> section of an mp3 file. When you right click an mp3 file and go to
> properties you can edit the title, album, and things like that.  I
> also want to be able to read the length of the mp3.
> 
> Is there a pythonic way to do this? I asked a professor of mine and
> he said to look into the OS module.

A quick google search reveals this for the tags part:
https://wiki.python.org/moin/UsefulModules#ID3_Handling


[toc] | [prev] | [next] | [standalone]


#60557

Fromalex23 <wuwei23@gmail.com>
Date2013-11-27 10:20 +1000
Message-ID<l73dtd$2kt$1@dont-email.me>
In reply to#60523
On 27/11/2013 1:41 AM, andonefilms@gmail.com wrote:
> I also want to be able to read the length of the mp3.

For this, try the eyed3 library:

     >>> import eyed3
     >>> mp3 = eyed3.load(r'pygame\examples\data\house_lo.mp3')
     >>> mp3.info.time_secs
     7

https://pypi.python.org/pypi/eyeD3/0.7.4

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web