Skip to content

Instantly share code, notes, and snippets.

@scturtle
Created December 6, 2012 08:41
Show Gist options
  • Save scturtle/4222871 to your computer and use it in GitHub Desktop.
Save scturtle/4222871 to your computer and use it in GitHub Desktop.
deal with album downloaded from xiami
# coding: utf-8
from path import path
import eyeD3
eyeD3.LOCAL_ENCODING = 'utf-8'
b = path('.')
artist = b.abspath().basename()
for f in b.walkfiles():
if f.ext != '.mp3':
continue
album, title = f.splitall()[-2:]
title = title[:-4]
artist, album, title = map(lambda x: x.encode('utf-8'),
[artist, album, title])
tag = eyeD3.Tag()
tag.link(f.abspath())
tag.header.setVersion(eyeD3.ID3_V2_3)
tag.encoding = '\x01'
tag.setTitle(title)
tag.setAlbum(album)
tag.setArtist(artist)
tag.update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment