# Adding new fields for import & tagging

**URL:** <https://discourse.beets.io/t/adding-new-fields-for-import-tagging/978>\
**Category:** Help\
**Created:** [October 24, 2019, 4:15am UTC](https://discourse.beets.io/t/adding-new-fields-for-import-tagging/978 "2019-10-24T04:15:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![SndChaser](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/sndchaser/32/312_2.png) [@SndChaser](https://discourse.beets.io/u/SndChaser)\
**Post date:** [October 24, 2019, 4:15am UTC](https://discourse.beets.io/t/adding-new-fields-for-import-tagging/978/1 "2019-10-24T04:15:01Z")

</div>

There are three “non-standard” fields that I have come to rely on in my metadata:

copyright  
wwwsource  
wwwfileinfo

The copyright field is just for that: copyright information (if found). The other two fields I map in my tagging software (puddle tag) to be used as:

wwwsource -\> Release Page URL  
wwwfileinfo -\> License (Creative Commons, Artistic, Public Domain, etc.)

I did not find any plugin(s) that would make it easy to add support for handling these fields. So I’ve turned to the plugin writing documentation to see what it would take to implement these fields. Am I correct in believing the section on extending MediaFile is all I would need to follow to write a plugin that could read/write these fields? By adding these fields to the MediaFile class would they be read and stored by the importer?

George

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)\
**Post date:** [October 24, 2019, 10:31am UTC](https://discourse.beets.io/t/adding-new-fields-for-import-tagging/978/2 "2019-10-24T10:31:17Z")

</div>

Yep, that’s all you need!

---

<div class="post-metadata">

**Author:** ![SndChaser](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/sndchaser/32/312_2.png) [@SndChaser](https://discourse.beets.io/u/SndChaser)\
**Post date:** [October 24, 2019, 11:58am UTC](https://discourse.beets.io/t/adding-new-fields-for-import-tagging/978/3 "2019-10-24T11:58:57Z")

</div>

Then, do I need to add them as the ID3v2.4 frames? IE:

wwwfileinfo -\> WOAF  
wwwsource -\> WOAS  
copyright -\> TCOP

And is there some way to alias them? IE, TCOP would be stored under the field name ‘copyright’ so queries would reference copyright instead of TCOP?

George

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)\
**Post date:** [October 24, 2019, 12:32pm UTC](https://discourse.beets.io/t/adding-new-fields-for-import-tagging/978/4 "2019-10-24T12:32:29Z")

</div>

I’m not entirely sure what you’re asking, but the way these things work is that you create an internal beets name for your field, which can be anything you want, and describe how to map those onto actual tags for various formats. Needless to say, the mapping for ID3 and for Vorbis Comments is going to be different. But within beets, you only use the internal name.

---

<div class="post-metadata">

**Author:** ![SndChaser](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/sndchaser/32/312_2.png) [@SndChaser](https://discourse.beets.io/u/SndChaser)\
**Post date:** [October 24, 2019, 1:20pm UTC](https://discourse.beets.io/t/adding-new-fields-for-import-tagging/978/5 "2019-10-24T13:20:07Z")

</div>

We are on the same page… It is the mapping of the ID3/Vorbis Comments to the beets name that I am trying to understand… The reason for the confusion is the documentation example uses “foo” for everything (and since I am not as familiar with the internals of beets and mutagen, this isn’t exactly clear). So, here’s the example, modified for one case:

class FooPlugin(BeetsPlugin):  
def **init** (self):  
field = mediafile.MediaField(  
mediafile.MP3DescStorageStyle(u’WOAF’),  
mediafile.StorageStyle(u’WOAF’)  
)  
self.add\_media\_field(‘license’, field)

Or would I do it like this:

class FooPlugin(BeetsPlugin):  
def **init** (self):  
field = mediafile.MediaField(  
mediafile.MP3DescStorageStyle(u’wwwfileinfo’),  
mediafile.StorageStyle(u’wwwfileinfo’)  
)  
self.add\_media\_field(‘license’, field)

Or do I completely misunderstand this mapping?

George

---

<div class="post-metadata">

**Author:** ![SndChaser](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/sndchaser/32/312_2.png) [@SndChaser](https://discourse.beets.io/u/SndChaser)\
**Post date:** [October 24, 2019, 1:22pm UTC](https://discourse.beets.io/t/adding-new-fields-for-import-tagging/978/6 "2019-10-24T13:22:11Z")

</div>

(Sorry, I forgot to mark the code as pre-formatted so it lost the indentations…)

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)\
**Post date:** [October 24, 2019, 1:34pm UTC](https://discourse.beets.io/t/adding-new-fields-for-import-tagging/978/7 "2019-10-24T13:34:05Z")

</div>

More like the latter, but if you want to use a non-“TXXX” field for ID3, you’ll need a different StorageStyle. To make this work, I think you might want to spend a little while working with the MediaFile source code to understand what the options are.

---

<div class="post-metadata">

**Author:** ![SndChaser](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/sndchaser/32/312_2.png) [@SndChaser](https://discourse.beets.io/u/SndChaser)\
**Post date:** [October 24, 2019, 3:13pm UTC](https://discourse.beets.io/t/adding-new-fields-for-import-tagging/978/8 "2019-10-24T15:13:42Z")

</div>

So, even if mutagen treats the WXXX fields the same as TXXX fields? For example:

mutagen-inspect d01t08\_\_Cousin\_Silas\_\_December\_Falling.mp3  
– d01t08\_\_Cousin\_Silas\_\_December\_Falling.mp3

- MPEG 1 layer 3, 320000 bps (CBR, LAME 3.97.0, -b 320), 44100 Hz, 2 chn, 514.06 seconds (audio/mp3)  
APIC=cover back, (image/jpeg, 2775360 bytes)  
APIC=cover front, (image/jpeg, 2387290 bytes)  
POPM=Windows Media Player 9 Series=0 255/255  
TALB=Catharsis  
TCON=Other  
TCOP=CC BY-NC-ND 4.0  
TDRC=2016  
TENC=Lavf54.63.104  
TIT2=December Falling  
TPE1=Cousin Silas  
TPOS=01  
TPUB=Hortus Conclusus Records  
TRCK=08  
WOAF=CC BY-NC-ND 4.0  
WOAS=https://archive.org/details/CousinSilasCatharsis\_HCR2016Catharsis

* * *

I’m kind of mis-using the WOAF field here (WXXX fields are text fields which are only supposed to contain URL’s, which I hadn’t realized until I dug into the Puddle Tag docs while researching this), but mutagen (and other tools) don’t choke on this misuse as they don’t appear to do any URL validation.

I will dig into the MediaFile source code – but given my surface level understanding of python it’s going to be an uphill struggle for me.
