3 import os
, shutil
, errno
4 from pyid3lib
import tag
6 def organiseMP3(tempFileName
):
8 id3tag
= tag(tempFileName
)
12 title
= 'Unknown Title'
14 artist
= id3tag
.artist
16 artist
= 'Unknown Artist'
20 album
= 'Unknown Album'
21 fileName
= "%s.mp3" % (title
)
22 songDir
= os
.path
.join('/tmp', artist
, album
)
26 if e
.errno
!= errno
.EEXIST
:
28 target
= os
.path
.join(songDir
, fileName
)
29 shutil
.move(tempFileName
, target
)
30 print "Pwn'd an MP3 file: %s" % (target
)
32 print "Encoding/identification errors have occurred, but a temp file was stored.", e
33 shutil
.move(tempFileName
, "./")