Running shell commands from bytes objects in python 3.1 (Or writing UTF-8 mp3 tags in python 3.1)
Question: I'm writing a script which uses .CUE files to split monolithic music files
into individual tracks, then encodes them in MP3 along with correct tags from
the CUE. It's all working, but unfortunately the tags (applied simply through
including them with `lame`'s command line arguments) reliably show up as
gibberish in iTunes when they include unicode characters (Which they always
do, due to the music being Japanese).

I can fix them by running them through
[this](http://code.google.com/p/mp3tagiconv/) script, but that's another
script to run , and occasionally attaches quote marks to the tags (A bug I
have been unable to fix), requiring yet one more run of a script to remove.

So my preferred solution is to encode the `lame` command + arguments string as
UTF-8 before running it, but python 3.1 appears to have no support for running
commands from bytes rather than strings. Simply passing a string instead
encodes incorrectly.

Alternatively, I'm happy with simply using a tagging library to insert the
tags after the encoding is finished, though a solution like that is slower and
less elegant. Any suggestions are welcome, though!

Thanks in advance.

EDIT: I invoke `lame` like this (sorry for long line):

    
    
    args = "lame --tt \"{0}\" --tn {1:02d}  --ta \"{2}\" --tl \"{3}\"  \"{4}\" \"{5}.mp3\"".format(item.title, item.tracknumber, item.artist, albumObject.title, item.wavFile, "{0:02d} ".format(item.tracknumber) + item.title)
    #args = bytearray(args, "utf-8")
    retcode = subprocess.check_call(args)
    


Answer: If you choose to use tagging library you may look at
[eyeD3](http://eyed3.nicfit.net); then you could set utf-8 encoded tags as
follows:

    
    
    import eyeD3
    
    tag = eyeD3.Tag ('file.mp3')
    tag.setVersion (eyeD3.ID3_V2_4)
    tag.setTextEncoding (eyeD3.UTF_8_ENCODING)
    tag.setArtist ('artist')
    tag.setAlbum ('album')
    tag.setTitle ('title')
    tag.update ()
    

